diff options
author | Paolo Borelli <pborelli@gnome.org> | 2014-08-27 21:36:08 +0200 |
---|---|---|
committer | Paolo Borelli <pborelli@gnome.org> | 2014-08-28 21:16:19 +0200 |
commit | d94379183a2fae089dcdffbead5744374edbacb1 (patch) | |
tree | 12dfd6dd8a69a395707f4145788728e784520071 /gtk/gtkmenubutton.c | |
parent | 0144cb92edcac4aaaf4abee8c9ed30da0b66536f (diff) | |
download | gtk+-d94379183a2fae089dcdffbead5744374edbacb1.tar.gz |
menubutton: dismiss menu/popover when toggling programmatically
https://bugzilla.gnome.org/show_bug.cgi?id=735545
Diffstat (limited to 'gtk/gtkmenubutton.c')
-rw-r--r-- | gtk/gtkmenubutton.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c index 605937aad3..656392f97d 100644 --- a/gtk/gtkmenubutton.c +++ b/gtk/gtkmenubutton.c @@ -408,23 +408,28 @@ gtk_menu_button_toggled (GtkToggleButton *button) { GtkMenuButton *menu_button = GTK_MENU_BUTTON (button); GtkMenuButtonPrivate *priv = menu_button->priv; + gboolean active; - if (!gtk_toggle_button_get_active (button)) - return; + active = gtk_toggle_button_get_active (button); if (priv->menu) - { - if (!gtk_widget_get_visible (priv->menu)) + { + if (active) { - /* we get here only when the menu is activated by a key - * press, so that we can select the first menu item - */ - popup_menu (menu_button, NULL); - gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE); + if (!gtk_widget_get_visible (priv->menu)) + { + /* we get here only when the menu is activated by a key + * press, so that we can select the first menu item + */ + popup_menu (menu_button, NULL); + gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE); + } } + else + gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu)); } else if (priv->popover) - gtk_widget_show (priv->popover); + gtk_widget_set_visible (priv->popover, active); } static gboolean |