2
2
-- GtkAda - Ada95 binding for Gtk+/Gnome --
4
4
-- Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet --
5
-- Copyright (C) 2000-2008, AdaCore --
6
7
-- This library is free software; you can redistribute it and/or --
7
8
-- modify it under the terms of the GNU General Public --
29
29
with Gtk.Menu_Shell; use Gtk.Menu_Shell;
30
30
with Gtk.Widget; use Gtk.Widget;
32
with Ada.Unchecked_Deallocation;
32
34
package body Gtk.Menu is
34
function Type_Conversion (Type_Name : String) return GObject;
35
-- This function is used to implement a minimal automated type conversion
36
package Type_Conversion is new Glib.Type_Conversion_Hooks.Hook_Registrator
37
(Get_Type'Access, Gtk_Menu_Record);
38
pragma Warnings (Off, Type_Conversion);
39
-- This package is used to implement a minimal automated type conversion
36
40
-- without having to drag the whole Gtk.Type_Conversion package for the
37
41
-- most common widgets.
43
procedure Internal_Menu_Position_Func
44
(Menu : access Gtk_Menu_Record'Class;
47
Push_In : out Gboolean;
48
Data : Gtk_Menu_Position_Func);
49
pragma Convention (C, Internal_Menu_Position_Func);
50
-- Wrapper function passed to C.
39
52
----------------------
40
53
-- Attach_To_Widget --
41
54
----------------------
276
289
Internal (Get_Object (Menu), Boolean'Pos (Torn_Off));
277
290
end Set_Tearoff_State;
292
---------------------------------
293
-- Internal_Menu_Position_Func --
294
---------------------------------
296
procedure Internal_Menu_Position_Func
297
(Menu : access Gtk_Menu_Record'Class;
300
Push_In : out Gboolean;
301
Data : Gtk_Menu_Position_Func) is
303
Data.all (Menu, X, Y);
304
Push_In := Boolean'Pos (False); -- ???
305
end Internal_Menu_Position_Func;
310
338
Parent_Item := Get_Object (Parent_Menu_Item);
313
Internal (Get_Object (Menu), Parent_Shell, Parent_Item,
314
Func, System.Null_Address, Button, Activate_Time);
343
(Get_Object (Menu), Parent_Shell, Parent_Item,
345
System.Null_Address, Button, Activate_Time);
348
(Get_Object (Menu), Parent_Shell, Parent_Item,
349
Internal_Menu_Position_Func'Address,
350
Func.all'Address, Button, Activate_Time);
317
354
---------------------------------------
321
358
package body User_Menu_Popup is
360
type Data_Access is access Data_Type;
362
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
363
(Data_Type, Data_Access);
365
type Data_And_Cb is record
367
Cb : Gtk_Menu_Position_Func;
370
type Data_And_Cb_Access is access Data_And_Cb;
372
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
373
(Data_And_Cb, Data_And_Cb_Access);
375
procedure Internal_Menu_Position_Func_With_Data
376
(Menu : access Gtk_Menu_Record;
379
Push_In : out Gboolean;
380
Data : Data_And_Cb_Access);
381
pragma Convention (C, Internal_Menu_Position_Func_With_Data);
382
-- Wrapper function passed to C.
384
-------------------------------------------
385
-- Internal_Menu_Position_Func_With_Data --
386
-------------------------------------------
388
procedure Internal_Menu_Position_Func_With_Data
389
(Menu : access Gtk_Menu_Record;
392
Push_In : out Gboolean;
393
Data : Data_And_Cb_Access)
395
The_Data : Data_And_Cb_Access := Data;
397
Data.Cb (Menu, X, Y, Data.Data);
398
Push_In := Boolean'Pos (False); -- ???
399
Unchecked_Free (Data.Data);
400
Unchecked_Free (The_Data);
401
end Internal_Menu_Position_Func_With_Data;
328
(Menu : access Gtk_Menu_Record;
408
(Menu : access Gtk_Menu_Record'Class;
329
409
Data : access Data_Type;
330
410
Parent_Menu_Shell : Gtk.Menu_Shell.Gtk_Menu_Shell := null;
331
411
Parent_Menu_Item : Gtk.Menu_Item.Gtk_Menu_Item := null;
346
426
Parent_Shell : System.Address := System.Null_Address;
347
427
Parent_Item : System.Address := System.Null_Address;
429
The_Data : Data_And_Cb_Access;
350
431
if Parent_Menu_Shell /= null then
351
432
Parent_Shell := Get_Object (Parent_Menu_Shell);
421
514
Internal (Get_Object (Menu), Monitor_Num);
424
---------------------
425
-- Type_Conversion --
426
---------------------
428
function Type_Conversion (Type_Name : String) return GObject is
430
if Type_Name = "GtkMenu" then
431
return new Gtk_Menu_Record;
438
Glib.Type_Conversion_Hooks.Add_Hook (Type_Conversion'Access);