forked from AuroraMiddleware/gtk
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;
|
return self->submenu_shown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only called from the opener, internally */
|
|
||||||
static void
|
static void
|
||||||
gtk_menu_tracker_item_set_submenu_shown (GtkMenuTrackerItem *self,
|
gtk_menu_tracker_item_set_submenu_shown (GtkMenuTrackerItem *self,
|
||||||
gboolean submenu_shown)
|
gboolean submenu_shown)
|
||||||
@ -762,22 +761,28 @@ gtk_menu_tracker_item_request_submenu_shown (GtkMenuTrackerItem *self,
|
|||||||
gboolean shown)
|
gboolean shown)
|
||||||
{
|
{
|
||||||
const gchar *submenu_action;
|
const gchar *submenu_action;
|
||||||
gboolean okay;
|
gboolean has_submenu_action;
|
||||||
|
|
||||||
if (shown == self->submenu_requested)
|
if (shown == self->submenu_requested)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Should not be getting called unless we have submenu-action.
|
has_submenu_action = g_menu_item_get_attribute (self->item, "submenu-action", "&s", &submenu_action);
|
||||||
*/
|
|
||||||
okay = g_menu_item_get_attribute (self->item, "submenu-action", "&s", &submenu_action);
|
|
||||||
g_assert (okay);
|
|
||||||
|
|
||||||
self->submenu_requested = shown;
|
self->submenu_requested = shown;
|
||||||
|
|
||||||
if (shown)
|
/* If we have a submenu action, start a submenu opener and wait
|
||||||
g_object_set_data_full (G_OBJECT (self), "submenu-opener",
|
* for the reply from the client. Otherwise, simply open the
|
||||||
gtk_menu_tracker_opener_new (self, submenu_action),
|
* submenu immediately.
|
||||||
gtk_menu_tracker_opener_free);
|
*/
|
||||||
|
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
|
else
|
||||||
g_object_set_data (G_OBJECT (self), "submenu-opener", NULL);
|
gtk_menu_tracker_item_set_submenu_shown (self, shown);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user