From 05a0b0b4fb52f8d71c4eb6df21516439b506893a Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Sun, 28 May 2006 23:34:47 +0000 Subject: [PATCH] select the current focus row if nothing is selected and ctrl is not 2006-05-29 Kristian Rietveld * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): select the current focus row if nothing is selected and ctrl is not pressed. (Fixes #324480, Murray Cumming/Srirama Sharma). --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ gtk/gtktreeview.c | 22 +++++++++++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7396aa1b84..ec6b6542c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-05-29 Kristian Rietveld + + * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): select + the current focus row if nothing is selected and ctrl is not pressed. + (Fixes #324480, Murray Cumming/Srirama Sharma). + 2006-05-28 Kristian Rietveld * gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_cell_focus): refactor diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7396aa1b84..ec6b6542c5 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2006-05-29 Kristian Rietveld + + * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): select + the current focus row if nothing is selected and ctrl is not pressed. + (Fixes #324480, Murray Cumming/Srirama Sharma). + 2006-05-28 Kristian Rietveld * gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_cell_focus): refactor diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 70d55373ee..183f3b9248 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -8755,6 +8755,7 @@ static void gtk_tree_view_move_cursor_up_down (GtkTreeView *tree_view, gint count) { + gint selection_count; GtkRBTree *cursor_tree = NULL; GtkRBNode *cursor_node = NULL; GtkRBTree *new_cursor_tree = NULL; @@ -8777,12 +8778,23 @@ gtk_tree_view_move_cursor_up_down (GtkTreeView *tree_view, if (cursor_tree == NULL) /* FIXME: we lost the cursor; should we get the first? */ return; - if (count == -1) - _gtk_rbtree_prev_full (cursor_tree, cursor_node, - &new_cursor_tree, &new_cursor_node); + + selection_count = gtk_tree_selection_count_selected_rows (tree_view->priv->selection); + + if (selection_count == 0 && !tree_view->priv->ctrl_pressed) + { + new_cursor_tree = cursor_tree; + new_cursor_node = cursor_node; + } else - _gtk_rbtree_next_full (cursor_tree, cursor_node, - &new_cursor_tree, &new_cursor_node); + { + if (count == -1) + _gtk_rbtree_prev_full (cursor_tree, cursor_node, + &new_cursor_tree, &new_cursor_node); + else + _gtk_rbtree_next_full (cursor_tree, cursor_node, + &new_cursor_tree, &new_cursor_node); + } /* * If the list has only one item and multi-selection is set then select