[gtk/ebassi/issue-902] Fix accessibility handling of child elements




commit 207865c7b69ff6d1f162c4c0e181a49a1b43af78
Author: Marcin Szalowicz <mszalowicz mailplus pl>
Date:   Thu Nov 23 15:00:26 2017 +0100

    Fix accessibility handling of child elements
    
    notebook tab can have more than label widget which should be reflected in the accessibility tree

 gtk/a11y/gtknotebookpageaccessible.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/gtk/a11y/gtknotebookpageaccessible.c b/gtk/a11y/gtknotebookpageaccessible.c
index 0f57c737b8..be3b3e31d5 100644
--- a/gtk/a11y/gtknotebookpageaccessible.c
+++ b/gtk/a11y/gtknotebookpageaccessible.c
@@ -115,7 +115,8 @@ gtk_notebook_page_accessible_get_parent (AtkObject *accessible)
 static gint
 gtk_notebook_page_accessible_get_n_children (AtkObject *accessible)
 {
-  return 1;
+  /* A tab label widget can either be a GtkLabel or any container widget */
+  return 2;
 }
 
 static AtkObject *
@@ -123,19 +124,32 @@ gtk_notebook_page_accessible_ref_child (AtkObject *accessible,
                                         gint       i)
 {
   AtkObject *child_obj;
-  GtkNotebookPageAccessible *page = NULL;
+  GtkNotebookPageAccessible *page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
+  GtkWidget *label = NULL;
+  GtkNotebook *notebook = NULL;
 
-  if (i != 0)
+  notebook = GTK_NOTEBOOK (gtk_accessible_get_widget (page->priv->notebook));
+  if (notebook == NULL)
     return NULL;
 
-  page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
-  if (!page->priv->child)
-    return NULL;
+  if (i == 0)
+    {
+      /* First will be always the label or the component that contains the label */
+      label = gtk_notebook_get_tab_label (notebook, page->priv->child);
+      child_obj = gtk_widget_get_accessible (label);
+      return g_object_ref (child_obj);
+    }
+  else if (i == 1)
+    {
+      page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
+      if (page->priv->child == NULL)
+        return NULL;
 
-  child_obj = gtk_widget_get_accessible (page->priv->child);
-  g_object_ref (child_obj);
+      child_obj = gtk_widget_get_accessible (page->priv->child);
+      return g_object_ref (child_obj);
+    }
 
-  return child_obj;
+  return NULL;
 }
 
 static AtkStateSet *


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