[gtk/a11y/atspi] notebook: Set accessible roles and properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/a11y/atspi] notebook: Set accessible roles and properties
- Date: Thu, 15 Oct 2020 01:04:53 +0000 (UTC)
commit 08b586bb574167cf8f9c00213d0454452f504d5a
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 14 19:06:46 2020 -0400
notebook: Set accessible roles and properties
Set up the necessary roles, relations and properties
for the tab patterns. This parallels what we have done
for GtkStackSwitcher, and implements the Tabs pattern
as described in the ARIA authoring guidelines.
gtk/gtknotebook.c | 42 ++++++++++++++++++++++++++++++++++--------
1 file changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index cdf873861f..116e7d54d9 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -1404,13 +1404,14 @@ gtk_notebook_init (GtkNotebook *notebook)
gtk_widget_hide (notebook->header_widget);
gtk_widget_set_parent (notebook->header_widget, GTK_WIDGET (notebook));
- notebook->tabs_widget = gtk_gizmo_new ("tabs",
- gtk_notebook_measure_tabs,
- gtk_notebook_allocate_tabs,
- gtk_notebook_snapshot_tabs,
- NULL,
- (GtkGizmoFocusFunc)gtk_widget_focus_self,
- (GtkGizmoGrabFocusFunc)gtk_widget_grab_focus_self);
+ notebook->tabs_widget = gtk_gizmo_new_with_role ("tabs",
+ GTK_ACCESSIBLE_ROLE_TAB_LIST,
+ gtk_notebook_measure_tabs,
+ gtk_notebook_allocate_tabs,
+ gtk_notebook_snapshot_tabs,
+ NULL,
+ (GtkGizmoFocusFunc)gtk_widget_focus_self,
+ (GtkGizmoGrabFocusFunc)gtk_widget_grab_focus_self);
gtk_widget_set_hexpand (notebook->tabs_widget, TRUE);
gtk_box_append (GTK_BOX (notebook->header_widget), notebook->tabs_widget);
@@ -3915,6 +3916,7 @@ gtk_notebook_insert_notebook_page (GtkNotebook *notebook,
GList *list;
GtkWidget *sibling;
GtkEventController *controller;
+ GtkStackPage *stack_page;
nchildren = g_list_length (notebook->children);
if ((position < 0) || (position > nchildren))
@@ -3929,7 +3931,14 @@ gtk_notebook_insert_notebook_page (GtkNotebook *notebook,
else
sibling = notebook->arrow_widget[ARROW_RIGHT_AFTER];
- page->tab_widget = gtk_gizmo_new ("tab", measure_tab, allocate_tab, NULL, NULL, NULL, NULL);
+ page->tab_widget = gtk_gizmo_new_with_role ("tab",
+ GTK_ACCESSIBLE_ROLE_TAB,
+ measure_tab,
+ allocate_tab,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
g_object_set_data (G_OBJECT (page->tab_widget), "notebook", notebook);
gtk_widget_insert_before (page->tab_widget, notebook->tabs_widget, sibling);
controller = gtk_drop_controller_motion_new ();
@@ -3951,6 +3960,15 @@ gtk_notebook_insert_notebook_page (GtkNotebook *notebook,
g_object_set_data (G_OBJECT (page->tab_label), "notebook", notebook);
}
+ stack_page = gtk_stack_get_page (GTK_STACK (notebook->stack_widget), page->child);
+ gtk_accessible_update_relation (GTK_ACCESSIBLE (page->tab_widget),
+ GTK_ACCESSIBLE_RELATION_CONTROLS, g_list_append (NULL, stack_page),
+ -1);
+
+ gtk_accessible_update_state (GTK_ACCESSIBLE (page->tab_widget),
+ GTK_ACCESSIBLE_STATE_SELECTED, FALSE,
+ -1);
+
gtk_notebook_update_labels (notebook);
if (!notebook->first_tab)
@@ -5303,12 +5321,20 @@ gtk_notebook_real_switch_page (GtkNotebook *notebook,
if (focus)
child_has_focus = gtk_widget_is_ancestor (focus, notebook->cur_page->child);
gtk_widget_unset_state_flags (notebook->cur_page->tab_widget, GTK_STATE_FLAG_CHECKED);
+
+ gtk_accessible_update_state (GTK_ACCESSIBLE (notebook->cur_page->tab_widget),
+ GTK_ACCESSIBLE_STATE_SELECTED, FALSE,
+ -1);
}
notebook->cur_page = page;
gtk_widget_set_state_flags (page->tab_widget, GTK_STATE_FLAG_CHECKED, FALSE);
gtk_widget_set_visible (notebook->header_widget, notebook->show_tabs);
+ gtk_accessible_update_state (GTK_ACCESSIBLE (notebook->cur_page->tab_widget),
+ GTK_ACCESSIBLE_STATE_SELECTED, TRUE,
+ -1);
+
if (!notebook->focus_tab ||
notebook->focus_tab->data != (gpointer) notebook->cur_page)
notebook->focus_tab =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]