[gtk+/composite-templates] a11y: Make lockbutton notify about state changes



commit 73335f5f0e2d49ebfad4e5336dbe28f649598817
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jul 9 03:11:01 2012 +0200

    a11y: Make lockbutton notify about state changes
    
    In particular, ensure that the name of the lockbutton gets updated as
    the displayed text of the lockbutton changes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677347

 gtk/a11y/gtklockbuttonaccessible.c |   17 ++++++++++++++++-
 gtk/a11y/gtklockbuttonaccessible.h |    4 ++++
 gtk/gtklockbutton.c                |   10 ++++++++--
 3 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/gtk/a11y/gtklockbuttonaccessible.c b/gtk/a11y/gtklockbuttonaccessible.c
index a24e310..641cfe3 100644
--- a/gtk/a11y/gtklockbuttonaccessible.c
+++ b/gtk/a11y/gtklockbuttonaccessible.c
@@ -17,9 +17,11 @@
 
 #include "config.h"
 
-#include "gtk/gtklockbuttonprivate.h"
 #include "gtklockbuttonaccessible.h"
 
+#include "gtk/gtklockbuttonprivate.h"
+#include "gtk/gtkwidgetprivate.h"
+
 G_DEFINE_TYPE (GtkLockButtonAccessible, _gtk_lock_button_accessible, GTK_TYPE_BUTTON_ACCESSIBLE)
 
 static const gchar *
@@ -46,3 +48,16 @@ static void
 _gtk_lock_button_accessible_init (GtkLockButtonAccessible *lockbutton)
 {
 }
+
+void
+_gtk_lock_button_accessible_name_changed (GtkLockButton *lockbutton)
+{
+  AtkObject *obj;
+
+  obj = _gtk_widget_peek_accessible (GTK_WIDGET (lockbutton));
+  if (obj == NULL)
+    return;
+
+  g_object_notify (G_OBJECT (obj), "accessible-name");
+}
+
diff --git a/gtk/a11y/gtklockbuttonaccessible.h b/gtk/a11y/gtklockbuttonaccessible.h
index 21bc93f..9430129 100644
--- a/gtk/a11y/gtklockbuttonaccessible.h
+++ b/gtk/a11y/gtklockbuttonaccessible.h
@@ -19,6 +19,7 @@
 #define __GTK_LOCK_BUTTON_ACCESSIBLE_H__
 
 #include "gtkbuttonaccessible.h"
+#include "gtk/gtklockbutton.h"
 
 G_BEGIN_DECLS
 
@@ -44,6 +45,9 @@ struct _GtkLockButtonAccessibleClass
 
 GType _gtk_lock_button_accessible_get_type (void);
 
+void  _gtk_lock_button_accessible_name_changed (GtkLockButton *lockbutton);
+
+
 G_END_DECLS
 
 #endif /* __GTK_LOCK_BUTTON_ACCESSIBLE_H__ */
diff --git a/gtk/gtklockbutton.c b/gtk/gtklockbutton.c
index 9cb828b..6121ade 100644
--- a/gtk/gtklockbutton.c
+++ b/gtk/gtklockbutton.c
@@ -185,10 +185,12 @@ gtk_lock_button_set_property (GObject      *object,
 
     case PROP_TEXT_LOCK:
       gtk_label_set_text (GTK_LABEL (priv->label_lock), g_value_get_string (value));
+      _gtk_lock_button_accessible_name_changed (button);
       break;
 
     case PROP_TEXT_UNLOCK:
       gtk_label_set_text (GTK_LABEL (priv->label_unlock), g_value_get_string (value));
+      _gtk_lock_button_accessible_name_changed (button);
       break;
 
     case PROP_TOOLTIP_LOCK:
@@ -388,8 +390,12 @@ update_state (GtkLockButton *button)
     }
 
   gtk_image_set_from_gicon (GTK_IMAGE (priv->image), icon, GTK_ICON_SIZE_MENU);
-  gtk_widget_set_visible (priv->label_lock, allowed);
-  gtk_widget_set_visible (priv->label_unlock, !allowed);
+  if (gtk_widget_get_visible (priv->label_lock) != allowed)
+    {
+      gtk_widget_set_visible (priv->label_lock, allowed);
+      gtk_widget_set_visible (priv->label_unlock, !allowed);
+      _gtk_lock_button_accessible_name_changed (button);
+    }
   gtk_widget_set_tooltip_markup (GTK_WIDGET (button), tooltip);
   gtk_widget_set_sensitive (GTK_WIDGET (button), sensitive);
   gtk_widget_set_visible (GTK_WIDGET (button), visible);



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