From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Gtkada: attach signals to menus
Date: Sun, 19 Jun 2016 20:33:34 +0200
Date: 2016-06-19T20:33:34+02:00 [thread overview]
Message-ID: <nk6ohs$5ot$1@gioia.aioe.org> (raw)
In-Reply-To: 1df56f78-8ea3-4cdc-aa54-05249464495f@googlegroups.com
On 2016-06-19 17:02, Stephen Leake wrote:
> Basic menus work, but I can't figure out how to compute the submenu on the fly.
>
> Here's my attempt:
[...]
> If I use "On_Activate" for On_Menu_Table, the submenu is not shown. So I tried "On_Select"; still no submenu, and it crashes with
This is because you do not "show" submenu you create.
> (menu_demo.exe:5884): Gtk-WARNING **: GtkWindow 001915B0 is mapped but visible child GtkMenu 08B2C468 is not mapped
This is because you do it each time new. Looks like a GTK bug to me, but
the usage is not intended.
> I know how to compute a dynamic submenu in Emacs and Win32; there must be a way to do this in Gtk.
Here I changed your signal handler:
procedure On_Menu_Table (Self : access
Gtk.Menu_Item.Gtk_Menu_Item_Record'Class)
is
use Gtk.Menu_Item;
use Gtk.Widget;
Table_Item : constant Gtk_Menu_Item := Gtk_Menu_Item (Self);
begin
if Table_Item.Get_Submenu = null then -- Do it only once
declare
Menu : constant Gtk.Menu.Gtk_Menu := Gtk.Menu.Gtk_Menu_New;
Item : Gtk_Menu_Item;
begin
Item := Gtk_Menu_Item_New_With_Mnemonic ("_Add");
Menu.Append (Item);
Item := Gtk_Menu_Item_New_With_Mnemonic ("_Edit");
Menu.Append (Item);
Item := Gtk_Menu_Item_New_With_Mnemonic ("_Delete");
Menu.Append (Item);
Menu.Show_All; -- Make it visible
Table_Item.Set_Submenu (Menu);
end;
end if;
end On_Menu_Table;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2016-06-19 18:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-18 17:05 Gtkada: attach signals to menus Stephen Leake
2016-06-18 18:07 ` Dmitry A. Kazakov
2016-06-18 18:21 ` Stephen Leake
2016-06-19 15:02 ` Stephen Leake
2016-06-19 18:33 ` Dmitry A. Kazakov [this message]
2016-06-20 9:18 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox