Re: GTKTreeView navigation improvement



> Just two spontaneous comments:
> 1. You should provide regression tests for this feature (tests/testtree*)
What are those?
I'm not changing any structures or declaring any new variables. I
don't understand.
> 2. You are introducing C++ comments (//) but the core code should use
> C-style comments (/* */)
Didn't know about that,
Fixed patch is attached

-Andrey
--- gtk+2.0-2.18.3/gtk/gtktreeview.c	2009-10-08 22:00:44.000000000 -0700
+++ gtktreeview.c	2009-11-22 19:43:44.792600790 -0800
@@ -10102,14 +10102,30 @@ gtk_tree_view_real_expand_collapse_curso
   if (_gtk_tree_view_find_node (tree_view, cursor_path, &tree, &node))
     return FALSE;
 
-  /* Don't handle the event if we aren't an expander */
-  if (!((node->flags & GTK_RBNODE_IS_PARENT) == GTK_RBNODE_IS_PARENT))
-    return FALSE;
-
   if (!logical
       && gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL)
     expand = !expand;
 
+  /* On a keyboard accelerator for collapse, this code should move the cursor */
+  /* to the parent, if the node has no children or is collapsed */
+  /* notes: */
+  /* a node is expanded if node->children != null */
+   
+  if(!expand && (node->children == NULL))
+  {
+    /* get parent path or return false */
+    if(!gtk_tree_path_up(cursor_path))
+      return FALSE;
+
+    /*do the parent select */
+    gtk_tree_view_set_cursor(tree_view,cursor_path,NULL,FALSE);
+    return TRUE;
+  }
+
+  /* Don't handle the event if we aren't an expander */
+  if (!((node->flags & GTK_RBNODE_IS_PARENT) == GTK_RBNODE_IS_PARENT))
+    return FALSE;
+
   if (expand)
     gtk_tree_view_real_expand_row (tree_view, cursor_path, tree, node, open_all, TRUE);
   else


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