--- gtk+-2.8.6-orig/gtk/gtktreeview.c	2005-09-13 15:40:45.000000000 +0200
+++ gtk+-2.8.6/gtk/gtktreeview.c	2006-03-29 23:14:22.000000000 +0200
@@ -966,23 +966,6 @@
   gtk_tree_view_add_move_binding (binding_set, GDK_KP_Page_Down, 0,
 				  GTK_MOVEMENT_PAGES, 1);
 
-
-  gtk_binding_entry_add_signal (binding_set, GDK_Right, 0, "move_cursor", 2,
-				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
-				G_TYPE_INT, 1);
-
-  gtk_binding_entry_add_signal (binding_set, GDK_Left, 0, "move_cursor", 2,
-				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
-				G_TYPE_INT, -1);
-
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Right, 0, "move_cursor", 2,
-				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
-				G_TYPE_INT, 1);
-
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Left, 0, "move_cursor", 2,
-				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
-				G_TYPE_INT, -1);
-
   gtk_binding_entry_add_signal (binding_set, GDK_Right, GDK_CONTROL_MASK,
                                 "move_cursor", 2,
 				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
@@ -1068,11 +1051,21 @@
 				G_TYPE_BOOLEAN, TRUE,
 				G_TYPE_BOOLEAN, TRUE,
 				G_TYPE_BOOLEAN, TRUE);
+  gtk_binding_entry_add_signal (binding_set, GDK_Right, 0,
+                                "expand_collapse_cursor_row", 3,
+				G_TYPE_BOOLEAN, FALSE,
+				G_TYPE_BOOLEAN, TRUE,
+				G_TYPE_BOOLEAN, FALSE);
   gtk_binding_entry_add_signal (binding_set, GDK_Right, GDK_SHIFT_MASK,
                                 "expand_collapse_cursor_row", 3,
 				G_TYPE_BOOLEAN, FALSE,
 				G_TYPE_BOOLEAN, TRUE,
 				G_TYPE_BOOLEAN, TRUE);
+  gtk_binding_entry_add_signal (binding_set, GDK_KP_Right, 0,
+                                "expand_collapse_cursor_row", 3,
+				G_TYPE_BOOLEAN, FALSE,
+				G_TYPE_BOOLEAN, TRUE,
+				G_TYPE_BOOLEAN, FALSE);
   gtk_binding_entry_add_signal (binding_set, GDK_KP_Right, GDK_SHIFT_MASK,
                                 "expand_collapse_cursor_row", 3,
 				G_TYPE_BOOLEAN, FALSE,
@@ -1107,6 +1100,16 @@
 				G_TYPE_BOOLEAN, TRUE,
 				G_TYPE_BOOLEAN, FALSE,
 				G_TYPE_BOOLEAN, TRUE);
+  gtk_binding_entry_add_signal (binding_set, GDK_Left, 0,
+                                "expand_collapse_cursor_row", 3,
+				G_TYPE_BOOLEAN, FALSE,
+				G_TYPE_BOOLEAN, FALSE,
+				G_TYPE_BOOLEAN, TRUE);
+  gtk_binding_entry_add_signal (binding_set, GDK_KP_Left, 0,
+                                "expand_collapse_cursor_row", 3,
+				G_TYPE_BOOLEAN, FALSE,
+				G_TYPE_BOOLEAN, FALSE,
+				G_TYPE_BOOLEAN, TRUE);
   gtk_binding_entry_add_signal (binding_set, GDK_Left, GDK_SHIFT_MASK,
                                 "expand_collapse_cursor_row", 3,
 				G_TYPE_BOOLEAN, FALSE,
@@ -8954,18 +8957,38 @@
   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;
 
-  if (expand)
-    gtk_tree_view_real_expand_row (tree_view, cursor_path, tree, node, open_all, TRUE);
-  else
-    gtk_tree_view_real_collapse_row (tree_view, cursor_path, tree, node, TRUE);
+  /* Don't handle the event if we aren't an expander */
+  if (!((node->flags & GTK_RBNODE_IS_PARENT) == GTK_RBNODE_IS_PARENT)) {
+    if (!expand) { 
+      /* Already collapsed, so go to parent */
+      gtk_tree_view_real_select_cursor_parent(tree_view);
+    }
+    return FALSE;
+  }
+
+  if (expand) {
+    
+    if (node->children != NULL && !open_all) {
+      /* Move right */
+ 
+      gtk_tree_view_move_cursor_up_down(tree_view,1);
+    } else {
+      gtk_tree_view_real_expand_row (tree_view, cursor_path, tree, node, open_all, TRUE);
+    }
+    
+  } else {
+    if (node->children == NULL) {
+      /* Already collapsed, so go to parent */
+      gtk_tree_view_real_select_cursor_parent(tree_view);
+    } else {
+      gtk_tree_view_real_collapse_row (tree_view, cursor_path, tree, node, TRUE);
+    }
+  }
 
   gtk_tree_path_free (cursor_path);
 
