From 3839db6ba17258c4c931ccfff2838a5ebd7b54fb Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 28 Sep 2017 16:07:03 -0400 Subject: MqTab: Set current tab on tree row activation --- diff --git a/src/tab.c b/src/tab.c index 5914bdf..3db9f45 100644 --- a/src/tab.c +++ b/src/tab.c @@ -168,6 +168,20 @@ create_tree_model(MqTab *tab) return GTK_TREE_MODEL(tree_store); } +static void +row_activated_cb(GtkTreeView __attribute__((unused)) *tree_view, + GtkTreePath *tree_path, + GtkTreeViewColumn __attribute__((unused)) *tree_view_column, + MqTab *tab) +{ + gint *indices; + gint depth; + + indices = gtk_tree_path_get_indices_with_depth(tree_path, &depth); + g_assert(depth == 1); + mq_window_set_current_tab(tab->window, indices[0] + 1); +} + static GtkWidget * create_tab_list(MqTab *tab) { @@ -188,6 +202,8 @@ create_tab_list(MqTab *tab) 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(row_activated_cb), tab); cell_renderer = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree_view), -- cgit v0.9.1