fepitre / rpms / gtk3

Forked from rpms/gtk3 4 years ago
Clone
Blob Blame History Raw
From 7d5fe40f2e11d21153fe86ce69deec7fa7c348ae Mon Sep 17 00:00:00 2001
From: Matthias Clasen <mclasen@redhat.com>
Date: Thu, 9 Oct 2014 15:30:52 -0400
Subject: [PATCH] GtkMenuButton: Submit to action

As an actionable (inherited from GtkButton), a GtkMenuButton
should not set its own sensitivity when it has an action-name
set, but just follow the enabled state of the associated
action.

https://bugzilla.gnome.org/show_bug.cgi?id=738083
---
 gtk/gtkmenubutton.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 4ff2c18..dd4cdf2 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -108,6 +108,7 @@
 
 #include "gtkmenubutton.h"
 #include "gtkmenubuttonprivate.h"
+#include "gtkbuttonprivate.h"
 #include "gtktypebuiltins.h"
 #include "gtkwindow.h"
 #include "gtkmain.h"
@@ -695,6 +696,18 @@ menu_detacher (GtkWidget *widget,
   priv->menu = NULL;
 }
 
+static void
+update_sensitivity (GtkMenuButton *menu_button)
+{
+  GtkMenuButtonPrivate *priv = menu_button->priv;
+
+  if (GTK_BUTTON (menu_button)->priv->action_helper)
+    return;
+
+  gtk_widget_set_sensitive (GTK_WIDGET (menu_button),
+                            priv->menu != NULL || priv->popover != NULL);
+}
+
 /* This function is used in GtkMenuToolButton, the call back will
  * be called when GtkMenuToolButton would have emitted the “show-menu”
  * signal.
@@ -742,7 +755,7 @@ _gtk_menu_button_set_popup_with_func (GtkMenuButton                 *menu_button
       gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (menu_button)), "menu-button");
     }
 
-  gtk_widget_set_sensitive (GTK_WIDGET (menu_button), priv->menu != NULL);
+  update_sensitivity (menu_button);
 
   g_object_notify (G_OBJECT (menu_button), "popup");
   g_object_notify (G_OBJECT (menu_button), "menu-model");
@@ -777,8 +790,7 @@ gtk_menu_button_set_popup (GtkMenuButton *menu_button,
   if (menu && priv->popover)
     gtk_menu_button_set_popover (menu_button, NULL);
 
-  gtk_widget_set_sensitive (GTK_WIDGET (menu_button),
-                            priv->menu != NULL || priv->popover != NULL);
+  update_sensitivity (menu_button);
 
   g_object_thaw_notify (G_OBJECT (menu_button));
 }
@@ -1173,8 +1185,7 @@ gtk_menu_button_set_popover (GtkMenuButton *menu_button,
   if (popover && priv->menu)
     gtk_menu_button_set_popup (menu_button, NULL);
 
-  gtk_widget_set_sensitive (GTK_WIDGET (menu_button),
-                            priv->menu != NULL || priv->popover != NULL);
+  update_sensitivity (menu_button);
 
   g_object_notify (G_OBJECT (menu_button), "popover");
   g_object_notify (G_OBJECT (menu_button), "menu-model");
-- 
2.1.0