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 <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-07-25 15:03:36 -04:00
parent 696173b03e
commit 15ed068e13
4 changed files with 9 additions and 26 deletions

View File

@ -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);

View File

@ -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),

View File

@ -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)

View File

@ -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);