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
This commit is contained in:
Benjamin Otte 2012-07-09 03:11:01 +02:00
parent 58cf6dfaaf
commit b900016a05
3 changed files with 28 additions and 3 deletions

View File

@ -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");
}

View File

@ -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__ */

View File

@ -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);