File: gtk-ui_manager.adb

package info (click to toggle)
libgtkada 2.24.4dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 12,208 kB
  • ctags: 1,676
  • sloc: ada: 119,686; ansic: 4,719; sh: 3,003; makefile: 690; xml: 338; perl: 70
file content (338 lines) | stat: -rw-r--r-- 10,579 bytes parent folder | download
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
-----------------------------------------------------------------------
--              GtkAda - Ada95 binding for Gtk+/Gnome                --
--                                                                   --
--                 Copyright (C) 2006-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.Bindings;      use Gtkada.Bindings;
with Glib.Error;           use Glib.Error;
with Gtk.Accel_Group;      use Gtk.Accel_Group;
with Gtk.Action;           use Gtk.Action;
with Gtk.Action_Group;     use Gtk.Action_Group;
with Gtk.Widget;           use Gtk.Widget;
with Interfaces.C.Strings; use Interfaces.C.Strings;

with Glib.Type_Conversion_Hooks;

package body Gtk.UI_Manager is

   package Type_Conversion is new Glib.Type_Conversion_Hooks.Hook_Registrator
     (Get_Type'Access, Gtk_UI_Manager_Record);
   pragma Warnings (Off, Type_Conversion);

   ------------
   -- Add_UI --
   ------------

   procedure Add_UI
     (Self     : access Gtk_UI_Manager_Record;
      Merge_Id : Guint;
      Path     : String;
      Name     : String;
      Action   : String := "";
      Typ      : Manager_Item_Type := Manager_Auto;
      Top      : Boolean := False)
   is
      procedure Internal
        (Self     : System.Address;
         Merge_Id : Guint;
         Path     : String;
         Name     : String;
         Action   : chars_ptr;
         Typ      : Manager_Item_Type;
         Top      : Gboolean);
      pragma Import (C, Internal, "gtk_ui_manager_add_ui");
      A : chars_ptr := String_Or_Null (Action);
   begin
      Internal (Get_Object (Self), Merge_Id, Path & ASCII.NUL,
                Name & ASCII.NUL, A, Typ, Boolean'Pos (Top));
      Free (A);
   end Add_UI;

   ----------------------
   -- Add_UI_From_File --
   ----------------------

   function Add_UI_From_File
     (Self     : access Gtk_UI_Manager_Record;
      Filename : String;
      Error    : GError_Access := null)
      return Guint
   is
      function Internal
        (Self     : System.Address;
         Filename : String;
         Error    : GError_Access) return Guint;
      pragma Import (C, Internal, "gtk_ui_manager_add_ui_from_file");
   begin
      return Internal (Get_Object (Self), Filename & ASCII.NUL, Error);
   end Add_UI_From_File;

   ------------------------
   -- Add_UI_From_String --
   ------------------------

   function Add_UI_From_String
     (Self   : access Gtk_UI_Manager_Record;
      Buffer : String;
      Error  : GError_Access := null)
      return Guint
   is
      function Internal
        (Self   : System.Address;
         Buffer : String;
         Length : Gint;
         Error  : GError_Access)
         return Guint;
      pragma Import (C, Internal, "gtk_ui_manager_add_ui_from_string");
   begin
      return Internal (Get_Object (Self), Buffer, Buffer'Length, Error);
   end Add_UI_From_String;

   -------------------
   -- Ensure_Update --
   -------------------

   procedure Ensure_Update (Self : access Gtk_UI_Manager_Record) is
      procedure Internal (Self : System.Address);
      pragma Import (C, Internal, "gtk_ui_manager_ensure_update");
   begin
      Internal (Get_Object (Self));
   end Ensure_Update;

   ---------------------
   -- Get_Accel_Group --
   ---------------------

   function Get_Accel_Group
     (Self : access Gtk_UI_Manager_Record)
      return Gtk_Accel_Group
   is
      function Internal (Self : System.Address) return System.Address;
      pragma Import (C, Internal, "gtk_ui_manager_get_accel_group");
      Stub : Gtk_Accel_Group_Record;
   begin
      return Gtk_Accel_Group
        (Get_User_Data (Internal (Get_Object (Self)), Stub));
   end Get_Accel_Group;

   ----------------
   -- Get_Action --
   ----------------

   function Get_Action
     (Self : access Gtk_UI_Manager_Record;
      Path : String)
      return Gtk_Action
   is
      function Internal
        (Self : System.Address; Path : String) return System.Address;
      pragma Import (C, Internal, "gtk_ui_manager_get_action");
      Stub : Gtk_Action_Record;
   begin
      return Gtk_Action
        (Get_User_Data (Internal (Get_Object (Self), Path & ASCII.NUL), Stub));
   end Get_Action;

   -----------------------
   -- Get_Action_Groups --
   -----------------------

   function Get_Action_Groups
     (Self : access Gtk_UI_Manager_Record)
      return Glib.Object.Object_Simple_List.Glist
   is
      function Internal (Self : System.Address) return System.Address;
      pragma Import (C, Internal, "gtk_ui_manager_get_action_groups");
      L : Object_Simple_List.Glist;
   begin
      Object_Simple_List.Set_Object (L, Internal (Get_Object (Self)));
      return L;
   end Get_Action_Groups;

   ----------------------
   -- Get_Add_Tearoffs --
   ----------------------

   function Get_Add_Tearoffs
     (Self : access Gtk_UI_Manager_Record)
      return Boolean
   is
      function Internal
        (Self : System.Address)
         return Gboolean;
      pragma Import (C, Internal, "gtk_ui_manager_get_add_tearoffs");
   begin
      return Boolean'Val (Internal (Get_Object (Self)));
   end Get_Add_Tearoffs;

   -------------------
   -- Get_Toplevels --
   -------------------

   function Get_Toplevels
     (Self  : access Gtk_UI_Manager_Record;
      Types : Manager_Item_Type)
      return Widget_SList.GSlist
   is
      function Internal
        (Self  : System.Address;
         Types : Manager_Item_Type) return System.Address;
      pragma Import (C, Internal, "gtk_ui_manager_get_toplevels");
      L : Widget_SList.GSlist;
   begin
      Widget_SList.Set_Object (L, Internal (Get_Object (Self), Types));
      return L;
   end Get_Toplevels;

   ------------
   -- Get_UI --
   ------------

   function Get_UI
     (Self : access Gtk_UI_Manager_Record) return String
   is
      function Internal (Self : System.Address) return chars_ptr;
      pragma Import (C, Internal, "gtk_ui_manager_get_ui");
      S : chars_ptr := Internal (Get_Object (Self));
      Result : constant String := Value (S);
   begin
      Free (S);
      return Result;
   end Get_UI;

   ----------------
   -- Get_Widget --
   ----------------

   function Get_Widget
     (Self : access Gtk_UI_Manager_Record;
      Path : String) return Gtk_Widget
   is
      function Internal
        (Self : System.Address;
         Path : String) return System.Address;
      pragma Import (C, Internal, "gtk_ui_manager_get_widget");
      Stub : Gtk_Widget_Record;
   begin
      return Gtk_Widget
        (Get_User_Data (Internal (Get_Object (Self), Path & ASCII.NUL), Stub));
   end Get_Widget;

   -------------------------
   -- Insert_Action_Group --
   -------------------------

   procedure Insert_Action_Group
     (Self         : access Gtk_UI_Manager_Record;
      Action_Group : access Gtk_Action_Group_Record'Class;
      Pos          : Gint)
   is
      procedure Internal
        (Self         : System.Address;
         Action_Group : System.Address;
         Pos          : Gint);
      pragma Import (C, Internal, "gtk_ui_manager_insert_action_group");
   begin
      Internal (Get_Object (Self), Get_Object (Action_Group), Pos);
   end Insert_Action_Group;

   -------------
   -- Gtk_New --
   -------------

   procedure Gtk_New (UI : out Gtk_UI_Manager) is
   begin
      UI := new Gtk_UI_Manager_Record;
      Gtk.UI_Manager.Initialize (UI);
   end Gtk_New;

   ----------------
   -- Initialize --
   ----------------

   procedure Initialize
     (UI : access Gtk_UI_Manager_Record'Class)
   is
      function Internal return System.Address;
      pragma Import (C, Internal, "gtk_ui_manager_new");
   begin
      Set_Object (UI, Internal);
   end Initialize;

   ------------------
   -- New_Merge_Id --
   ------------------

   function New_Merge_Id
     (Self : access Gtk_UI_Manager_Record) return Guint
   is
      function Internal (Self : System.Address) return Guint;
      pragma Import (C, Internal, "gtk_ui_manager_new_merge_id");
   begin
      return Internal (Get_Object (Self));
   end New_Merge_Id;

   -------------------------
   -- Remove_Action_Group --
   -------------------------

   procedure Remove_Action_Group
     (Self         : access Gtk_UI_Manager_Record;
      Action_Group : access Gtk_Action_Group_Record'Class)
   is
      procedure Internal
        (Self         : System.Address;
         Action_Group : System.Address);
      pragma Import (C, Internal, "gtk_ui_manager_remove_action_group");
   begin
      Internal (Get_Object (Self), Get_Object (Action_Group));
   end Remove_Action_Group;

   ---------------
   -- Remove_UI --
   ---------------

   procedure Remove_UI
     (Self     : access Gtk_UI_Manager_Record;
      Merge_Id : Guint)
   is
      procedure Internal (Self : System.Address; Merge_Id : Guint);
      pragma Import (C, Internal, "gtk_ui_manager_remove_ui");
   begin
      Internal (Get_Object (Self), Merge_Id);
   end Remove_UI;

   ----------------------
   -- Set_Add_Tearoffs --
   ----------------------

   procedure Set_Add_Tearoffs
     (Self         : access Gtk_UI_Manager_Record;
      Add_Tearoffs : Boolean)
   is
      procedure Internal
        (Self         : System.Address;
         Add_Tearoffs : Gboolean);
      pragma Import (C, Internal, "gtk_ui_manager_set_add_tearoffs");
   begin
      Internal (Get_Object (Self), Boolean'Pos (Add_Tearoffs));
   end Set_Add_Tearoffs;

end Gtk.UI_Manager;