[gtkada] Context popup menu from a clist widget
Ebert, Rolf
ebert at bms.de
Thu Apr 25 13:35:43 CEST 2002
RE> I can send code, if anybody cares.
EB> Yes, it would be helpful. Please try to extract only the relevant part
(widget
EB> creation, callbacks setting, and handler)
The code was originally generated via GLADE, but is heavily modified in the
mean time.
The toplevel application window is called Appwin_Pkg.Appwin, the pop-up menu
is Popup_Pkg.Popup. The ctree widget is part of the application window, it
is called appwin_pkg.appwin.ctree.
-----------------------------------------------------------------------
-- the "main" procedure
...
Gtk.Main.Init;
-- popup must be initialized first, as the initialization routine
-- of appwin refers to popup.
Gtk_New(Popup_Pkg.Popup);
Gtk_New(Appwin);
...
-----------------------------------------------------------------------
-- the body of appwin_pkg containing the callbacks and the link between
-- popup and appwin.
procedure Initialize (Appwin : access Appwin_Record'Class) is
...
package Menu_Cb is new Gtk.Handlers.Return_Callback
(Widget_Type => Gtk_Menu_Record,
Return_Type => Boolean);
function Popup_Menu_Handler(Menu : access Gtk_Menu_Record'Class;
Event : Gdk.Event.Gdk_Event)
return Boolean
is
use Logger;
begin
Log("popup_menu_handler", "start");
if Gdk.Event.Get_Event_Type(Event) = Button_Press
and then Gdk.Event.Get_Button(Event) = 3
then
Log("popup_menu_handler", "activate");
Popup(Menu,
Button => Gdk.Event.Get_Button(Event),
Activate_Time => Gdk.Event.Get_Time(Event));
end if;
return False;
end Popup_Menu_Handler;
begin
...
Set_Events (Appwin.Ctree, Button_Press_Mask);
Menu_Cb.Object_Connect(Appwin.Ctree, "button_press_event",
Menu_Cb.To_Marshaller(Popup_Menu_Handler'Access),
Slot_Object => Popup_Pkg.Popup);
end Initialize;
-------------------------------------------------------------------------
I hope to have cut off all the decoration and to keep just the essence of
the problem. Please tell me, if you need anything else.
Rolf
More information about the gtkada
mailing list