[gtk/wip/ebassi/a11y-2] a11y: Drop notify_gtk() from GtkButtonAccessible
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/ebassi/a11y-2] a11y: Drop notify_gtk() from GtkButtonAccessible
- Date: Thu, 23 Apr 2020 19:17:58 +0000 (UTC)
commit 8035a6839f66c4218a6d862c5a48df3d6a736b5a
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 d296699ee2..bdb860eed8 100644
--- a/gtk/a11y/gtkbuttonaccessible.c
+++ b/gtk/a11y/gtkbuttonaccessible.c
@@ -178,6 +178,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 671c6c2e7b..8144c3b1de 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 947e440a63..e507c4eb3b 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -798,6 +798,15 @@ gtk_button_set_label (GtkButton *button,
gtk_label_set_label (GTK_LABEL (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]