This file is indexed.

/usr/share/ada/adainclude/gtkada/gtk-selection.adb is in libgtkada2.24.4-dev 2.24.4dfsg-1.

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
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
-----------------------------------------------------------------------
--               GtkAda - Ada95 binding for Gtk+/Gnome               --
--                                                                   --
--                Copyright (C) 2000-2013, 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 Gtkada.C;             use Gtkada.C;
with Gdk.Pixbuf;           use Gdk.Pixbuf;
with Gdk.Types;            use Gdk.Types;
with Interfaces.C.Strings; use Interfaces.C, Interfaces.C.Strings;
with System;               use System;
with GNAT.Strings;         use GNAT.Strings;

package body Gtk.Selection is

   package Atom_Arrays is new Gtkada.C.Unbounded_Arrays
     (Gdk.Types.Gdk_Atom, Gdk.Types.Gdk_None,
      Natural, Gdk.Types.Gdk_Atom_Array);

   ------------------------
   -- Get_Data_As_String --
   ------------------------

   function Get_Data_As_String
     (Selection : Selection_Data) return String
   is
      function Internal
        (Selection : Selection_Data) return Interfaces.C.Strings.chars_ptr;
      pragma Import (C, Internal, "gtk_selection_data_get_data");

   begin
      return Interfaces.C.Strings.Value (Internal (Selection));
   end Get_Data_As_String;

   ----------------
   -- Get_Pixbuf --
   ----------------

   function Get_Pixbuf
     (Selection : Selection_Data) return Gdk.Pixbuf.Gdk_Pixbuf
   is
      function Internal
        (Selection : Selection_Data) return System.Address;
      pragma Import (C, Internal, "gtk_selection_data_get_pixbuf");
   begin
      return Gdk.Pixbuf.Convert (Internal (Selection));
   end Get_Pixbuf;

   ------------------------
   -- Selection_Data_Set --
   ------------------------

   procedure Selection_Data_Set
     (Selection : Selection_Data;
      The_Type  : Gdk.Types.Gdk_Atom;
      Format    : Gint;
      Data      : String) is
   begin
      Selection_Data_Set
        (Selection, The_Type, Format, Data'Address, Data'Length);
   end Selection_Data_Set;

   ---------------------
   -- Target_List_New --
   ---------------------

   function Target_List_New
     (Targets : Target_Entry_Array) return Target_List
   is
      function Internal
        (Targets : System.Address; N_Targets : Guint) return Target_List;
      pragma Import (C, Internal, "gtk_target_list_new");

   begin
      return Internal (Targets'Address, Targets'Length);
   end Target_List_New;

   ---------------------------
   -- Target_List_Add_Table --
   ---------------------------

   procedure Target_List_Add_Table
     (List    : Target_List;
      Targets : Target_Entry_Array)
   is
      procedure Internal
        (List      : Target_List;
         Targets   : System.Address;
         N_Targets : Guint);
      pragma Import (C, Internal, "gtk_target_list_add_table");

   begin
      Internal (List, Targets'Address, Targets'Length);
   end Target_List_Add_Table;

   ----------------------
   -- Target_List_Find --
   ----------------------

   procedure Target_List_Find
     (List   : Target_List;
      Target : Gdk.Types.Gdk_Atom;
      Info   : out Guint;
      Found  : out Boolean)
   is
      function Internal
        (List   : Target_List;
         Target : Gdk.Types.Gdk_Atom;
         Info   : System.Address) return Gboolean;
      pragma Import (C, Internal, "gtk_target_list_find");

      J : aliased Guint;

   begin
      Found := Boolean'Val (Internal (List, Target, J'Address));
      Info := J;
   end Target_List_Find;

   ---------------
   -- Owner_Set --
   ---------------

   function Owner_Set
     (Widget    : Gtk.Widget.Gtk_Widget;
      Selection : Gdk_Selection := Selection_Primary;
      Time      : Guint32 := 0) return Boolean
   is
      function Internal
        (Widget    : System.Address;
         Selection : Gdk_Selection;
         Time      : Guint32) return Gint;
      pragma Import (C, Internal, "gtk_selection_owner_set");

   begin
      return Boolean'Val (Internal (Get_Object (Widget), Selection, Time));
   end Owner_Set;

   ----------------
   -- Add_Target --
   ----------------

   procedure Add_Target
     (Widget    : access Gtk.Widget.Gtk_Widget_Record'Class;
      Selection : Gdk_Selection;
      Target    : Gdk.Types.Gdk_Atom;
      Info      : Guint)
   is
      procedure Internal
        (Widget    : System.Address;
         Selection : Gdk_Selection;
         Target    : Gdk.Types.Gdk_Atom;
         Info      : Guint);
      pragma Import (C, Internal, "gtk_selection_add_target");

   begin
      Internal (Get_Object (Widget), Selection, Target, Info);
   end Add_Target;

   -----------------
   -- Add_Targets --
   -----------------

   procedure Add_Targets
     (Widget    : access Gtk.Widget.Gtk_Widget_Record'Class;
      Selection : Gdk_Selection;
      Targets   : Target_Entry_Array)
   is
      procedure Internal
        (Widget    : System.Address;
         Selection : Gdk_Selection;
         Targets   : System.Address;
         N_Targets : Guint);
      pragma Import (C, Internal, "gtk_selection_add_targets");

   begin
      Internal (Get_Object (Widget), Selection, Targets'Address,
                Targets'Length);
   end Add_Targets;

   -------------
   -- Convert --
   -------------

   function Convert
     (Widget    : access Gtk.Widget.Gtk_Widget_Record'Class;
      Selection : Gdk_Selection := Selection_Primary;
      Target    : Gdk.Types.Gdk_Atom;
      Time      : Guint32 := 0) return Boolean
   is
      function Internal
        (Widget    : System.Address;
         Selection : Gdk_Selection;
         Target    : Gdk.Types.Gdk_Atom;
         Time      : Guint32) return Gint;
      pragma Import (C, Internal, "gtk_selection_convert");

   begin
      return Boolean'Val (Internal (Get_Object (Widget), Selection,
                                    Target, Time));
   end Convert;

   -------------------
   -- Clear_Targets --
   -------------------

   procedure Clear_Targets
     (Widget    : access Gtk.Widget.Gtk_Widget_Record'Class;
      Selection : Gdk_Selection)
   is
      procedure Internal
        (Widget    : System.Address;
         Selection : Gdk_Selection);
      pragma Import (C, Internal, "gtk_selection_clear_targets");

   begin
      Internal (Get_Object (Widget), Selection);
   end Clear_Targets;

   ----------------
   -- Remove_All --
   ----------------

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

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

   ----------------
   -- Set_Pixbuf --
   ----------------

   function Set_Pixbuf
     (Selection : Selection_Data;
      Pixbuf    : Gdk_Pixbuf)
      return Boolean
   is
      function Internal
        (Selection : Selection_Data;
         Pixbuf    : System.Address)
         return Gboolean;
      pragma Import (C, Internal, "gtk_selection_data_set_pixbuf");
   begin
      return Boolean'Val (Internal (Selection, Get_Object (Pixbuf)));
   end Set_Pixbuf;

   --------------
   -- Get_Text --
   --------------

   function Get_Text
     (Selection : Selection_Data) return String
   is
      function Internal
        (Selection : Selection_Data) return Interfaces.C.Strings.chars_ptr;
      pragma Import (C, Internal, "gtk_selection_data_get_text");
      Val    : chars_ptr := Internal (Selection);
      Result : constant String := Value (Val);
   begin
      Free (Val);
      return Result;
   end Get_Text;

   --------------
   -- Set_Text --
   --------------

   function Set_Text
     (Selection : Selection_Data;
      Str       : UTF8_String)
      return Boolean
   is
      function Internal
        (Selection : Selection_Data;
         Str       : String;
         Len       : Gint)
         return Gboolean;
      pragma Import (C, Internal, "gtk_selection_data_set_text");
   begin
      return Boolean'Val
        (Internal (Selection, Str, Str'Length));
   end Set_Text;

   -----------------
   -- Get_Targets --
   -----------------

   function Get_Targets
     (Selection : Selection_Data) return Gdk.Types.Gdk_Atom_Array
   is
      use Atom_Arrays;
      function Internal
        (Selection : Selection_Data;
         Targets   : access Unbounded_Array_Access;
         N_Atoms   : access Gint) return Gboolean;
      pragma Import (C, Internal, "gtk_selection_data_get_targets");

      Output    : aliased Unbounded_Array_Access;
      N         : aliased Gint;
   begin
      if Internal
        (Selection, Output'Unchecked_Access, N'Unchecked_Access) = 0
      then
         Output := null;
      end if;

      declare
         Result : constant Gdk_Atom_Array := To_Array (Output, Integer (N));
      begin
         G_Free (Output);
         return Result;
      end;
   end Get_Targets;

   ---------------------------
   -- Targets_Include_Image --
   ---------------------------

   function Targets_Include_Image
     (Selection : Selection_Data; Writable : Boolean := True) return Boolean
   is
      function Internal
        (Selection : Selection_Data; Writable : Gboolean) return Gboolean;
      pragma Import (C, Internal, "gtk_selection_data_targets_include_image");
   begin
      return Boolean'Val (Internal (Selection, Boolean'Pos (Writable)));
   end Targets_Include_Image;

   --------------------------
   -- Targets_Include_Text --
   --------------------------

   function Targets_Include_Text (Selection : Selection_Data) return Boolean is
      function Internal (Selection : Selection_Data) return Gboolean;
      pragma Import (C, Internal, "gtk_selection_data_targets_include_text");
   begin
      return Boolean'Val (Internal (Selection));
   end Targets_Include_Text;

   -----------------------------------
   -- Target_List_Add_Image_Targets --
   -----------------------------------

   procedure Target_List_Add_Image_Targets
     (List      : Target_List;
      Info      : Guint;
      Writable  : Boolean)
   is
      procedure Internal
        (List     : Target_List;
         Info     : Guint;
         Writable : Gboolean);
      pragma Import (C, Internal, "gtk_target_list_add_image_targets");
   begin
      Internal (List, Info, Boolean'Pos (Writable));
   end Target_List_Add_Image_Targets;

   --------------
   -- Set_Uris --
   --------------

   function Set_Uris
     (Selection : Selection_Data;
      URIs      : GNAT.Strings.String_List)
      return Boolean
   is
      function Internal
        (Selection : Selection_Data; URIs : chars_ptr_array) return Gboolean;
      pragma Import (C, Internal, "gtk_selection_data_set_uris");

      List : chars_ptr_array (1 .. size_t (URIs'Length) + 1);
      Result : Gboolean;
   begin
      for U in URIs'Range loop
         List (size_t (U - URIs'First) + List'First) :=
           New_String (URIs (U).all);
      end loop;
      List (List'Last) := Null_Ptr;
      Result := Internal (Selection, List);

      Gtkada.Types.Free (List);
      return Boolean'Val (Result);
   end Set_Uris;

   --------------
   -- Get_Uris --
   --------------

   function Get_Uris
     (Selection : Selection_Data)
      return GNAT.Strings.String_List
   is
      function Internal (Selection : Selection_Data) return System.Address;
      pragma Import (C, Internal, "gtk_selection_data_get_uris");

      function Get_Length (S : System.Address) return Integer;
      pragma Import (C, Get_Length, "ada_string_array_length");

      function Get (S : System.Address; Index : Natural) return chars_ptr;
      pragma Import (C, Get, "ada_string_array_get");

      Result : constant System.Address := Internal (Selection);
   begin
      if Result = System.Null_Address then
         return (1 .. 0 => null);
      else
         declare
            Output : String_List (1 .. Get_Length (Result));
            Tmp    : chars_ptr;
         begin
            for L in Output'Range loop
               Tmp := Get (Result, L - Output'First);
               Output (L) := new String'(Value (Tmp));
               Free (Tmp);
            end loop;
            return Output;
         end;
      end if;
   end Get_Uris;

end Gtk.Selection;