]> Pileus Git - ~andy/gtk/commitdiff
a11y: Add a special-case for cell index querying
authorBenjamin Otte <otte@redhat.com>
Fri, 11 Nov 2011 00:25:09 +0000 (01:25 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 16 Nov 2011 03:31:06 +0000 (04:31 +0100)
I could have tried to make GtkContainerCellAccessible implement
GtkCellAccessibleParent, but the current implementation of that
interface doesn't make sense for it.

gtk/a11y/gtkcellaccessible.c
gtk/a11y/gtkcontainercellaccessible.c

index 54bd1adf4720c6e5dcfa1a0cf8cb28d48712aa9f..c68ff271259b9e067fa7996d429c5083563fbb41 100644 (file)
@@ -95,6 +95,11 @@ gtk_cell_accessible_get_index_in_parent (AtkObject *obj)
   int index;
 
   cell = GTK_CELL_ACCESSIBLE (obj);
+
+  parent = atk_object_get_parent (obj);
+  if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
+    return g_list_index (GTK_CONTAINER_CELL_ACCESSIBLE (parent)->children, obj);
+
   parent = gtk_widget_get_accessible (cell->widget);
   if (parent == NULL)
     return -1;
index ad5bdb4ac370c3039d2f04924633e9174153b5e4..d2f577d938bd90f292d7e91631da747b3d045c34 100644 (file)
@@ -96,29 +96,6 @@ _gtk_container_cell_accessible_new (void)
   return container;
 }
 
-static void
-recompute_child_indices (GtkContainerCellAccessible *container)
-{
-  gint cur_index = 0;
-  GList *l;
-
-  for (l = container->children; l; l = l->next)
-    {
-      GTK_CELL_ACCESSIBLE (l->data)->index = cur_index;
-      cur_index++;
-    }
-}
-
-static void
-refresh_child_index (GtkCellAccessible *cell)
-{
-  AtkObject *parent;
-
-  parent = atk_object_get_parent (ATK_OBJECT (cell));
-
-  recompute_child_indices (GTK_CONTAINER_CELL_ACCESSIBLE (parent));
-}
-
 void
 _gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container,
                                           GtkCellAccessible          *child)
@@ -132,7 +109,6 @@ _gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container,
   container->children = g_list_append (container->children, child);
   child->index = child_index;
   atk_object_set_parent (ATK_OBJECT (child), ATK_OBJECT (container));
-  child->refresh_index = refresh_child_index;
 }
 
 void
@@ -144,6 +120,5 @@ _gtk_container_cell_accessible_remove_child (GtkContainerCellAccessible *contain
   g_return_if_fail (container->NChildren > 0);
 
   container->children = g_list_remove (container->children, child);
-  recompute_child_indices (container);
   container->NChildren--;
 }