[gtk/ebassi/for-master: 14/15] a11y: Add more accessible data to GtkTreeExpander




commit d8b342df045c27849af82a45d7c8858ac7a83f08
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Nov 12 16:16:48 2020 +0000

    a11y: Add more accessible data to GtkTreeExpander
    
    Document the role of the GtkTreeExpander, and the behaviour of the
    expander button.
    
    Additionally, improve the label of the expander button, by adding a
    fixed "Expand" label, and setting the "labelled-by" relation to the
    child of the GtkTreeExpander.

 gtk/gtktreeexpander.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/gtk/gtktreeexpander.c b/gtk/gtktreeexpander.c
index 2a68df898d..9b50e02039 100644
--- a/gtk/gtktreeexpander.c
+++ b/gtk/gtktreeexpander.c
@@ -25,6 +25,7 @@
 #include "gtkboxlayout.h"
 #include "gtkbuiltiniconprivate.h"
 #include "gtkdropcontrollermotion.h"
+#include "gtkenums.h"
 #include "gtkgestureclick.h"
 #include "gtkintl.h"
 #include "gtktreelistmodel.h"
@@ -66,6 +67,12 @@
  * If the node is not expandable, an "indent" node will be displayed instead.
  *
  * For every level of depth, another "indent" node is prepended.
+ *
+ * # Accessibility
+ *
+ * GtkTreeExpander uses the %GTK_ACCESSIBLE_ROLE_GROUP role. The expander icon
+ * is represented as a %GTK_ACCESSIBLE_ROLE_BUTTON, labelled by the expander's
+ * child, and toggling it will change the %GTK_ACCESSIBLE_STATE_EXPANDED state.
  */
 
 struct _GtkTreeExpander
@@ -182,6 +189,13 @@ gtk_tree_expander_update_for_list_row (GtkTreeExpander *self)
               gtk_widget_insert_before (self->expander,
                                         GTK_WIDGET (self),
                                         self->child);
+
+              gtk_accessible_update_property (GTK_ACCESSIBLE (self->expander),
+                                              GTK_ACCESSIBLE_PROPERTY_LABEL, _("Expand"),
+                                              -1);
+              gtk_accessible_update_relation (GTK_ACCESSIBLE (self->expander),
+                                              GTK_ACCESSIBLE_RELATION_LABELLED_BY, self->child, NULL,
+                                              -1);
             }
 
           if (gtk_tree_list_row_get_expanded (self->list_row))
@@ -600,6 +614,7 @@ gtk_tree_expander_class_init (GtkTreeExpanderClass *klass)
 
   gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
   gtk_widget_class_set_css_name (widget_class, I_("treeexpander"));
+  gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GROUP);
 }
 
 static gboolean


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