Gtk3: different handling of menu sensitivity in same model in menu and popover
Steps to reproduce
- Implement a GMenuModel, which contains a submenu with "action" property.
- Associate this model with 2 menubuttons, with one has set use-popover to true
- Try to change
enabled
property of action associated with submenu.
Current behavior
When action is disabled, submenu in popover button will be disabled and cannot be opened, but submenu in normal menubutton is opened.
Expected outcome
Uniform handling: either allow bind action and monitor its sensitivity or not. I think than first will be better.
Version information
Gtk 3.24.23 ArchLinux.
Additional information
I found different handling in source:
else if (gtk_menu_tracker_item_get_has_link (item, G_MENU_LINK_SUBMENU))
{
GtkMenuShell *submenu;
widget = gtk_model_menu_item_new ();
g_object_bind_property (item, "label", widget, "text", G_BINDING_SYNC_CREATE);
submenu = GTK_MENU_SHELL (gtk_menu_new ());
MenuShell only binds label there.
2. https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/gtkmenusectionbox.c#L289
else if (gtk_menu_tracker_item_get_has_link (item, G_MENU_LINK_SUBMENU))
{
GtkWidget *stack = NULL;
GtkWidget *parent = NULL;
gchar *name;
widget = g_object_new (GTK_TYPE_MODEL_BUTTON,
"menu-name", gtk_menu_tracker_item_get_label (item),
NULL);
g_object_bind_property (item, "label", widget, "text", G_BINDING_SYNC_CREATE);
g_object_bind_property (item, "icon", widget, "icon", G_BINDING_SYNC_CREATE);
g_object_bind_property (item, "sensitive", widget, "sensitive", G_BINDING_SYNC_CREATE);
MenuSectionBox also binds sensitivity here.
There is also a question to GtkMenuTracker's sensitivity handling with submenus. If submenu-action
is set, its enabled
property is not respected, so, even when action is disabled, GtkMenuTracker try to change state of this action.
I think than:
- If
submenu-action
is present, submenu sensitivity should be bind to this action'senabled
property. - Submenus' sensitivity behaviour should be uniform in both menu and popover.
Edited by Konstantin