[gtk+] a11y: Don't mess up if column gets hidden



commit 0dbf5db0e1f45b85f7b4d8bc96804f30f9836f2e
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jul 9 01:28:26 2012 +0200

    a11y: Don't mess up if column gets hidden
    
    We were using a function that insisted on visible columns for computing
    the potential ID of an invisible column. Not good.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675990

 gtk/a11y/gtktreeviewaccessible.c |   39 +++++++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c
index e441753..6e1d3c7 100644
--- a/gtk/a11y/gtktreeviewaccessible.c
+++ b/gtk/a11y/gtktreeviewaccessible.c
@@ -1785,24 +1785,41 @@ _gtk_tree_view_accessible_toggle_visibility (GtkTreeView       *treeview,
                                              GtkTreeViewColumn *column)
 {
   AtkObject *obj;
-  guint id;
+  guint i, id;
 
   obj = _gtk_widget_peek_accessible (GTK_WIDGET (treeview));
   if (obj == NULL)
     return;
 
-  id = get_column_number (treeview, column);
-
   if (gtk_tree_view_column_get_visible (column))
-    _gtk_tree_view_accessible_do_add_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
-                                             treeview,
-                                             column,
-                                             id);
+    {
+      id = get_column_number (treeview, column);
+
+      _gtk_tree_view_accessible_do_add_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
+                                               treeview,
+                                               column,
+                                               id);
+    }
   else
-    _gtk_tree_view_accessible_do_remove_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
-                                                treeview,
-                                                column,
-                                                id);
+    {
+      id = 0;
+
+      for (i = 0; i < gtk_tree_view_get_n_columns (treeview); i++)
+        {
+          GtkTreeViewColumn *cur = gtk_tree_view_get_column (treeview, i);
+          
+          if (gtk_tree_view_column_get_visible (cur))
+            id++;
+
+          if (cur == column)
+            break;
+        }
+
+      _gtk_tree_view_accessible_do_remove_column (GTK_TREE_VIEW_ACCESSIBLE (obj),
+                                                  treeview,
+                                                  column,
+                                                  id);
+    }
 }
 
 static GtkTreeViewColumn *



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