From 1ad112e217eae02ba80005ddf99d7899c4c8a500 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sat, 4 Jun 2016 13:52:09 -0400 Subject: [PATCH] gui/sidebar: Select first enabled queue during startup Otherwise the list of tracks is left blank, which the user might not be expecting. Fixes #55: Collection should be selected by default Signed-off-by: Anna Schumaker --- CHANGELOG | 2 ++ gui/ocarina.c | 1 + gui/sidebar.c | 20 ++++++++++++++++++++ include/gui/sidebar.h | 3 +++ 4 files changed, 26 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 2d887363..bd322488 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ 6.4.13: - Enable GtkTreeView fixed-height mode +- Fix bug where temporary queues don't save +- Fix bug where a queue is not selected on startup 6.4.13-rc: - Rewrite GtkTreeView code diff --git a/gui/ocarina.c b/gui/ocarina.c index df5a7ba8..38619290 100644 --- a/gui/ocarina.c +++ b/gui/ocarina.c @@ -72,6 +72,7 @@ int main(int argc, char **argv) g_free(ui); g_free(icon); + gui_sidebar_select_first(); g_signal_connect(G_APPLICATION(ocarina), "activate", (GCallback)__ocarina_activate, NULL); g_signal_connect(G_APPLICATION(ocarina), "shutdown", (GCallback)__ocarina_shutdown, NULL); diff --git a/gui/sidebar.c b/gui/sidebar.c index 00907410..9cc8cc00 100644 --- a/gui/sidebar.c +++ b/gui/sidebar.c @@ -138,6 +138,26 @@ void gui_sidebar_init() gtk_paned_set_position(pane, pos); } +void gui_sidebar_select_first() +{ + GtkTreeView *treeview = GTK_TREE_VIEW(gui_builder_widget("o_sidebar_view")); + GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); + struct gui_queue *gq; + GtkTreePath *path; + GtkTreeIter iter; + + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sb_store), &iter); + + do { + gq = __sidebar_get_queue(&iter); + } while (!queue_has_flag(gq->gq_queue, Q_ENABLED) && + gtk_tree_model_iter_next(GTK_TREE_MODEL(sb_store), &iter)); + + path = gtk_tree_model_get_path(GTK_TREE_MODEL(sb_store), &iter); + gtk_tree_selection_select_path(selection, path); + gtk_tree_path_free(path); +} + gboolean gui_sidebar_on_select(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean selected, gpointer data) diff --git a/include/gui/sidebar.h b/include/gui/sidebar.h index 5a29f770..a9c283e7 100644 --- a/include/gui/sidebar.h +++ b/include/gui/sidebar.h @@ -16,6 +16,9 @@ enum sidebar_selection_t { /* Called to initialize the sidebar. */ void gui_sidebar_init(); +/* Called to select the first item in the sidebar. */ +void gui_sidebar_select_first(); + /* Called when a row in the sidebar is selected. */ gboolean gui_sidebar_on_select(GtkTreeSelection *, GtkTreeModel *, GtkTreePath *path, gboolean, gpointer);