diff --git a/gui/sidebar.c b/gui/sidebar.c index 118aab5d..2ca2a26e 100644 --- a/gui/sidebar.c +++ b/gui/sidebar.c @@ -28,6 +28,22 @@ void __sidebar_resize(GtkPaned *pane, GParamSpec *pspec, gpointer data) gui_settings_set(SIDEBAR_SETTING, gtk_paned_get_position(pane)); } +void __sidebar_selection_changed(GtkTreeSelection *selection, gpointer data) +{ + GtkNotebook *notebook = GTK_NOTEBOOK(gui_builder_widget("o_notebook")); + GtkTreeModel *model = GTK_TREE_MODEL(sb_store); + GtkTreeIter iter; + + if (gtk_tree_selection_get_selected(selection, &model, &iter)) { + GtkTreePath *path = gtk_tree_model_get_path(model, &iter); + unsigned int page = gtk_tree_path_get_indices(path)[0]; + + gtk_notebook_set_current_page(notebook, page); + gui_sidebar_selected(SB_SIDEBAR); + gtk_tree_path_free(path); + } +} + void __sidebar_deselect(const gchar *widget) { GtkTreeView *treeview = GTK_TREE_VIEW(gui_builder_widget(widget)); @@ -70,4 +86,6 @@ void gui_sidebar_selected(enum sidebar_selection_t selected) __sidebar_deselect("o_collection_view"); if (selected != SB_PLAYLIST) __sidebar_deselect("o_playlist_view"); + if (selected != SB_SIDEBAR) + __sidebar_deselect("o_sidebar_view"); } diff --git a/include/gui/sidebar.h b/include/gui/sidebar.h index 309c81ec..5f68180e 100644 --- a/include/gui/sidebar.h +++ b/include/gui/sidebar.h @@ -7,6 +7,7 @@ enum sidebar_selection_t { SB_COLLECTION, SB_PLAYLIST, + SB_SIDEBAR, }; /* Called to initialize the sidebar. */ diff --git a/include/tests/gui.h b/include/tests/gui.h index 0e2bf1a0..a7f89779 100644 --- a/include/tests/gui.h +++ b/include/tests/gui.h @@ -13,6 +13,7 @@ void __audio_seek() {} #ifdef TEST_NEED_SIDEBAR void __sidebar_resize() {} +void __sidebar_selection_changed() {} #endif /* TEST_NEED_SIDEBAR */ #ifdef TEST_NEED_COLLECTION diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index dcd75499..7c627793 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -666,7 +666,9 @@ 10 True - + + +