Index: ChangeLog
===================================================================
RCS file: /export/cvs/head/gtk+/ChangeLog,v
retrieving revision 1.6582
diff -p -u -5 -r1.6582 ChangeLog
--- ChangeLog	9 May 2005 22:35:01 -0000	1.6582
+++ ChangeLog	10 May 2005 14:14:56 -0000
@@ -1,5 +1,12 @@
+2005-05-10  Srirama Sharma  <srirama.sharma@wipro.com>
+
+	* gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down):
+	If the treeview has no selection and a node has the focus then 
+	pressing Up/Down key should select it. Further Up/Down keypress 
+	allows user to traverse through the list. Fixes bug#303669.
+
 2005-05-09  Owen Taylor  <otaylor@redhat.com>
 
 	* gdk/gdkrgb.c (gdk_rgb_convert_0888_br, gdk_rgb_convert_8880_br): 
 	Fill in unused bits so they can be used for the depth-32 target case.
 	Rewrite so that that gives a marginal speedup rather than a
Index: gtk/gtktreeview.c
===================================================================
RCS file: /export/cvs/head/gtk+/gtk/gtktreeview.c,v
retrieving revision 1.455
diff -p -u -5 -r1.455 gtktreeview.c
--- gtk/gtktreeview.c	6 May 2005 19:36:41 -0000	1.455
+++ gtk/gtktreeview.c	10 May 2005 14:14:56 -0000
@@ -8428,10 +8428,15 @@ gtk_tree_view_move_cursor_up_down (GtkTr
   GtkRBTree *cursor_tree = NULL;
   GtkRBNode *cursor_node = NULL;
   GtkRBTree *new_cursor_tree = NULL;
   GtkRBNode *new_cursor_node = NULL;
   GtkTreePath *cursor_path = NULL;
+  GtkTreeSelection *selection;
+  GtkTreeModel     *model;
+  GList            *selected_rows;
+  gboolean mask_key_pressed = (tree_view->priv->shift_pressed ||
+			       tree_view->priv->ctrl_pressed);
 
   if (! GTK_WIDGET_HAS_FOCUS (tree_view))
     return;
 
   cursor_path = NULL;
@@ -8452,46 +8457,72 @@ gtk_tree_view_move_cursor_up_down (GtkTr
 			   &new_cursor_tree, &new_cursor_node);
   else
     _gtk_rbtree_next_full (cursor_tree, cursor_node,
 			   &new_cursor_tree, &new_cursor_node);
 
+  selection = gtk_tree_view_get_selection (tree_view);
+  selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
+
   /*
-   * If the list has only one item and multi-selection is set then select
-   * the row.
+   * If there is a focus on an item, then pressing Up/Down should select it.
+   * 
    */
-  if (tree_view->priv->selection->type == GTK_SELECTION_MULTIPLE &&
-      new_cursor_node == NULL)
+  if (new_cursor_node == NULL)
     {
-      if (count == -1)
-        _gtk_rbtree_next_full (cursor_tree, cursor_node,
-    			       &new_cursor_tree, &new_cursor_node);
-      else
-        _gtk_rbtree_prev_full (cursor_tree, cursor_node,
-			       &new_cursor_tree, &new_cursor_node);
+      if (tree_view->priv->selection->type == GTK_SELECTION_MULTIPLE)
+	{
+	  if (count == -1)
+	    _gtk_rbtree_next_full (cursor_tree, cursor_node,
+				   &new_cursor_tree, &new_cursor_node);
+	  else
+	    _gtk_rbtree_prev_full (cursor_tree, cursor_node,
+				   &new_cursor_tree, &new_cursor_node);
 
-      if (new_cursor_node == NULL)
-        {
-          new_cursor_node = cursor_node;
-          new_cursor_tree = cursor_tree;
-        }
+	  if (new_cursor_node == NULL || (new_cursor_node != NULL &&
+	      !selected_rows && !mask_key_pressed))
+	    {
+	      new_cursor_node = cursor_node;
+	      new_cursor_tree = cursor_tree;
+	    }
+	  else
+	    {
+	      new_cursor_node = NULL;
+	    }
+	}
       else
-        {
-          new_cursor_node = NULL;
-        }
-    }
+	{
+	  if (!selected_rows && !mask_key_pressed)
+	    {
+	      new_cursor_node = cursor_node;
+	      new_cursor_tree = cursor_tree;
+	    }
+	}
+  }
 
   if (new_cursor_node)
     {
-      cursor_path = _gtk_tree_view_find_path (tree_view, new_cursor_tree, new_cursor_node);
+      if (!selected_rows && !mask_key_pressed)
+	cursor_path = _gtk_tree_view_find_path (tree_view, cursor_tree, 
+						cursor_node);
+      else
+	cursor_path = _gtk_tree_view_find_path (tree_view, new_cursor_tree, 
+						new_cursor_node);
+
       gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE, TRUE);
       gtk_tree_path_free (cursor_path);
     }
   else
     {
       gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node);
     }
 
+  if (selected_rows)
+    {
+      g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
+      g_list_free (selected_rows);
+    }
+
   gtk_widget_grab_focus (GTK_WIDGET (tree_view));
 }
 
 static void
 gtk_tree_view_move_cursor_page_up_down (GtkTreeView *tree_view,
