[gtk/wip/matthiasc/a11y-2: 9/12] a11y: Drop notify_gtk() from GtkButtonAccessible
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/a11y-2: 9/12] a11y: Drop notify_gtk() from GtkButtonAccessible
- Date: Wed, 13 May 2020 17:42:06 +0000 (UTC)
commit f5daab3dd25c991979a85a7c7d452f6ec0acff47
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Apr 23 20:08:18 2020 +0100
a11y: Drop notify_gtk() from GtkButtonAccessible
Make GtkButton notify the accessible state directly when updating the
label.
gtk/a11y/gtkbuttonaccessible.c | 14 ++++++++++++++
gtk/a11y/gtkbuttonaccessible.h | 3 +++
gtk/gtkbutton.c | 9 +++++++++
3 files changed, 26 insertions(+)
---
diff --git a/gtk/a11y/gtkbuttonaccessible.c b/gtk/a11y/gtkbuttonaccessible.c
index b8f30658e9..deccb9300a 100644
--- a/gtk/a11y/gtkbuttonaccessible.c
+++ b/gtk/a11y/gtkbuttonaccessible.c
@@ -171,6 +171,20 @@ gtk_button_accessible_ref_state_set (AtkObject *obj)
return state_set;
}
+void
+gtk_button_accessible_update_label (GtkButtonAccessible *self)
+{
+ g_return_if_fail (GTK_IS_BUTTON_ACCESSIBLE (self));
+
+ /* If we don't have an overridden name, we use the label as the
+ * accessible name
+ */
+ if (atk_object_get_name (ATK_OBJECT (self)) == NULL)
+ g_object_notify (G_OBJECT (self), "accessible-name");
+
+ g_signal_emit_by_name (self, "visible-data-changed");
+}
+
static void
gtk_button_accessible_notify_gtk (GObject *obj,
GParamSpec *pspec)
diff --git a/gtk/a11y/gtkbuttonaccessible.h b/gtk/a11y/gtkbuttonaccessible.h
index 077344007d..1c49c329b6 100644
--- a/gtk/a11y/gtkbuttonaccessible.h
+++ b/gtk/a11y/gtkbuttonaccessible.h
@@ -52,6 +52,9 @@ struct _GtkButtonAccessibleClass
GDK_AVAILABLE_IN_ALL
GType gtk_button_accessible_get_type (void);
+/*< private >*/
+void gtk_button_accessible_update_label (GtkButtonAccessible *self);
+
G_END_DECLS
#endif /* __GTK_BUTTON_ACCESSIBLE_H__ */
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index fd9cbf7abc..dc96c752b1 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -836,6 +836,15 @@ gtk_button_set_label (GtkButton *button,
gtk_label_set_label (GTK_LABEL (priv->child), label);
gtk_button_set_child_type (button, LABEL_CHILD);
+
+ {
+ GtkButtonAccessible *accessible =
+ GTK_BUTTON_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (button)));
+
+ if (accessible != NULL)
+ gtk_button_accessible_update_label (accessible);
+ }
+
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_LABEL]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]