/usr/share/ada/adainclude/gtkada/gtkada-printing.adb is in libgtkada2.24.1-dev 2.24.1-14.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | -----------------------------------------------------------------------
-- GtkAda - Ada95 binding for Gtk+/Gnome --
-- --
-- Copyright (C) 2010, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-----------------------------------------------------------------------
with System;
with System.Assertions; use System.Assertions;
with Unchecked_Conversion;
with Glib.Object; use Glib.Object;
with Glib.Values; use Glib.Values;
with Gtk.Arguments; use Gtk.Arguments;
with Gtk.Handlers;
package body Gtkada.Printing is
package Object_Callback is new Gtk.Handlers.Callback
(Gtkada_Print_Operation_Record);
package Object_Boolean_Return_Callback is new Gtk.Handlers.Return_Callback
(Gtkada_Print_Operation_Record, Boolean);
-----------------------
-- Local subprograms --
-----------------------
procedure Begin_Print_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues);
-- Wrapper around callback for "begin-print".
procedure Done_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues);
-- Wrapper around callback for "done".
procedure Draw_Page_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues);
-- Wrapper around callback for "draw-page".
procedure End_Print_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues);
-- Wrapper around callback for "end-print".
function Paginate_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues)
return Boolean;
-- Wrapper around callback for "paginate".
function Preview_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues)
return Boolean;
-- Wrapper around callback for "preview".
procedure Request_Page_Setup_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues);
-- Wrapper around callback for "request-page-setup".
procedure Status_Changed_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues);
-- Wrapper around callback for "status-changed".
-----------------------------
-- Default implementations --
-----------------------------
---------------
-- Draw_Page --
---------------
procedure Draw_Page
(Op : access Gtkada_Print_Operation_Record;
Context : Gtk_Print_Context;
Page_Number : Gint) is
begin
-- This procedure should be overridden.
Raise_Assert_Failure ("Subprogram ""Draw_Page"" should be overridden");
end Draw_Page;
-----------------
-- Begin_Print --
-----------------
procedure Begin_Print
(Op : access Gtkada_Print_Operation_Record;
Context : Gtk_Print_Context) is
begin
-- Default implementation : do nothing
null;
end Begin_Print;
----------
-- Done --
----------
procedure Done
(Op : access Gtkada_Print_Operation_Record;
Result : Gtk_Print_Operation_Result) is
begin
-- Default implementation : do nothing
null;
end Done;
---------------
-- End_Print --
---------------
procedure End_Print
(Op : access Gtkada_Print_Operation_Record;
Context : Gtk_Print_Context) is
begin
-- Default implementation : do nothing
null;
end End_Print;
--------------
-- Paginate --
--------------
function Paginate
(Op : access Gtkada_Print_Operation_Record;
Context : Gtk_Print_Context) return Boolean is
pragma Unreferenced (Op, Context);
begin
-- Default implementation : do nothing
return True;
end Paginate;
-------------
-- Preview --
-------------
function Preview
(Op : access Gtkada_Print_Operation_Record;
Preview : Gtk_Print_Operation_Preview;
Context : Gtk_Print_Context;
Parent : Gtk_Window) return Boolean is
pragma Unreferenced (Op, Preview, Context, Parent);
begin
-- Default implementation: do not override the Gtk+ preview mechanism.
return False;
end Preview;
------------------------
-- Request_Page_Setup --
------------------------
procedure Request_Page_Setup
(Op : access Gtkada_Print_Operation_Record;
Context : Gtk_Print_Context;
Page_Number : Gint;
Setup : Gtk_Page_Setup) is
begin
-- Default implementation : do nothing
null;
end Request_Page_Setup;
--------------------
-- Status_Changed --
--------------------
procedure Status_Changed (Op : access Gtkada_Print_Operation_Record) is
begin
-- Default implementation : do nothing
null;
end Status_Changed;
---------------------------------
-- Begin_Print_Handler_Wrapper --
---------------------------------
procedure Begin_Print_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues)
is
Context_Addr : constant System.Address := To_Address (Args, 1);
Context_Stub : Gtk_Print_Context_Record;
Context : constant Gtk_Print_Context :=
Gtk_Print_Context (Get_User_Data (Context_Addr, Context_Stub));
begin
Begin_Print (Op, Context);
end Begin_Print_Handler_Wrapper;
--------------------------
-- Done_Handler_Wrapper --
--------------------------
procedure Done_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues)
is
Result : constant Gtk_Print_Operation_Result :=
Gtk_Print_Operation_Result'Val (Get_Enum (Nth (Args, 1)));
begin
Done (Op, Result);
end Done_Handler_Wrapper;
-------------------------------
-- Draw_Page_Handler_Wrapper --
-------------------------------
procedure Draw_Page_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues)
is
Context_Addr : constant System.Address := To_Address (Args, 1);
Context_Stub : Gtk_Print_Context_Record;
Context : constant Gtk_Print_Context :=
Gtk_Print_Context (Get_User_Data (Context_Addr, Context_Stub));
Page_Num : constant Gint := To_Gint (Args, 2);
begin
Draw_Page (Op, Context, Page_Num);
end Draw_Page_Handler_Wrapper;
-------------------------------
-- End_Print_Handler_Wrapper --
-------------------------------
procedure End_Print_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues)
is
Context_Addr : constant System.Address := To_Address (Args, 1);
Context_Stub : Gtk_Print_Context_Record;
Context : constant Gtk_Print_Context :=
Gtk_Print_Context (Get_User_Data (Context_Addr, Context_Stub));
begin
End_Print (Op, Context);
end End_Print_Handler_Wrapper;
-------------
-- Gtk_New --
-------------
procedure Gtk_New (Op : out Gtkada_Print_Operation) is
begin
Op := new Gtkada_Print_Operation_Record;
Gtkada.Printing.Initialize (Op);
end Gtk_New;
----------------
-- Initialize --
----------------
procedure Initialize
(Widget : access Gtkada_Print_Operation_Record'Class) is
begin
Gtk.Print_Operation.Initialize (Widget);
end Initialize;
------------------------------
-- Paginate_Handler_Wrapper --
------------------------------
function Paginate_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues)
return Boolean
is
Context_Addr : constant System.Address := To_Address (Args, 1);
Context_Stub : Gtk_Print_Context_Record;
Context : constant Gtk_Print_Context :=
Gtk_Print_Context (Get_User_Data (Context_Addr, Context_Stub));
begin
return Paginate (Op, Context);
end Paginate_Handler_Wrapper;
-----------------------------
-- Preview_Handler_Wrapper --
-----------------------------
function Preview_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues)
return Boolean
is
-- ??? ugly, but otherwise correct.
function To_Preview is
new Unchecked_Conversion (System.Address, Gtk_Print_Operation_Preview);
Preview_Addr : constant System.Address := To_Address (Args, 1);
Preview_Op : constant Gtk_Print_Operation_Preview :=
To_Preview (Preview_Addr);
Context_Addr : constant System.Address := To_Address (Args, 2);
Context_Stub : Gtk_Print_Context_Record;
Context : constant Gtk_Print_Context :=
Gtk_Print_Context (Get_User_Data (Context_Addr, Context_Stub));
Parent_Addr : constant System.Address := To_Address (Args, 3);
Parent_Stub : Gtk_Window_Record;
Parent : constant Gtk_Window :=
Gtk_Window (Get_User_Data (Parent_Addr, Parent_Stub));
begin
return Preview (Op, Preview_Op, Context, Parent);
end Preview_Handler_Wrapper;
----------------------------------------
-- Request_Page_Setup_Handler_Wrapper --
----------------------------------------
procedure Request_Page_Setup_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues)
is
Context_Addr : constant System.Address := To_Address (Args, 1);
Context_Stub : Gtk_Print_Context_Record;
Context : constant Gtk_Print_Context :=
Gtk_Print_Context (Get_User_Data (Context_Addr, Context_Stub));
Page_Num : constant Gint := To_Gint (Args, 2);
Setup_Addr : constant System.Address := To_Address (Args, 3);
Setup_Stub : Gtk_Page_Setup_Record;
Setup : constant Gtk_Page_Setup :=
Gtk_Page_Setup (Get_User_Data (Setup_Addr, Setup_Stub));
begin
Request_Page_Setup (Op, Context, Page_Num, Setup);
end Request_Page_Setup_Handler_Wrapper;
------------------------------------
-- Status_Changed_Handler_Wrapper --
------------------------------------
procedure Status_Changed_Handler_Wrapper
(Op : access Gtkada_Print_Operation_Record'Class;
Args : Glib.Values.GValues)
is
pragma Unreferenced (Args);
begin
Status_Changed (Op);
end Status_Changed_Handler_Wrapper;
---------
-- Run --
---------
function Connect_And_Run
(Op : access Gtkada_Print_Operation_Record'Class;
Action : Gtk_Print_Operation_Action;
Parent : access Gtk.Window.Gtk_Window_Record'Class;
Error : Glib.Error.GError := null)
return Gtk_Print_Operation_Result
is
begin
-- Connect all handlers
Object_Callback.Connect
(Op, "begin-print", Begin_Print_Handler_Wrapper'Access);
Object_Callback.Connect
(Op, "done", Done_Handler_Wrapper'Access);
Object_Callback.Connect
(Op, "draw-page",
Draw_Page_Handler_Wrapper'Access);
Object_Callback.Connect
(Op, "end-print", End_Print_Handler_Wrapper'Access);
Object_Boolean_Return_Callback.Connect
(Op, "paginate", Paginate_Handler_Wrapper'Access);
Object_Boolean_Return_Callback.Connect
(Op, "preview", Preview_Handler_Wrapper'Access);
Object_Callback.Connect
(Op, "request-page-setup",
Request_Page_Setup_Handler_Wrapper'Access);
Object_Callback.Connect
(Op, "status-changed", Status_Changed_Handler_Wrapper'Access);
return Gtk.Print_Operation.Run
(Gtk_Print_Operation (Op), Action, Parent, Error);
end Connect_And_Run;
end Gtkada.Printing;
|