From 15ed068e13a89042c77f5440b7b26b2bcef81f63 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Mon, 25 Jul 2016 15:03:36 -0400 Subject: [PATCH] gui/playlist: Select Collection playlist during startup This preserves the original behavior, where the collection is always selected from the beginning. This can be improved upon later, once queued tracks are implemented as a playlist. Signed-off-by: Anna Schumaker --- gui/ocarina.c | 1 - gui/playlist.c | 11 +++++++++-- gui/sidebar.c | 20 -------------------- include/gui/sidebar.h | 3 --- 4 files changed, 9 insertions(+), 26 deletions(-) diff --git a/gui/ocarina.c b/gui/ocarina.c index bfb37f28..6e7b3bad 100644 --- a/gui/ocarina.c +++ b/gui/ocarina.c @@ -66,7 +66,6 @@ static void __ocarina_startup(GApplication *application, gpointer data) gui_audio_init(); gui_idle_enable(); - gui_sidebar_select_first(); g_free(ui); g_free(icon); diff --git a/gui/playlist.c b/gui/playlist.c index ca89fe5c..c7d0c454 100644 --- a/gui/playlist.c +++ b/gui/playlist.c @@ -166,15 +166,23 @@ static bool __playlist_erase(struct queue *queue, struct track *track) void gui_playlist_init() { + GtkTreeSelection *selection; GtkTreeView *treeview; GtkTreeIter parent; + GtkTreePath *path; - p_store = GTK_TREE_STORE(gui_builder_object("o_playlist_store")); + p_store = GTK_TREE_STORE(gui_builder_object("o_playlist_store")); + treeview = GTK_TREE_VIEW(gui_builder_widget("o_playlist_view")); + selection = gtk_tree_view_get_selection(treeview); gtk_tree_store_insert(p_store, &parent, NULL, -1); __playlist_set(&parent, "Collection", "media-optical"); __playlist_set_size(&parent, "Collection"); + path = gtk_tree_model_get_path(GTK_TREE_MODEL(p_store), &parent); + gtk_tree_selection_select_path(selection, path); + gtk_tree_path_free(path); + gtk_tree_store_insert(p_store, &parent, NULL, -1); __playlist_set(&parent, "History", "document-open-recent"); __playlist_set_size(&parent, "History"); @@ -191,7 +199,6 @@ void gui_playlist_init() __playlist_add(&parent, "Least Played", "go-down"); __playlist_add(&parent, "Unplayed", "audio-x-generic"); - treeview = GTK_TREE_VIEW(gui_builder_widget("o_playlist_view")); gtk_tree_view_expand_all(treeview); gtk_tree_selection_set_select_function( gtk_tree_view_get_selection(treeview), diff --git a/gui/sidebar.c b/gui/sidebar.c index ba4927b3..6b8b77b7 100644 --- a/gui/sidebar.c +++ b/gui/sidebar.c @@ -135,26 +135,6 @@ 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 a9c283e7..5a29f770 100644 --- a/include/gui/sidebar.h +++ b/include/gui/sidebar.h @@ -16,9 +16,6 @@ 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);