diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-24 04:15:25 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-24 04:15:25 (EDT) |
commit | a9667056278842c0318ed8728f330380e01b31fb (patch) | |
tree | 08bbb53a98b30e23fd847cb3ccf464ed168d20fb | |
parent | 505f7bd3f82bffe555f27d5dba4f71d845b8a9b4 (diff) | |
download | marquee-a9667056278842c0318ed8728f330380e01b31fb.zip marquee-a9667056278842c0318ed8728f330380e01b31fb.tar.gz marquee-a9667056278842c0318ed8728f330380e01b31fb.tar.bz2 |
Revert "MqNotebook: Try to use gtk_tree_selection_select_iter()"
This reverts commit 505f7bd3f82bffe555f27d5dba4f71d845b8a9b4.
-rw-r--r-- | src/notebook.c | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/src/notebook.c b/src/notebook.c index d5503c5..8ef5733 100644 --- a/src/notebook.c +++ b/src/notebook.c @@ -133,8 +133,7 @@ new_tab_clicked_cb(GtkWidget G_GNUC_UNUSED *button, MqNotebook *notebook) } static void -create_tab_tree_model_recurse(MqNotebook *notebook, GtkTreeStore *tree_store, - GtkTreeSelection *tree_selection, MqTabTree *node, +create_tab_tree_model_recurse(MqTabTree *node, GtkTreeStore *tree_store, GtkTreeIter *parent_tree_iter) { GtkTreeIter tree_iter; @@ -145,24 +144,22 @@ create_tab_tree_model_recurse(MqNotebook *notebook, GtkTreeStore *tree_store, 0, mq_tree_position(node), 1, mq_tab_page_get_title(node->page), -1); - if (node->page == notebook->current_page) { - g_print("Selecting page \"%s\"\n", - mq_tab_page_get_title(node->page)); - gtk_tree_selection_select_iter(tree_selection, - &tree_iter); - } - create_tab_tree_model_recurse(notebook, tree_store, - tree_selection, MQ_TAB_TREE(mq_tree_first_child(node)), - &tree_iter); + create_tab_tree_model_recurse( + MQ_TAB_TREE(mq_tree_first_child(node)), + tree_store, &tree_iter); } } static GtkTreeModel * -create_tab_tree_model(MqNotebook *notebook, GtkTreeStore *tree_store, - GtkTreeSelection *tree_selection) +create_tab_tree_model(MqNotebook *notebook) { - create_tab_tree_model_recurse(notebook, tree_store, tree_selection, - MQ_TAB_TREE(mq_tree_first_child(notebook->tree)), NULL); + GtkTreeStore *tree_store; + + tree_store = gtk_tree_store_new(2, G_TYPE_INT, G_TYPE_STRING); + + create_tab_tree_model_recurse( + MQ_TAB_TREE(mq_tree_first_child(notebook->tree)), + tree_store, NULL); return GTK_TREE_MODEL(tree_store); } @@ -190,34 +187,33 @@ tab_tree_row_activated_cb(GtkTreeView G_GNUC_UNUSED *tree_view, static GtkWidget * create_tab_tree_view(MqNotebook *notebook) { - GtkTreeView *tree_view; + GtkTreeModel *tree_model; + GtkWidget *tree_view; GtkTreeSelection *tree_selection; - GtkTreeStore *tree_store; GtkCellRenderer *cell_renderer; - tree_store = gtk_tree_store_new(2, G_TYPE_INT, G_TYPE_STRING); - - tree_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model( - GTK_TREE_MODEL(tree_store))); - - tree_selection = gtk_tree_view_get_selection(tree_view); + tree_model = create_tab_tree_model(notebook); + tree_view = gtk_tree_view_new_with_model(tree_model); + tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); gtk_tree_selection_set_mode(tree_selection, GTK_SELECTION_BROWSE); - - create_tab_tree_model(notebook, tree_store, tree_selection); - - gtk_tree_view_set_headers_visible(tree_view, FALSE); - gtk_tree_view_set_activate_on_single_click(tree_view, TRUE); - gtk_tree_view_expand_all(tree_view); - gtk_tree_view_set_reorderable(tree_view, TRUE); - gtk_tree_view_set_enable_tree_lines(tree_view, TRUE); + gtk_tree_selection_select_path(tree_selection, + gtk_tree_path_new_from_indices( + gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)), + -1)); + 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", G_CALLBACK(tab_tree_row_activated_cb), notebook); cell_renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes(tree_view, + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree_view), -1, NULL, cell_renderer, "text", 1, NULL); - return GTK_WIDGET(tree_view); + return tree_view; } static void |