[gnome-shell] St: add :disabled pseudo class when a button is not reactive



commit a29507e45221633f6515f92b0174531ee290ed11
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Wed Jul 18 13:59:26 2012 +0200

    St: add :disabled pseudo class when a button is not reactive
    
    The :reactive property is used on StButton to like the :sensitive
    property on GtkWidgets, that is, to indicate that the user is not
    (yet) expected to click the button, and therefore should affect
    styling too.
    This allows to remove some code at the JS layer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=619955

 js/ui/networkAgent.js |    4 ----
 src/st/st-button.c    |   12 ++++++++++++
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/networkAgent.js b/js/ui/networkAgent.js
index c9473a7..1c29b98 100644
--- a/js/ui/networkAgent.js
+++ b/js/ui/networkAgent.js
@@ -166,10 +166,6 @@ const NetworkSecretDialog = new Lang.Class({
 
         this._okButton.button.reactive = valid;
         this._okButton.button.can_focus = valid;
-        if (valid)
-            this._okButton.button.remove_style_pseudo_class('disabled');
-        else
-            this._okButton.button.add_style_pseudo_class('disabled');
     },
 
     _onOk: function() {
diff --git a/src/st/st-button.c b/src/st/st-button.c
index a4edbe7..e3c46f9 100644
--- a/src/st/st-button.c
+++ b/src/st/st-button.c
@@ -447,6 +447,15 @@ st_button_class_init (StButtonClass *klass)
 }
 
 static void
+notify_reactive_cb (StWidget *button)
+{
+  if (clutter_actor_get_reactive (CLUTTER_ACTOR (button)))
+    st_widget_remove_style_pseudo_class (button, "disabled");
+  else
+    st_widget_add_style_pseudo_class (button, "disabled");
+}
+
+static void
 st_button_init (StButton *button)
 {
   button->priv = ST_BUTTON_GET_PRIVATE (button);
@@ -455,6 +464,9 @@ st_button_init (StButton *button)
 
   clutter_actor_set_reactive (CLUTTER_ACTOR (button), TRUE);
   st_widget_set_track_hover (ST_WIDGET (button), TRUE);
+
+  g_signal_connect(button, "notify::reactive",
+                   G_CALLBACK (notify_reactive_cb), NULL);
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]