File: glib.adb

package info (click to toggle)
libgtkada2 2.8.1-6lenny3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,496 kB
  • ctags: 3,886
  • sloc: ada: 103,189; ansic: 45,411; perl: 5,500; sh: 2,812; makefile: 1,169; xml: 19
file content (142 lines) | stat: -rw-r--r-- 4,587 bytes parent folder | download | duplicates (4)
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
-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   --
--                 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 Interfaces.C.Strings; use Interfaces.C.Strings;

package body Glib is

   ----------------------
   -- To_Boolean_Array --
   ----------------------

   function To_Boolean_Array (A : in Gboolean_Array) return Boolean_Array is
      Result : Boolean_Array (A'Range);
   begin
      for Index in A'Range loop
         Result (Index) := A (Index) /= 0;
      end loop;

      return Result;
   end To_Boolean_Array;

   -------------
   -- To_Gint --
   -------------

   function To_Gint (Bool : in Boolean) return Gint is
   begin
      if Bool then
         return 1;
      else
         return 0;
      end if;
   end To_Gint;

   -----------------------
   -- Quark_From_String --
   -----------------------

   function Quark_From_String (Id : in String) return GQuark is
      function Internal (Id : String) return GQuark;
      pragma Import (C, Internal, "g_quark_from_string");
   begin
      return Internal (Id & ASCII.NUL);
   end Quark_From_String;

   ----------------------
   -- Quark_Try_String --
   ----------------------

   function Quark_Try_String (Id : in String) return GQuark is
      function Internal (Id : String) return GQuark;
      pragma Import (C, Internal, "g_quark_try_string");
   begin
      return Internal (Id & ASCII.NUL);
   end Quark_Try_String;

   ---------------
   -- Type_Name --
   ---------------

   function Type_Name (Type_Num : in GType) return String is
      function Internal (Type_Num : GType) return chars_ptr;
      pragma Import (C, Internal, "g_type_name");
      Ret : constant chars_ptr := Internal (Type_Num);
   begin
      if Ret = Null_Ptr then
         return "";
      else
         return Value (Ret);
      end if;
   end Type_Name;

   --------------------
   -- Type_From_Name --
   --------------------

   function Type_From_Name (Name : in String) return GType is
      function Internal (Name : String) return GType;
      pragma Import (C, Internal, "g_type_from_name");
   begin
      return Internal (Name & ASCII.NUL);
   end Type_From_Name;

   -----------
   -- Build --
   -----------

   function Build (Name : String) return Property is
   begin
      if Name (Name'Last) /= ASCII.NUL then
         return Property (Name & ASCII.NUL);
      else
         return Property (Name);
      end if;
   end Build;

   -------------------
   -- Property_Name --
   -------------------

   function Property_Name (Prop : Property) return String is
   begin
      return String (Prop);
   end Property_Name;

   --------------------------------
   -- Boxed_Type_Register_Static --
   --------------------------------

   function Boxed_Type_Register_Static
     (Name : String;
      Copy : Boxed_Copy;
      Free : Boxed_Free) return GType
   is
      function Internal
        (N : String; Copy : Boxed_Copy; Free : Boxed_Free) return GType;
      pragma Import (C, Internal, "g_boxed_type_register_static");
   begin
      return Internal (Name & ASCII.NUL, Copy, Free);
   end Boxed_Type_Register_Static;

end Glib;