~ubuntu-branches/ubuntu/intrepid/libgtkada2/intrepid

« back to all changes in this revision

Viewing changes to src/gtk-icon_factory.adb

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2008-08-11 09:46:51 UTC
  • mfrom: (6.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20080811094651-9mjd6acwa98ffw5c
Tags: 2.12.0-2ubuntu1
Add lpia to supported architectures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
-----------------------------------------------------------------------
2
2
--              GtkAda - Ada95 binding for Gtk+/Gnome                --
3
3
--                                                                   --
 
4
--                 Copyright (C) 2004-2008, AdaCore                  --
4
5
--                                                                   --
5
6
-- This library is free software; you can redistribute it and/or     --
6
7
-- modify it under the terms of the GNU General Public               --
20
20
--                                                                   --
21
21
-----------------------------------------------------------------------
22
22
 
23
 
with Ada.Unchecked_Conversion;
 
23
with Gtkada.Bindings;      use Gtkada.Bindings;
24
24
with System;               use System;
25
25
with Gdk.Pixbuf;           use Gdk.Pixbuf;
26
26
with Gtk;                  use Gtk;
28
28
with Interfaces.C.Strings; use Interfaces.C.Strings;
29
29
with Gtk.Widget;           use Gtk.Widget;
30
30
 
 
31
with Glib.Type_Conversion_Hooks;
 
32
 
31
33
package body Gtk.Icon_Factory is
32
34
 
 
35
   package Type_Conversion is new Glib.Type_Conversion_Hooks.Hook_Registrator
 
36
     (Get_Type'Access, Gtk_Icon_Factory_Record);
 
37
   pragma Warnings (Off, Type_Conversion);
 
38
 
33
39
   -------------
34
40
   -- Gtk_New --
35
41
   -------------
217
223
   ---------------
218
224
 
219
225
   function Get_Sizes (Icon_Set : Gtk_Icon_Set) return Gint_Array is
 
226
      use Gint_Arrays;
220
227
      procedure Internal
221
228
        (Icon_Set : Gtk_Icon_Set;
222
 
         Result   : access System.Address;
 
229
         Result   : access Unbounded_Array_Access;
223
230
         N_Sizes  : access Gint);
224
231
      pragma Import (C, Internal, "gtk_icon_set_get_sizes");
225
232
 
226
 
      type Big_Int_Array is array (Natural) of Gint;
227
 
      pragma Convention (C, Big_Int_Array);
228
 
 
229
 
      type Big_Int_Array_Access is access Big_Int_Array;
230
 
      function Convert is new Ada.Unchecked_Conversion
231
 
        (System.Address, Big_Int_Array_Access);
232
 
 
233
 
      procedure G_Free (S : System.Address);
234
 
      pragma Import (C, G_Free, "g_free");
235
 
      --  External binding: g_free
236
 
 
237
233
      Count  : aliased Gint;
238
 
      Result : aliased System.Address;
 
234
      Result : aliased Unbounded_Array_Access;
239
235
   begin
240
236
      Internal (Icon_Set, Result'Access, Count'Access);
241
 
      if Result = System.Null_Address then
242
 
         return (1 .. 0 => 0);
243
 
      else
244
 
         declare
245
 
            Result2 : constant Big_Int_Array_Access := Convert (Result);
246
 
            Output  : Gint_Array (0 .. Natural (Count - 1));
247
 
         begin
248
 
            for O in Output'Range loop
249
 
               Output (O) := Result2 (O);
250
 
            end loop;
251
 
            G_Free (Result);
252
 
            return Output;
253
 
         end;
254
 
      end if;
 
237
      declare
 
238
         Output : constant Gint_Array := To_Array (Result, Integer (Count));
 
239
      begin
 
240
         G_Free (Result);
 
241
         return Output;
 
242
      end;
255
243
   end Get_Sizes;
256
244
 
257
245
   ---------------------
297
285
         Detail    : chars_ptr)
298
286
         return Gdk_Pixbuf;
299
287
      pragma Import (C, Internal, "gtk_icon_set_render_icon");
300
 
      Str : chars_ptr := Null_Ptr;
 
288
      Str : chars_ptr := String_Or_Null (Detail);
301
289
      W   : System.Address := System.Null_Address;
302
290
      Result : Gdk_Pixbuf;
303
291
   begin
304
 
      if Detail /= "" then
305
 
         Str := New_String (Detail);
306
 
      end if;
307
 
 
308
292
      if Widget /= null then
309
293
         W := Get_Object (Widget);
310
294
      end if;
343
327
      pragma Import (C, Internal, "gtk_style_render_icon");
344
328
      --  External binding: gtk_style_render_icon
345
329
 
346
 
      Str    : chars_ptr := Null_Ptr;
 
330
      Str    : chars_ptr := String_Or_Null (Detail);
347
331
      W      : System.Address := System.Null_Address;
348
332
      Result : Gdk_Pixbuf;
349
333
   begin
350
 
      if Detail /= "" then
351
 
         Str := New_String (Detail);
352
 
      end if;
353
 
 
354
334
      if Widget /= null then
355
335
         W := Get_Object (Widget);
356
336
      end if;