a11y: Report children of widgets
authorMatthias Clasen <mclasen@redhat.com>
Thu, 6 Feb 2020 04:07:33 +0000 (23:07 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 6 Feb 2020 21:54:59 +0000 (16:54 -0500)
We want children of composite accessibles to be
reported.

gtk/a11y/gtkwidgetaccessible.c

index 0a07f47fe2e783ea82e1aad8dd73c9220fa1db90..79c38a8f0160bd4bfa874a0eb3c7de6b217725a4 100644 (file)
@@ -409,16 +409,26 @@ gtk_widget_accessible_get_index_in_parent (AtkObject *accessible)
         }
     }
 
-  if (!GTK_IS_WIDGET (widget))
-    return -1;
   parent_widget = gtk_widget_get_parent (widget);
-  if (!GTK_IS_CONTAINER (parent_widget))
-    return -1;
+  if (GTK_IS_CONTAINER (parent_widget))
+    {
+      children = gtk_container_get_children (GTK_CONTAINER (parent_widget));
+      index = g_list_index (children, widget);
+      g_list_free (children);
+    }
+  else if (GTK_IS_WIDGET (parent_widget))
+    {
+      GtkWidget *child;
 
-  children = gtk_container_get_children (GTK_CONTAINER (parent_widget));
+      for (child = gtk_widget_get_first_child (parent_widget), index = 0; child; child = gtk_widget_get_next_sibling (child), index++)
+        {
+          if (child == widget)
+            break;
+        }
+    }
+  else
+    index = -1;
 
-  index = g_list_index (children, widget);
-  g_list_free (children);
   return index;
 }