gui/collection: Update library paths when rows are clicked

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-01-01 11:23:27 -05:00
parent 2f9ee44000
commit 8dece02eed
4 changed files with 28 additions and 0 deletions

View File

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

View File

@ -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 */

View File

@ -627,6 +627,7 @@
<property name="show_expanders">False</property>
<property name="level_indentation">10</property>
<property name="enable_tree_lines">True</property>
<signal name="row-activated" handler="__collection_activated" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2">
<signal name="changed" handler="__collection_selection_changed" object="colmgr_chooser" swapped="no"/>

View File

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