mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-06 00:30:08 +00:00
gtkmenutrackeritem: Simplify the submenu opening API
Instead of making clients inspect the submenu action and decide what to do based upon that, always request the submenu open and let the tracker decide what to do.
This commit is contained in:
parent
2024384e0a
commit
7793f21d2a
@ -585,7 +585,6 @@ gtk_menu_tracker_item_get_submenu_shown (GtkMenuTrackerItem *self)
|
||||
return self->submenu_shown;
|
||||
}
|
||||
|
||||
/* only called from the opener, internally */
|
||||
static void
|
||||
gtk_menu_tracker_item_set_submenu_shown (GtkMenuTrackerItem *self,
|
||||
gboolean submenu_shown)
|
||||
@ -762,22 +761,28 @@ gtk_menu_tracker_item_request_submenu_shown (GtkMenuTrackerItem *self,
|
||||
gboolean shown)
|
||||
{
|
||||
const gchar *submenu_action;
|
||||
gboolean okay;
|
||||
gboolean has_submenu_action;
|
||||
|
||||
if (shown == self->submenu_requested)
|
||||
return;
|
||||
|
||||
/* Should not be getting called unless we have submenu-action.
|
||||
*/
|
||||
okay = g_menu_item_get_attribute (self->item, "submenu-action", "&s", &submenu_action);
|
||||
g_assert (okay);
|
||||
has_submenu_action = g_menu_item_get_attribute (self->item, "submenu-action", "&s", &submenu_action);
|
||||
|
||||
self->submenu_requested = shown;
|
||||
|
||||
/* If we have a submenu action, start a submenu opener and wait
|
||||
* for the reply from the client. Otherwise, simply open the
|
||||
* submenu immediately.
|
||||
*/
|
||||
if (has_submenu_action)
|
||||
{
|
||||
if (shown)
|
||||
g_object_set_data_full (G_OBJECT (self), "submenu-opener",
|
||||
gtk_menu_tracker_opener_new (self, submenu_action),
|
||||
gtk_menu_tracker_opener_free);
|
||||
else
|
||||
g_object_set_data (G_OBJECT (self), "submenu-opener", NULL);
|
||||
}
|
||||
else
|
||||
gtk_menu_tracker_item_set_submenu_shown (self, shown);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user