summaryrefslogtreecommitdiffstats
path: root/divelist.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-01-31 16:56:51 +1100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-31 17:31:36 +1100
commitb93f2ec6c3511ce9d0fc6d990ba97af7b8cc440d (patch)
treef40fe981aab0603a877e089b795863a21ae84e77 /divelist.c
parentd37f8736dbbf74157eb73a16678f2ec54c02d16c (diff)
downloadsubsurface-b93f2ec6c3511ce9d0fc6d990ba97af7b8cc440d.tar.gz
Make the dive selection logic also set the treeview cursor
This fixes "enter" after moving around with the cursor keys. Hinted-at-by: Carl Worth <cworth@cworth.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r--divelist.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/divelist.c b/divelist.c
index 5a942c13f..26ccd3de4 100644
--- a/divelist.c
+++ b/divelist.c
@@ -1250,6 +1250,8 @@ static void clear_trip_indexes(void)
trip->index = 0;
}
+/* Select the iter asked for, and set the keyboard focus on it */
+static void go_to_iter(GtkTreeSelection *selection, GtkTreeIter *iter);
static void fill_dive_list(void)
{
int i, trip_index = 0;
@@ -1344,7 +1346,7 @@ static void fill_dive_list(void)
gtk_tree_model_get(MODEL(dive_list), &iter, DIVE_INDEX, &selected_dive, -1);
first_leaf(MODEL(dive_list), &iter, &selected_dive);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dive_list.tree_view));
- gtk_tree_selection_select_iter(selection, &iter);
+ go_to_iter(selection, &iter);
}
}
@@ -2876,6 +2878,19 @@ void show_and_select_dive(struct dive *dive)
scroll_to_selected(iter);
}
+static void go_to_iter(GtkTreeSelection *selection, GtkTreeIter *iter)
+{
+ GtkTreePath *path;
+
+ scroll_to_selected(iter);
+ gtk_tree_selection_unselect_all(selection);
+ gtk_tree_selection_select_iter(selection, iter);
+
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(dive_list.model), iter);
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(dive_list.tree_view), path, NULL, FALSE);
+ gtk_tree_path_free(path);
+}
+
void select_next_dive(void)
{
GtkTreeIter *nextiter, *parent;
@@ -2903,9 +2918,7 @@ void select_next_dive(void)
if (! gtk_tree_model_iter_children(MODEL(dive_list), nextiter, parent))
return;
}
- scroll_to_selected(nextiter);
- gtk_tree_selection_unselect_all(selection);
- gtk_tree_selection_select_iter(selection, nextiter);
+ go_to_iter(selection, nextiter);
}
void select_prev_dive(void)
@@ -2941,9 +2954,7 @@ void select_prev_dive(void)
gtk_tree_model_iter_n_children(MODEL(dive_list), parent) - 1))
goto free_path;
}
- scroll_to_selected(&previter);
- gtk_tree_selection_unselect_all(selection);
- gtk_tree_selection_select_iter(selection, &previter);
+ go_to_iter(selection, &previter);
free_path:
gtk_tree_path_free(treepath);
}