X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtktreeselection.c;h=10c9cd717a6908cf686251f22bd0ee58fb1e49d4;hb=56bcb1933f6de613e5d8689e23420d47b65425c3;hp=727119d609a7e0e6f835e3c2b98119567f54854d;hpb=d80d834be8a95c50f4754ab8dbcf1960ce2aad14;p=~andy%2Fgtk diff --git a/gtk/gtktreeselection.c b/gtk/gtktreeselection.c index 727119d60..10c9cd717 100644 --- a/gtk/gtktreeselection.c +++ b/gtk/gtktreeselection.c @@ -12,9 +12,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library. If not, see . */ #include "config.h" @@ -25,6 +23,7 @@ #include "gtkmarshalers.h" #include "gtkintl.h" #include "gtktypebuiltins.h" +#include "a11y/gtktreeviewaccessibleprivate.h" /** @@ -55,7 +54,7 @@ * * One of the important things to remember when monitoring the selection of * a view is that the #GtkTreeSelection::changed signal is mostly a hint. - * That is,it may only emit one signal when a range of rows is selected. + * That is, it may only emit one signal when a range of rows is selected. * Additionally, it may on occasion emit a #GtkTreeSelection::changed signal * when nothing has happened (mostly as a result of programmers calling * select_row on an already selected row). @@ -554,8 +553,7 @@ gtk_tree_selection_get_selected (GtkTreeSelection *selection, * * To free the return value, use: * |[ - * g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - * g_list_free (list); + * g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); * ]| * * Return value: (element-type GtkTreePath) (transfer full): A #GList containing a #GtkTreePath for each selected row. @@ -605,10 +603,7 @@ gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection, return NULL; } - node = tree->root; - - while (node->left != tree->nil) - node = node->left; + node = _gtk_rbtree_first (tree); path = gtk_tree_path_new_first (); do @@ -619,10 +614,7 @@ gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection, if (node->children) { tree = node->children; - node = tree->root; - - while (node->left != tree->nil) - node = node->left; + node = _gtk_rbtree_first (tree); gtk_tree_path_append_index (path, 0); } @@ -786,10 +778,7 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection, return; } - node = tree->root; - - while (node->left != tree->nil) - node = node->left; + node = _gtk_rbtree_first (tree); g_object_ref (model); @@ -824,10 +813,7 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection, if (node->children) { tree = node->children; - node = tree->root; - - while (node->left != tree->nil) - node = node->left; + node = _gtk_rbtree_first (tree); gtk_tree_path_append_index (path, 0); } @@ -1377,9 +1363,7 @@ gtk_tree_selection_real_modify_range (GtkTreeSelection *selection, if (start_node->children) { start_tree = start_node->children; - start_node = start_tree->root; - while (start_node->left != start_tree->nil) - start_node = start_node->left; + start_node = _gtk_rbtree_first (start_tree); } else { @@ -1644,14 +1628,23 @@ gtk_tree_selection_real_select_node (GtkTreeSelection *selection, if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED) != select) { - path = _gtk_tree_view_find_path (priv->tree_view, tree, node); + path = _gtk_tree_path_new_from_rbtree (tree, node); toggle = _gtk_tree_selection_row_is_selectable (selection, node, path); gtk_tree_path_free (path); } if (toggle) { - node->flags ^= GTK_RBNODE_IS_SELECTED; + if (!GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED)) + { + GTK_RBNODE_SET_FLAG (node, GTK_RBNODE_IS_SELECTED); + _gtk_tree_view_accessible_add_state (priv->tree_view, tree, node, GTK_CELL_RENDERER_SELECTED); + } + else + { + GTK_RBNODE_UNSET_FLAG (node, GTK_RBNODE_IS_SELECTED); + _gtk_tree_view_accessible_remove_state (priv->tree_view, tree, node, GTK_CELL_RENDERER_SELECTED); + } _gtk_tree_view_queue_draw_node (priv->tree_view, tree, node, NULL);