[gtk/a11y/stackswitcher-tabs: 4/5] stackswitcher: Set up relations and states




commit 5d962412c721fe693c135fd4beffedd45c67566f
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Oct 14 00:25:57 2020 -0400

    stackswitcher: Set up relations and states
    
    Set up a CONTROLS relation between each tab button
    and its page, and update the SELECTED property of
    the buttons to match their active state.

 gtk/gtkstackswitcher.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index e9cbfc9b90..4392cc9cdb 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -267,6 +267,14 @@ add_child (guint             position,
   selected = gtk_selection_model_is_selected (self->pages, position);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), selected);
 
+  gtk_accessible_update_state (GTK_ACCESSIBLE (button),
+                               GTK_ACCESSIBLE_STATE_SELECTED, selected,
+                               -1);
+
+  gtk_accessible_update_relation (GTK_ACCESSIBLE (button),
+                                  GTK_ACCESSIBLE_RELATION_CONTROLS, g_list_append (NULL, page),
+                                  -1);
+
   g_signal_connect (button, "notify::active", G_CALLBACK (on_button_toggled), self);
   g_signal_connect (page, "notify", G_CALLBACK (on_page_updated), self);
 
@@ -331,6 +339,10 @@ selection_changed_cb (GtkSelectionModel *model,
         {
           selected = gtk_selection_model_is_selected (switcher->pages, i);
           gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), selected);
+
+          gtk_accessible_update_state (GTK_ACCESSIBLE (button),
+                                       GTK_ACCESSIBLE_STATE_SELECTED, selected,
+                                       -1);
         }
       g_object_unref (page);
     }


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