summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/notebook.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/notebook.c b/src/notebook.c
index 8ef5733..126732a 100644
--- a/src/notebook.c
+++ b/src/notebook.c
@@ -133,8 +133,9 @@ new_tab_clicked_cb(GtkWidget G_GNUC_UNUSED *button, MqNotebook *notebook)
}
static void
-create_tab_tree_model_recurse(MqTabTree *node, GtkTreeStore *tree_store,
- GtkTreeIter *parent_tree_iter)
+create_tab_tree_model_recurse(MqNotebook *notebook, MqTabTree *node,
+ GtkTreeStore *tree_store, GtkTreeIter *parent_tree_iter,
+ GtkTreeIter **select_tree_iter)
{
GtkTreeIter tree_iter;
@@ -144,22 +145,25 @@ create_tab_tree_model_recurse(MqTabTree *node, GtkTreeStore *tree_store,
0, mq_tree_position(node),
1, mq_tab_page_get_title(node->page),
-1);
- create_tab_tree_model_recurse(
+ if (node->page == notebook->current_page) {
+ *select_tree_iter = gtk_tree_iter_copy(&tree_iter);
+ }
+ create_tab_tree_model_recurse(notebook,
MQ_TAB_TREE(mq_tree_first_child(node)),
- tree_store, &tree_iter);
+ tree_store, &tree_iter, select_tree_iter);
}
}
static GtkTreeModel *
-create_tab_tree_model(MqNotebook *notebook)
+create_tab_tree_model(MqNotebook *notebook, GtkTreeIter **select_tree_iter)
{
GtkTreeStore *tree_store;
tree_store = gtk_tree_store_new(2, G_TYPE_INT, G_TYPE_STRING);
- create_tab_tree_model_recurse(
+ create_tab_tree_model_recurse(notebook,
MQ_TAB_TREE(mq_tree_first_child(notebook->tree)),
- tree_store, NULL);
+ tree_store, NULL, select_tree_iter);
return GTK_TREE_MODEL(tree_store);
}
@@ -188,22 +192,21 @@ static GtkWidget *
create_tab_tree_view(MqNotebook *notebook)
{
GtkTreeModel *tree_model;
+ GtkTreeIter *select_tree_iter;
GtkWidget *tree_view;
GtkTreeSelection *tree_selection;
GtkCellRenderer *cell_renderer;
- tree_model = create_tab_tree_model(notebook);
+ tree_model = create_tab_tree_model(notebook, &select_tree_iter);
tree_view = gtk_tree_view_new_with_model(tree_model);
+ gtk_tree_view_expand_all(GTK_TREE_VIEW(tree_view));
tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
gtk_tree_selection_set_mode(tree_selection, GTK_SELECTION_BROWSE);
- gtk_tree_selection_select_path(tree_selection,
- gtk_tree_path_new_from_indices(
- gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)),
- -1));
+ gtk_tree_selection_select_iter(tree_selection, select_tree_iter);
+ gtk_tree_iter_free(select_tree_iter);
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), FALSE);
gtk_tree_view_set_activate_on_single_click(GTK_TREE_VIEW(tree_view),
TRUE);
- gtk_tree_view_expand_all(GTK_TREE_VIEW(tree_view));
gtk_tree_view_set_reorderable(GTK_TREE_VIEW(tree_view), TRUE);
gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(tree_view), TRUE);
g_signal_connect(tree_view, "row-activated",