[gnome-terminal/gnome-3-30] window: Fix tabs menu
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal/gnome-3-30] window: Fix tabs menu
- Date: Mon, 8 Apr 2019 12:02:53 +0000 (UTC)
commit 558cf5d2e625c9aedbc9373ea6a082d9c6da12a6
Author: Christian Persch <chpe src gnome org>
Date: Tue Mar 26 11:36:35 2019 +0100
window: Fix tabs menu
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/93
(cherry picked from commit 58b9488a46ab4265a4b3e00e26c577bcdeccb84f)
src/terminal-menu-button.c | 48 ++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/src/terminal-menu-button.c b/src/terminal-menu-button.c
index fdaaffaa..fbe30f27 100644
--- a/src/terminal-menu-button.c
+++ b/src/terminal-menu-button.c
@@ -33,6 +33,9 @@ enum
static guint signals[LAST_SIGNAL];
+static void popup_menu_selection_done_cb (GtkMenu *menu,
+ GtkMenuButton *button);
+
/* The menu button sets itself insensitive when it has no menu.
* Work around this by using an empty menu.
*/
@@ -43,6 +46,24 @@ set_empty_menu (GtkMenuButton *button)
gtk_menu_button_set_menu_model (button, G_MENU_MODEL (menu));
}
+static void
+disconnect_popup_menu (GtkMenuButton *button)
+{
+ GtkMenu *popup_menu = gtk_menu_button_get_popup (button);
+
+ if (popup_menu)
+ g_signal_handlers_disconnect_by_func
+ (popup_menu, G_CALLBACK (popup_menu_selection_done_cb), button);
+}
+
+static void
+popup_menu_selection_done_cb (GtkMenu *menu,
+ GtkMenuButton *button)
+{
+ disconnect_popup_menu (button);
+ set_empty_menu (button);
+}
+
/* Class implementation */
G_DEFINE_TYPE (TerminalMenuButton, terminal_menu_button, GTK_TYPE_MENU_BUTTON);
@@ -69,17 +90,36 @@ terminal_menu_button_toggled (GtkToggleButton *button)
g_signal_emit (button, signals[UPDATE_MENU], 0);
GTK_TOGGLE_BUTTON_CLASS (terminal_menu_button_parent_class)->toggled (button);
+}
- /* On deactivate, clear the menu */
- if (!active)
- set_empty_menu (GTK_MENU_BUTTON (button));
+static void
+terminal_menu_button_update_menu (TerminalMenuButton *button)
+{
+ GtkMenuButton *gtk_button = GTK_MENU_BUTTON (button);
+ GtkMenu *popup_menu = gtk_menu_button_get_popup (gtk_button);
+
+ if (popup_menu)
+ g_signal_connect (popup_menu, "selection-done",
+ G_CALLBACK (popup_menu_selection_done_cb), button);
+}
+
+static void
+terminal_menu_button_dispose (GObject *object)
+{
+ disconnect_popup_menu (GTK_MENU_BUTTON (object));
+
+ G_OBJECT_CLASS (terminal_menu_button_parent_class)->dispose (object);
}
static void
terminal_menu_button_class_init (TerminalMenuButtonClass *klass)
{
- GtkToggleButtonClass *toggle_button_class = GTK_TOGGLE_BUTTON_CLASS (klass);
+ klass->update_menu = terminal_menu_button_update_menu;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = terminal_menu_button_dispose;
+
+ GtkToggleButtonClass *toggle_button_class = GTK_TOGGLE_BUTTON_CLASS (klass);
toggle_button_class->toggled = terminal_menu_button_toggled;
signals[UPDATE_MENU] =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]