diff --git a/gui/collection.c b/gui/collection.c index fb44bacb..182600d3 100644 --- a/gui/collection.c +++ b/gui/collection.c @@ -42,6 +42,21 @@ static struct library *__collection_get_library(GtkTreeIter *iter) return library; } +void __collection_activated(GtkTreeView *treeview, GtkTreePath *path, + GtkTreeViewColumn *column, gpointer data) +{ + struct library *library = NULL; + GtkTreeIter iter; + + if (gtk_tree_model_get_iter(c_model, &iter, path)) + library = __collection_get_library(&iter); + if (!library) + return; + + collection_update(library); + gui_collection_idle_enable(); +} + void __collection_add(GtkButton *button, GtkFileChooser *chooser) { gchar *filename = gtk_file_chooser_get_filename(chooser); diff --git a/include/tests/gui.h b/include/tests/gui.h index b4f9affc..7e4514f4 100644 --- a/include/tests/gui.h +++ b/include/tests/gui.h @@ -16,6 +16,7 @@ void __sidebar_resize() {} #endif /* TEST_NEED_SIDEBAR */ #ifdef TEST_NEED_COLLECTION +void __collection_activated() {} void __collection_add() {} void __collection_selection_changed() {} #endif /* TEST_NEED_COLLECTION */ diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 3f499bef..bc8a83e2 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -627,6 +627,7 @@ False 10 True + diff --git a/tests/gui/collection.c b/tests/gui/collection.c index 9f549ecc..d66c103c 100644 --- a/tests/gui/collection.c +++ b/tests/gui/collection.c @@ -87,6 +87,17 @@ static void test_collection_sidebar() gtk_tree_model_get(model, &child, 5, &library, -1); test_equal((void *)library, (void *)library_get(0)); + path = gtk_tree_model_get_path(model, &child); + gtk_tree_view_row_activated(treeview, path, NULL); + gtk_tree_path_free(path); + + /* Again, run two idle events to update the selected path. */ + test_equal(gtk_widget_is_visible(GTK_WIDGET(progress)), true); + g_main_loop_run(main_loop); + test_equal((float)gtk_progress_bar_get_fraction(progress), (float)0.5); + g_main_loop_run(main_loop); + test_equal(gtk_widget_is_visible(GTK_WIDGET(progress)), false); + gui_builder_deinit(); }