File: gtk-item_factory.ads

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 (308 lines) | stat: -rw-r--r-- 10,874 bytes parent folder | download | duplicates (2)
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
-----------------------------------------------------------------------
--               GtkAda - Ada95 binding for Gtk+/Gnome               --
--                                                                   --
--                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.                                       --
--                                                                   --
-----------------------------------------------------------------------

--  <description>
--  In recent versions of gtk+, this package has been deprecated in favor of
--  Gtk.UIManager. However, the subprograms have not been marked as such in the
--  C files themselves, so are still available in GtkAda as well.
--  </description>
--  <c_version>2.8.17</c_version>
--  <testgtk>create_item_factory.adb</testgtk>

with Gdk.Types;
with Gtk.Accel_Group;
with Gtk.Widget;
with Gtk.Object;
with Gtkada.Types;

package Gtk.Item_Factory is
   pragma Obsolescent;

   type Gtk_Item_Factory_Record is new Object.Gtk_Object_Record with private;
   type Gtk_Item_Factory is access all Gtk_Item_Factory_Record'Class;

   --  <doc_ignore>

   type Item_Type_Enum is
     (Title,
      --  Create a title item

      Item,
      --  Create a simple item

      Image_Item,
      --  Create an item holding an image

      Stock_Item,
      --  Create an item holding a stock image

      Check_Item,
      --  Create a check item

      Toggle_Item,
      --  Create a toggle item

      Radio_Item,
      --  Create a radio item

      Separator,
      --  Create a separator

      Tearoff,
      --  Create a tearoff item

      Branch,
      --  Create an item to hold sub items

      Last_Branch
      --  Create a right justified item to hold sub items
     );
   --  Identify the predefined item types used to create a
   --  Gtk_Item_Factory_Entry.

   type Gtk_Item_Factory_Entry is private;
   type Gtk_Item_Factory_Entry_Array is array (Gint range <>) of
     Gtk_Item_Factory_Entry;

   procedure Gtk_New
     (Ifactory       : out Gtk_Item_Factory;
      Container_Type : Gtk_Type;
      Path           : UTF8_String;
      Accel_Group    : Gtk.Accel_Group.Gtk_Accel_Group);
   procedure Initialize
     (Ifactory       : access Gtk_Item_Factory_Record'Class;
      Container_Type : Gtk_Type;
      Path           : UTF8_String := "";
      Accel_Group    : Gtk.Accel_Group.Gtk_Accel_Group);
   --  Creates or initializes a new item factory.
   --  Possible values of Container_Type are:
   --    - Gtk.Option_Menu.Get_Type
   --    - Gtk.Menu_Bar.Get_Type
   --    - Gtk.Menu.Get_Type

   function Get_Type return Gtk_Type;
   --  Return the internal value associated with a Gtk_Item_Factory

   procedure Add_Foreign
     (Accel_Widget : access Gtk.Widget.Gtk_Widget_Record'Class;
      Full_Path    : UTF8_String;
      Accel_Group  : Gtk.Accel_Group.Gtk_Accel_Group;
      Keyval       : Guint;
      Modifiers    : Gdk.Types.Gdk_Modifier_Type);

   function From_Widget
     (Widget : access Gtk.Widget.Gtk_Widget_Record'Class)
      return Gtk_Item_Factory;

   function Path_From_Widget
     (Widget : access Gtk.Widget.Gtk_Widget_Record'Class) return UTF8_String;

   function Get_Item
     (Ifactory : access Gtk_Item_Factory_Record;
      Path     : UTF8_String) return Gtk.Widget.Gtk_Widget;

   function Get_Widget
     (Ifactory : access Gtk_Item_Factory_Record;
      Path     : UTF8_String) return Gtk.Widget.Gtk_Widget;

   function Get_Widget_By_Action
     (Ifactory : access Gtk_Item_Factory_Record;
      Action   : Guint) return Gtk.Widget.Gtk_Widget;

   function Get_Item_By_Action
     (Ifactory : access Gtk_Item_Factory_Record;
      Action   : Guint) return Gtk.Widget.Gtk_Widget;

   procedure Delete_Item
     (Ifactory : access Gtk_Item_Factory_Record;
      Path     : UTF8_String);

   procedure Delete_Entry
     (Ifactory : access Gtk_Item_Factory_Record;
      Ientry   : Gtk_Item_Factory_Entry);

   procedure Delete_Entries
     (Ifactory  : access Gtk_Item_Factory_Record;
      Entries   : Gtk_Item_Factory_Entry_Array);

   procedure Popup
     (Ifactory     : access Gtk_Item_Factory_Record;
      X            : Guint;
      Y            : Guint;
      Mouse_Button : Guint;
      Time         : Guint32);

   generic
      type Data_Type (<>) is limited private;
   package Data_Item is

      type Data_Type_Access is access all Data_Type;

      type Gtk_Print_Func is access procedure
        (Func_Data : Data_Type_Access;
         Str       : String);  --  gchar* ???

      type Gtk_Translate_Func is access function
        (Path      : UTF8_String;  --  const gchar* ???
         Func_Data : Data_Type_Access) return Gtkada.Types.Chars_Ptr;

      type Limited_Widget is limited private;
      Null_Widget : constant Limited_Widget;

      function To_Widget
        (Widget : Limited_Widget) return Gtk.Widget.Gtk_Widget;

      type Gtk_Item_Factory_Callback is access procedure
        (Callback_Data   : Data_Type_Access;
         Callback_Action : Guint;
         Widget          : Limited_Widget);

      function Gtk_New
        (Path            : UTF8_String;
         Accelerator     : String := "";
         Callback        : Gtk_Item_Factory_Callback := null;
         Item_Type       : Item_Type_Enum;
         Callback_Action : Guint := 0) return Gtk_Item_Factory_Entry;
      --  Create a Gtk_Item_Factory_Entry.
      --  It is up to you to call Free at an appropriate point to avoid memory
      --  leaks.

      function Gtk_New
        (Path            : UTF8_String;
         Accelerator     : String := "";
         Callback        : Gtk_Item_Factory_Callback := null;
         Item_Type       : String := "";
         Callback_Action : Guint := 0) return Gtk_Item_Factory_Entry;
      --  Create a Gtk_Item_Factory_Entry.
      --  It is up to you to call Free at an appropriate point to avoid memory
      --  leaks.

      function Gtk_New
        (Path            : UTF8_String;
         Accelerator     : String := "";
         Stock_Id        : String;
         Callback        : Gtk_Item_Factory_Callback := null;
         Callback_Action : Guint := 0) return Gtk_Item_Factory_Entry;
      --  Create a Gtk_Item_Factory_Entry from a stock item.
      --  It is up to you to call Free at an appropriate point to avoid memory
      --  leaks.

      function Gtk_New
        (Path            : UTF8_String;
         Accelerator     : String := "";
         Callback        : Gtk_Item_Factory_Callback := null;
         Pixbuf          : access Guchar_Array;
         Callback_Action : Guint := 0) return Gtk_Item_Factory_Entry;
      --  Create a Gtk_Item_Factory_Entry from an inline pixbuf image.
      --  It is up to you to call Free at an appropriate point to avoid memory
      --  leaks.

      procedure Free (Ientry : in out Gtk_Item_Factory_Entry);
      --  Free all the dynamic data associated with an item factory entry.

      procedure Free (Ientries : in out Gtk_Item_Factory_Entry_Array);
      --  Free all the dynamic data associated with each item factory entry.

      procedure Create_Item
        (Ifactory      : access Gtk_Item_Factory_Record'Class;
         Ientry        : Gtk_Item_Factory_Entry;
         Callback_Data : Data_Type_Access;
         Callback_Type : Guint);
      --  Callback_Type = 0 -> Gtk_Item_Factory_Callback
      --  Callback_Type = 1 -> Gtk_Item_Factory_Callback1

      procedure Create_Items
        (Ifactory      : access Gtk_Item_Factory_Record'Class;
         Entries       : Gtk_Item_Factory_Entry_Array;
         Callback_Data : Data_Type_Access);

      function Popup_Data
        (Ifactory : access Gtk_Item_Factory_Record'Class)
         return Data_Type_Access;

      function Popup_Data_From_Widget
        (Widget : access Gtk.Widget.Gtk_Widget_Record'Class)
         return Data_Type_Access;

      procedure Popup_With_Data
        (Ifactory     : access Gtk_Item_Factory_Record'Class;
         Popup_Data   : Data_Type_Access;
         Destroy      : System.Address; --  Gtk_Destroy_Notify ???
         X            : Guint;
         Y            : Guint;
         Mouse_Button : Guint;
         Time         : Guint32);

      procedure Set_Translate_Func
        (Ifactory : access Gtk_Item_Factory_Record'Class;
         Func     : Gtk_Translate_Func;
         Data     : Data_Type_Access;
         Notify   : System.Address);  --  Gtk_Destroy_Notify ???

   private
      type Limited_Widget is new System.Address;
      Null_Widget : constant Limited_Widget :=
        Limited_Widget (System.Null_Address);
   end Data_Item;

   --  </doc_ignore>

   ----------------
   -- Properties --
   ----------------

   --  <properties>
   --  The following properties are defined for this widget. See
   --  Glib.Properties for more information on properties.
   --
   --  </properties>

private
   type Gtk_Item_Factory_Record is new Gtk.Object.Gtk_Object_Record
     with null record;

   type Gtk_Item_Factory_Entry is record
      Path            : Gtkada.Types.Chars_Ptr;
      Accelerator     : Gtkada.Types.Chars_Ptr;
      Callback        : System.Address;
      Callback_Action : Guint;
      Item_Type       : Gtkada.Types.Chars_Ptr;

      --  Extra data for some item types:
      --  Image_Item -> pointer to inline pixbuf
      --  Stock_Item -> name of stock item

      Extra_Data      : Gtkada.Types.Chars_Ptr;
   end record;
   pragma Convention (C, Gtk_Item_Factory_Entry);

   pragma Import (C, Get_Type, "gtk_item_factory_get_type");

end Gtk.Item_Factory;

--  The following subprograms never had a binding, are now obsolescent:
--  No binding: gtk_item_factories_path_delete
--  No binding: gtk_item_factory_construct
--  No binding: gtk_item_factory_create_items_ac
--  No binding: gtk_item_factory_create_menu_entries
--  No binding: gtk_item_factory_from_path