File: gtk-dnd.adb

package info (click to toggle)
libgtkada2 2.8.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 13,488 kB
  • ctags: 3,888
  • sloc: ada: 103,189; ansic: 45,411; perl: 5,500; sh: 2,812; makefile: 1,146; xml: 19
file content (585 lines) | stat: -rw-r--r-- 17,585 bytes parent folder | download | duplicates (2)
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
-----------------------------------------------------------------------
--               GtkAda - Ada95 binding for Gtk+/Gnome               --
--                                                                   --
--                Copyright (C) 2000-2006 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 Gdk.Bitmap;    use Gdk.Bitmap;
with Gdk.Color;     use Gdk.Color;
with Gdk.Event;     use Gdk.Event;
with Gdk.Pixmap;    use Gdk.Pixmap;
with Gdk.Types;     use Gdk.Types;
with Gdk.Window;    use Gdk.Window;
with Gtk.Widget;    use Gtk.Widget;

package body Gtk.Dnd is

   ---------------------
   -- Set_Icon_Pixbuf --
   ---------------------

   procedure Set_Icon_Pixbuf
     (Context : Drag_Context;
      Pixbuf  : Gdk.Pixbuf.Gdk_Pixbuf;
      Hot_X   : Gint;
      Hot_Y   : Gint)
   is
      procedure Internal
        (Context : Drag_Context;
         Pixbuf  : Gdk.Pixbuf.Gdk_Pixbuf;
         Hot_X   : Gint;
         Hot_Y   : Gint);
      pragma Import (C, Internal, "gtk_drag_set_icon_pixbuf");
   begin
      Internal (Context,
                Pixbuf,
                Hot_X,
                Hot_Y);
   end Set_Icon_Pixbuf;

   -------------------
   -- Set_Icon_Name --
   -------------------

   procedure Set_Icon_Name
     (Context   : Drag_Context;
      Icon_Name : String;
      Hot_X     : Gint;
      Hot_Y     : Gint)
   is
      procedure Internal
        (Context   : Drag_Context;
         Icon_Name : String;
         Hot_X     : Gint;
         Hot_Y     : Gint);
      pragma Import (C, Internal, "gtk_drag_set_icon_name");
   begin
      Internal (Context, Icon_Name & ASCII.NUL, Hot_X, Hot_Y);
   end Set_Icon_Name;

   --------------------
   -- Set_Icon_Stock --
   --------------------

   procedure Set_Icon_Stock
     (Context  : Drag_Context;
      Stock_Id : String;
      Hot_X    : Gint;
      Hot_Y    : Gint)
   is
      procedure Internal
        (Context  : Drag_Context;
         Stock_Id : String;
         Hot_X    : Gint;
         Hot_Y    : Gint);
      pragma Import (C, Internal, "gtk_drag_set_icon_stock");
   begin
      Internal (Context,
                Stock_Id & ASCII.NUL,
                Hot_X,
                Hot_Y);
   end Set_Icon_Stock;

   ----------------------------
   -- Source_Set_Icon_Pixbuf --
   ----------------------------

   procedure Source_Set_Icon_Pixbuf
     (Widget : access Gtk.Widget.Gtk_Widget_Record'Class;
      Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf)
   is
      procedure Internal
        (Widget : System.Address;
         Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf);
      pragma Import (C, Internal, "gtk_drag_source_set_icon_pixbuf");
   begin
      Internal (Get_Object (Widget),
                Pixbuf);
   end Source_Set_Icon_Pixbuf;

   ---------------------------
   -- Source_Set_Icon_Stock --
   ---------------------------

   procedure Source_Set_Icon_Stock
     (Widget   : access Gtk.Widget.Gtk_Widget_Record'Class;
      Stock_Id : String)
   is
      procedure Internal
        (Widget   : System.Address;
         Stock_Id : String);
      pragma Import (C, Internal, "gtk_drag_source_set_icon_stock");
   begin
      Internal (Get_Object (Widget),
                Stock_Id & ASCII.NUL);
   end Source_Set_Icon_Stock;

   --------------------------
   -- Source_Set_Icon_Name --
   --------------------------

   procedure Source_Set_Icon_Name
     (Widget    : access Gtk_Widget_Record'Class;
      Icon_Name : String)
   is
      procedure Internal (Widget : System.Address; Icon_Name : String);
      pragma Import (C, Internal, "gtk_drag_source_set_icon_name");
   begin
      Internal (Get_Object (Widget), Icon_Name & ASCII.NUL);
   end Source_Set_Icon_Name;

   ---------------------
   -- Check_Threshold --
   ---------------------

   function Check_Threshold
     (Widget    : access Gtk.Widget.Gtk_Widget_Record'Class;
      Start_X   : Gint;
      Start_Y   : Gint;
      Current_X : Gint;
      Current_Y : Gint)
      return Boolean
   is
      function Internal
        (Widget    : System.Address;
         Start_X   : Gint;
         Start_Y   : Gint;
         Current_X : Gint;
         Current_Y : Gint)
         return Gint;
      pragma Import (C, Internal, "gtk_drag_check_threshold");
   begin
      return Boolean'Val (Internal (Get_Object (Widget),
                                    Start_X,
                                    Start_Y,
                                    Current_X,
                                    Current_Y));
   end Check_Threshold;

   --------------------------
   -- Dest_Set_Target_List --
   --------------------------

   procedure Dest_Set_Target_List
     (Widget      : access Gtk.Widget.Gtk_Widget_Record'Class;
      Target_List : Gtk.Selection.Target_List)
   is
      procedure Internal
        (Widget      : System.Address;
         Target_List : System.Address);
      pragma Import (C, Internal, "gtk_drag_dest_set_target_list");
   begin
      Internal (Get_Object (Widget), Target_List.all'Address);
   end Dest_Set_Target_List;

   --------------------------
   -- Dest_Get_Target_List --
   --------------------------

   function Dest_Get_Target_List
     (Widget : access Gtk.Widget.Gtk_Widget_Record'Class) return Target_List
   is
      function Internal (Widget : System.Address)
                        return System.Address;
      pragma Import (C, Internal, "gtk_drag_dest_get_target_list");
   begin
      return To_Proxy (Internal (Get_Object (Widget)));
   end Dest_Get_Target_List;

   ----------------------------
   -- Source_Set_Target_List --
   ----------------------------

   procedure Source_Set_Target_List
     (Widget      : access Gtk.Widget.Gtk_Widget_Record'Class;
      Target_List : Gtk.Selection.Target_List)
   is
      procedure Internal
        (Widget      : System.Address;
         Target_List : System.Address);
      pragma Import (C, Internal, "gtk_drag_source_set_target_list");
   begin
      Internal (Get_Object (Widget), Target_List.all'Address);
   end Source_Set_Target_List;

   ----------------------------
   -- Source_Get_Target_List --
   ----------------------------

   function Source_Get_Target_List
     (Widget : access Gtk.Widget.Gtk_Widget_Record'Class) return Target_List
   is
      function Internal (Widget : System.Address)
                        return System.Address;
      pragma Import (C, Internal, "gtk_drag_source_get_target_list");
   begin
      return To_Proxy (Internal (Get_Object (Widget)));
   end Source_Get_Target_List;

   ----------------------
   -- Dest_Find_Target --
   ----------------------

   function Dest_Find_Target
     (Widget      : access Gtk.Widget.Gtk_Widget_Record'Class;
      Context     : Drag_Context;
      Target_List : Gtk.Selection.Target_List) return Gdk.Types.Gdk_Atom
   is
      function Internal
        (Widget      : System.Address;
         Context     : Drag_Context;
         Target_List : System.Address)
         return Gdk_Atom;
      pragma Import (C, Internal, "gtk_drag_dest_find_target");
   begin
      return Internal (Get_Object (Widget), Context, Target_List.all'Address);
   end Dest_Find_Target;

   --------------
   -- Dest_Set --
   --------------

   procedure Dest_Set
     (Widget  : access Gtk.Widget.Gtk_Widget_Record'Class;
      Flags   : Dest_Defaults := Dest_No_Default;
      Targets : Target_Entry_Array := Any_Target_Entry;
      Actions : Drag_Action := Action_Any)
   is
      procedure Internal
        (Widget    : System.Address;
         Flags     : Dest_Defaults;
         Targets   : System.Address;
         N_Targets : Gint;
         Actions   : Drag_Action);
      pragma Import (C, Internal, "gtk_drag_dest_set");

   begin
      if Targets'Length = 0 then
         Internal
           (Get_Object (Widget), Flags, System.Null_Address, 0, Actions);
      else
         Internal
           (Get_Object (Widget), Flags,
            Targets'Address, Targets'Length, Actions);
      end if;
   end Dest_Set;

   --------------------
   -- Dest_Set_Proxy --
   --------------------

   procedure Dest_Set_Proxy
     (Widget          : access Gtk.Widget.Gtk_Widget_Record'Class;
      Proxy_Window    : Gdk.Window.Gdk_Window;
      Protocol        : Drag_Protocol;
      Use_Coordinates : Boolean)
   is
      procedure Internal
        (Widget          : System.Address;
         Proxy_Window    : Gdk.Window.Gdk_Window;
         Protocol        : Drag_Protocol;
         Use_Coordinates : Gint);
      pragma Import (C, Internal, "gtk_drag_dest_set_proxy");

   begin
      Internal (Get_Object (Widget), Proxy_Window, Protocol,
                Boolean'Pos (Use_Coordinates));
   end Dest_Set_Proxy;

   ----------------
   -- Dest_Unset --
   ----------------

   procedure Dest_Unset
     (Widget : access Gtk.Widget.Gtk_Widget_Record'Class)
   is
      procedure Internal (Widget : System.Address);
      pragma Import (C, Internal, "gtk_drag_dest_unset");

   begin
      Internal (Get_Object (Widget));
   end Dest_Unset;

   ----------------
   -- Source_Set --
   ----------------

   procedure Source_Set
     (Widget            : access Gtk.Widget.Gtk_Widget_Record'Class;
      Start_Button_Mask : in Gdk.Types.Gdk_Modifier_Type;
      Targets           : in Target_Entry_Array;
      Actions           : in Drag_Action)
   is
      procedure Internal
        (Widget            : System.Address;
         Start_Button_Mask : Gdk.Types.Gdk_Modifier_Type;
         Targets           : System.Address;
         N_Targets         : Gint;
         Actions           : Drag_Action);
      pragma Import (C, Internal, "gtk_drag_source_set");

   begin
      Internal (Get_Object (Widget), Start_Button_Mask,
                Targets (Targets'First)'Address,
                Targets'Length,
                Actions);
   end Source_Set;

   ------------------
   -- Source_Unset --
   ------------------

   procedure Source_Unset
     (Widget : access Gtk.Widget.Gtk_Widget_Record'Class)
   is
      procedure Internal (Widget : System.Address);
      pragma Import (C, Internal, "gtk_drag_source_unset");

   begin
      Internal (Get_Object (Widget));
   end Source_Unset;

   ------------
   -- Finish --
   ------------

   procedure Finish
     (Context : Drag_Context;
      Success : Boolean;
      Del     : Boolean;
      Time    : Guint32 := 0)
   is
      procedure Internal
        (Context  : Drag_Context;
         Succcess : Gint;
         Del      : Gint;
         Time     : Guint32);
      pragma Import (C, Internal, "gtk_drag_finish");

   begin
      Internal (Context, Boolean'Pos (Success), Boolean'Pos (Del), Time);
   end Finish;

   --------------
   -- Get_Data --
   --------------

   procedure Get_Data
     (Widget  : access Gtk.Widget.Gtk_Widget_Record'Class;
      Context : Drag_Context;
      Target  : Gdk.Types.Gdk_Atom;
      Time    : Guint32 := 0)
   is
      procedure Internal
        (Widget   : System.Address;
         Context  : Drag_Context;
         Target   : Gdk.Types.Gdk_Atom;
         Time     : Guint32);
      pragma Import (C, Internal, "gtk_drag_get_data");

   begin
      Internal (Get_Object (Widget), Context, Target, Time);
   end Get_Data;

   -----------------------
   -- Get_Source_Widget --
   -----------------------

   function Get_Source_Widget
     (Context : in Drag_Context) return Gtk.Widget.Gtk_Widget
   is
      function Internal (Context : Drag_Context) return System.Address;
      pragma Import (C, Internal, "gtk_drag_get_source_widget");

   begin
      return Convert (Internal (Context));
   end Get_Source_Widget;

   ---------------
   -- Highlight --
   ---------------

   procedure Highlight (Widget : access Gtk.Widget.Gtk_Widget_Record'Class) is
      procedure Internal (Widget : System.Address);
      pragma Import (C, Internal, "gtk_drag_highlight");

   begin
      Internal (Get_Object (Widget));
   end Highlight;

   -----------------
   -- Unhighlight --
   -----------------

   procedure Unhighlight
     (Widget : access Gtk.Widget.Gtk_Widget_Record'Class)
   is
      procedure Internal (Widget : System.Address);
      pragma Import (C, Internal, "gtk_drag_unhighlight");

   begin
      Internal (Get_Object (Widget));
   end Unhighlight;

   ----------------
   -- Drag_Begin --
   ----------------

   function Drag_Begin
     (Widget  : access Gtk.Widget.Gtk_Widget_Record'Class;
      Targets : Target_List;
      Actions : Drag_Action;
      Button  : Gint;
      Event   : Gdk.Event.Gdk_Event) return Drag_Context
   is
      function Internal
        (Widget  : System.Address;
         Targets : Target_List;
         Actions : Drag_Action;
         Button  : Gint;
         Event   : System.Address) return Drag_Context;
      pragma Import (C, Internal, "gtk_drag_begin");

   begin
      return Internal (Get_Object (Widget), Targets, Actions, Button,
                       To_Address (Event));
   end Drag_Begin;

   ---------------------
   -- Set_Icon_Widget --
   ---------------------

   procedure Set_Icon_Widget
     (Context : Drag_Context;
      Widget  : access Gtk.Widget.Gtk_Widget_Record'Class;
      Hot_X   : Gint;
      Hot_Y   : Gint)
   is
      procedure Internal
        (Context : Drag_Context;
         Widget  : System.Address;
         Hot_X   : Gint;
         Hot_Y   : Gint);
      pragma Import (C, Internal, "gtk_drag_set_icon_widget");

   begin
      Internal (Context, Get_Object (Widget), Hot_X, Hot_Y);
   end Set_Icon_Widget;

   ---------------------
   -- Source_Set_Icon --
   ---------------------

   procedure Source_Set_Icon
     (Widget   : access Gtk.Widget.Gtk_Widget_Record'Class;
      Colormap : Gdk.Color.Gdk_Colormap;
      Pixmap   : Gdk.Pixmap.Gdk_Pixmap;
      Mask     : Gdk.Bitmap.Gdk_Bitmap)
   is
      procedure Internal
        (Widget : System.Address;
         Colormap : Gdk.Gdk_Colormap;
         Pixmap   : Gdk.Pixmap.Gdk_Pixmap;
         Mask     : Gdk.Bitmap.Gdk_Bitmap);
      pragma Import (C, Internal, "gtk_drag_source_set_icon");

   begin
      Internal (Get_Object (Widget), Colormap, Pixmap, Mask);
   end Source_Set_Icon;

   ----------------------------
   -- Dest_Add_Image_Targets --
   ----------------------------

   procedure Dest_Add_Image_Targets
     (Widget : access Gtk_Widget_Record'Class)
   is
      procedure Internal (Widget : System.Address);
      pragma Import (C, Internal, "gtk_drag_dest_add_image_targets");
   begin
      Internal (Get_Object (Widget));
   end Dest_Add_Image_Targets;

   ---------------------------
   -- Dest_Add_Text_Targets --
   ---------------------------

   procedure Dest_Add_Text_Targets
     (Widget : access Gtk_Widget_Record'Class)
   is
      procedure Internal (Widget : System.Address);
      pragma Import (C, Internal, "gtk_drag_dest_add_text_targets");
   begin
      Internal (Get_Object (Widget));
   end Dest_Add_Text_Targets;

   --------------------------
   -- Dest_Add_Uri_Targets --
   --------------------------

   procedure Dest_Add_Uri_Targets
     (Widget : access Gtk_Widget_Record'Class)
   is
      procedure Internal (Widget : System.Address);
      pragma Import (C, Internal, "gtk_drag_dest_add_uri_targets");
   begin
      Internal (Get_Object (Widget));
   end Dest_Add_Uri_Targets;

   ------------------------------
   -- Source_Add_Image_Targets --
   ------------------------------

   procedure Source_Add_Image_Targets
     (Widget : access Gtk_Widget_Record'Class)
   is
      procedure Internal (Widget : System.Address);
      pragma Import (C, Internal, "gtk_drag_source_add_image_targets");
   begin
      Internal (Get_Object (Widget));
   end Source_Add_Image_Targets;

   -----------------------------
   -- Source_Add_Text_Targets --
   -----------------------------

   procedure Source_Add_Text_Targets
     (Widget : access Gtk_Widget_Record'Class)
   is
      procedure Internal (Widget : System.Address);
      pragma Import (C, Internal, "gtk_drag_source_add_text_targets");
   begin
      Internal (Get_Object (Widget));
   end Source_Add_Text_Targets;

   ----------------------------
   -- Source_Add_Uri_Targets --
   ----------------------------

   procedure Source_Add_Uri_Targets
     (Widget : access Gtk_Widget_Record'Class)
   is
      procedure Internal (Widget : System.Address);
      pragma Import (C, Internal, "gtk_drag_source_add_uri_targets");
   begin
      Internal (Get_Object (Widget));
   end Source_Add_Uri_Targets;


end Gtk.Dnd;