1----------------------------------------------------------------------- 2-- GtkAda - Ada95 binding for Gtk+/Gnome -- 3-- -- 4-- Copyright (C) 2010-2013, AdaCore -- 5-- -- 6-- This library is free software; you can redistribute it and/or -- 7-- modify it under the terms of the GNU General Public -- 8-- License as published by the Free Software Foundation; either -- 9-- version 2 of the License, or (at your option) any later version. -- 10-- -- 11-- This library is distributed in the hope that it will be useful, -- 12-- but WITHOUT ANY WARRANTY; without even the implied warranty of -- 13-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- 14-- General Public License for more details. -- 15-- -- 16-- You should have received a copy of the GNU General Public -- 17-- License along with this library; if not, write to the -- 18-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- 19-- Boston, MA 02111-1307, USA. -- 20-- -- 21-- As a special exception, if other files instantiate generics from -- 22-- this unit, or you link this unit with other files to produce an -- 23-- executable, this unit does not by itself cause the resulting -- 24-- executable to be covered by the GNU General Public License. This -- 25-- exception does not however invalidate any other reasons why the -- 26-- executable file might be covered by the GNU Public License. -- 27----------------------------------------------------------------------- 28 29with Interfaces.C.Strings; use Interfaces.C.Strings; 30with Gtkada.Bindings; use Gtkada.Bindings; 31 32package body Gtk.Paper_Size is 33 34 ----------------- 35 -- Get_Default -- 36 ----------------- 37 38 function Get_Default return String is 39 function Internal return chars_ptr; 40 pragma Import (C, Internal, "gtk_paper_size_get_default"); 41 begin 42 return Value (Internal); 43 end Get_Default; 44 45 ---------------------- 46 -- Get_Display_Name -- 47 ---------------------- 48 49 function Get_Display_Name (Size : Gtk_Paper_Size) return String is 50 function Internal (Size : Gtk_Paper_Size) return chars_ptr; 51 pragma Import (C, Internal, "gtk_paper_size_get_display_name"); 52 begin 53 return Value (Internal (Size)); 54 end Get_Display_Name; 55 56 -------------- 57 -- Get_Name -- 58 -------------- 59 60 function Get_Name (Size : Gtk_Paper_Size) return String is 61 function Internal (Size : Gtk_Paper_Size) return chars_ptr; 62 pragma Import (C, Internal, "gtk_paper_size_get_name"); 63 begin 64 return Value (Internal (Size)); 65 end Get_Name; 66 67 --------------------- 68 -- Get_Paper_Sizes -- 69 --------------------- 70 71 function Get_Paper_Sizes 72 (Include_Custom : Boolean) return Gtk_Paper_Size_Glist.Glist 73 is 74 function Internal (Include_Custom : Gboolean) return System.Address; 75 pragma Import (C, Internal, "gtk_paper_size_get_paper_sizes"); 76 G : Gtk_Paper_Size_Glist.Glist; 77 begin 78 Gtk_Paper_Size_Glist.Set_Object 79 (G, Internal (Boolean'Pos (Include_Custom))); 80 return G; 81 end Get_Paper_Sizes; 82 83 ------------------ 84 -- Get_Ppd_Name -- 85 ------------------ 86 87 function Get_Ppd_Name (Size : Gtk_Paper_Size) return String is 88 function Internal (Size : Gtk_Paper_Size) return chars_ptr; 89 pragma Import (C, Internal, "gtk_paper_size_get_ppd_name"); 90 C : chars_ptr; 91 begin 92 C := Internal (Size); 93 if C = Null_Ptr then 94 return ""; 95 else 96 return Value (C); 97 end if; 98 end Get_Ppd_Name; 99 100 --------------- 101 -- Is_Custom -- 102 --------------- 103 104 function Is_Custom (Size : Gtk_Paper_Size) return Boolean is 105 function Internal (Size : Gtk_Paper_Size) return Gboolean; 106 pragma Import (C, Internal, "gtk_paper_size_is_custom"); 107 begin 108 return Boolean'Val (Internal (Size)); 109 end Is_Custom; 110 111 --------- 112 -- "=" -- 113 --------- 114 115 function "=" (Size1, Size2 : Gtk_Paper_Size) return Boolean is 116 function Internal (Size1, Size2 : Gtk_Paper_Size) return Gboolean; 117 pragma Import (C, Internal, "gtk_paper_size_is_equal"); 118 begin 119 return Boolean'Val (Internal (Size1, Size2)); 120 end "="; 121 122 ------------- 123 -- Gtk_New -- 124 ------------- 125 126 procedure Gtk_New 127 (Widget : out Gtk_Paper_Size; 128 Name : String) 129 is 130 function Internal (Name : chars_ptr) return Gtk_Paper_Size; 131 pragma Import (C, Internal, "gtk_paper_size_new"); 132 N : chars_ptr := String_Or_Null (Name); 133 begin 134 Widget := Internal (N); 135 Free (N); 136 end Gtk_New; 137 138 -------------------- 139 -- Gtk_New_Custom -- 140 -------------------- 141 142 procedure Gtk_New_Custom 143 (Widget : out Gtk_Paper_Size; 144 Name : String; 145 Display_Name : String; 146 Width : Gdouble; 147 Height : Gdouble; 148 Unit : Gtk.Enums.Gtk_Unit) 149 is 150 function Internal 151 (Name : String; 152 Display_Name : chars_ptr; 153 Width : Gdouble; 154 Height : Gdouble; 155 Unit : Gtk.Enums.Gtk_Unit) 156 return Gtk_Paper_Size; 157 pragma Import (C, Internal, "gtk_paper_size_new_custom"); 158 D : chars_ptr := String_Or_Null (Display_Name); 159 begin 160 Widget := Internal 161 (Name & ASCII.NUL, 162 D, 163 Width, 164 Height, 165 Unit); 166 Free (D); 167 end Gtk_New_Custom; 168 169 --------------------------- 170 -- Gtk_New_From_Key_File -- 171 --------------------------- 172 173 procedure Gtk_New_From_Key_File 174 (Widget : out Gtk_Paper_Size; 175 Key_File : Glib.Key_File.G_Key_File; 176 Group_Name : String := "") 177 is 178 function Internal 179 (Key_File : Glib.Key_File.G_Key_File; 180 Group_Name : chars_ptr) 181 return Gtk_Paper_Size; 182 pragma Import (C, Internal, "gtk_paper_size_new_from_key_file"); 183 184 G : chars_ptr := String_Or_Null (Group_Name); 185 begin 186 Widget := Internal (Key_File, G); 187 Free (G); 188 end Gtk_New_From_Key_File; 189 190 ---------------------- 191 -- Gtk_New_From_Ppd -- 192 ---------------------- 193 194 procedure Gtk_New_From_Ppd 195 (Widget : out Gtk_Paper_Size; 196 Ppd_Name : String; 197 Ppd_Display_Name : String := ""; 198 Width : Gdouble; 199 Height : Gdouble) 200 is 201 function Internal 202 (Ppd_Name : String; 203 Ppd_Display_Name : chars_ptr; 204 Width : Gdouble; 205 Height : Gdouble) 206 return Gtk_Paper_Size; 207 pragma Import (C, Internal, "gtk_paper_size_new_from_ppd"); 208 D : chars_ptr := String_Or_Null (Ppd_Display_Name); 209 begin 210 Widget := Internal (Ppd_Name & ASCII.NUL, D, Width, Height); 211 Free (D); 212 end Gtk_New_From_Ppd; 213 214 ----------------- 215 -- To_Key_File -- 216 ----------------- 217 218 procedure To_Key_File 219 (Size : Gtk_Paper_Size; 220 Key_File : Glib.Key_File.G_Key_File; 221 Group_Name : String := "") 222 is 223 procedure Internal 224 (Size : Gtk_Paper_Size; 225 Key_File : Glib.Key_File.G_Key_File; 226 Group_Name : chars_ptr); 227 pragma Import (C, Internal, "gtk_paper_size_to_key_file"); 228 G : chars_ptr := String_Or_Null (Group_Name); 229 begin 230 Internal (Size, Key_File, G); 231 Free (G); 232 end To_Key_File; 233 234end Gtk.Paper_Size; 235