GtkMenuButton: Make programmatic toggling work again

This was broken in 0796d7b6ff.

https://bugzilla.gnome.org/show_bug.cgi?id=751018
This commit is contained in:
Matthias Clasen 2015-06-15 19:42:47 -04:00
parent f99375f91e
commit 002699402d

View File

@ -426,26 +426,36 @@ gtk_menu_button_clicked (GtkButton *button)
{
GtkMenuButton *menu_button = GTK_MENU_BUTTON (button);
GtkMenuButtonPrivate *priv = menu_button->priv;
gboolean active = TRUE;
gboolean active;
if (priv->menu && !gtk_widget_get_visible (priv->menu))
if (priv->menu)
{
GdkEvent *event;
active = !gtk_widget_get_visible (priv->menu);
if (active)
{
GdkEvent *event;
event = gtk_get_current_event ();
event = gtk_get_current_event ();
popup_menu (menu_button, event);
popup_menu (menu_button, event);
if (!event ||
event->type == GDK_KEY_PRESS ||
event->type == GDK_KEY_RELEASE)
gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
if (!event ||
event->type == GDK_KEY_PRESS ||
event->type == GDK_KEY_RELEASE)
gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
if (event)
gdk_event_free (event);
if (event)
gdk_event_free (event);
}
}
else if (priv->popover)
{
active = !gtk_widget_get_visible (priv->popover);
if (active)
gtk_widget_show (priv->popover);
else
gtk_widget_hide (priv->popover);
}
else if (priv->popover && !gtk_widget_get_visible (priv->popover))
gtk_widget_show (priv->popover);
else
active = FALSE;