Commit 7793f21d authored by Jasper St. Pierre's avatar Jasper St. Pierre

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.
parent 2024384e
......@@ -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 (shown)
g_object_set_data_full (G_OBJECT (self), "submenu-opener",
gtk_menu_tracker_opener_new (self, submenu_action),
gtk_menu_tracker_opener_free);
/* 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
g_object_set_data (G_OBJECT (self), "submenu-opener", NULL);
gtk_menu_tracker_item_set_submenu_shown (self, shown);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment