1----------------------------------------------------------------------- 2-- GtkAda - Ada95 binding for the Gimp Toolkit -- 3-- -- 4-- Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet -- 5-- Copyright (C) 2000-2013, AdaCore -- 6-- -- 7-- This library is free software; you can redistribute it and/or -- 8-- modify it under the terms of the GNU General Public -- 9-- License as published by the Free Software Foundation; either -- 10-- version 2 of the License, or (at your option) any later version. -- 11-- -- 12-- This library is distributed in the hope that it will be useful, -- 13-- but WITHOUT ANY WARRANTY; without even the implied warranty of -- 14-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- 15-- General Public License for more details. -- 16-- -- 17-- You should have received a copy of the GNU General Public -- 18-- License along with this library; if not, write to the -- 19-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- 20-- Boston, MA 02111-1307, USA. -- 21-- -- 22-- As a special exception, if other files instantiate generics from -- 23-- this unit, or you link this unit with other files to produce an -- 24-- executable, this unit does not by itself cause the resulting -- 25-- executable to be covered by the GNU General Public License. This -- 26-- exception does not however invalidate any other reasons why the -- 27-- executable file might be covered by the GNU Public License. -- 28----------------------------------------------------------------------- 29 30with Interfaces.C.Strings; use Interfaces.C.Strings; 31 32package body Glib is 33 34 ---------------------- 35 -- To_Boolean_Array -- 36 ---------------------- 37 38 function To_Boolean_Array (A : in Gboolean_Array) return Boolean_Array is 39 Result : Boolean_Array (A'Range); 40 begin 41 for Index in A'Range loop 42 Result (Index) := A (Index) /= 0; 43 end loop; 44 45 return Result; 46 end To_Boolean_Array; 47 48 ------------- 49 -- To_Gint -- 50 ------------- 51 52 function To_Gint (Bool : in Boolean) return Gint is 53 begin 54 if Bool then 55 return 1; 56 else 57 return 0; 58 end if; 59 end To_Gint; 60 61 ----------------------- 62 -- Quark_From_String -- 63 ----------------------- 64 65 function Quark_From_String (Id : in String) return GQuark is 66 function Internal (Id : String) return GQuark; 67 pragma Import (C, Internal, "g_quark_from_string"); 68 begin 69 return Internal (Id & ASCII.NUL); 70 end Quark_From_String; 71 72 ---------------------- 73 -- Quark_Try_String -- 74 ---------------------- 75 76 function Quark_Try_String (Id : in String) return GQuark is 77 function Internal (Id : String) return GQuark; 78 pragma Import (C, Internal, "g_quark_try_string"); 79 begin 80 return Internal (Id & ASCII.NUL); 81 end Quark_Try_String; 82 83 --------------- 84 -- Type_Name -- 85 --------------- 86 87 function Type_Name (Type_Num : in GType) return String is 88 function Internal (Type_Num : GType) return chars_ptr; 89 pragma Import (C, Internal, "g_type_name"); 90 Ret : constant chars_ptr := Internal (Type_Num); 91 begin 92 if Ret = Null_Ptr then 93 return ""; 94 else 95 return Value (Ret); 96 end if; 97 end Type_Name; 98 99 -------------------- 100 -- Type_From_Name -- 101 -------------------- 102 103 function Type_From_Name (Name : in String) return GType is 104 function Internal (Name : String) return GType; 105 pragma Import (C, Internal, "g_type_from_name"); 106 begin 107 return Internal (Name & ASCII.NUL); 108 end Type_From_Name; 109 110 ----------- 111 -- Build -- 112 ----------- 113 114 function Build (Name : String) return Property is 115 begin 116 if Name (Name'Last) /= ASCII.NUL then 117 return Property (Name & ASCII.NUL); 118 else 119 return Property (Name); 120 end if; 121 end Build; 122 123 ------------------- 124 -- Property_Name -- 125 ------------------- 126 127 function Property_Name (Prop : Property) return String is 128 begin 129 return String (Prop); 130 end Property_Name; 131 132 -------------------------------- 133 -- Boxed_Type_Register_Static -- 134 -------------------------------- 135 136 function Boxed_Type_Register_Static 137 (Name : String; 138 Copy : Boxed_Copy; 139 Free : Boxed_Free) return GType 140 is 141 function Internal 142 (N : String; Copy : Boxed_Copy; Free : Boxed_Free) return GType; 143 pragma Import (C, Internal, "g_boxed_type_register_static"); 144 begin 145 return Internal (Name & ASCII.NUL, Copy, Free); 146 end Boxed_Type_Register_Static; 147 148end Glib; 149