gui/collection: Add library paths on startup
And change to them when selected. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
08910bef7c
commit
2f9ee44000
|
@ -60,16 +60,18 @@ void __collection_add(GtkButton *button, GtkFileChooser *chooser)
|
|||
}
|
||||
|
||||
void __collection_selection_changed(GtkTreeSelection *selection,
|
||||
gpointer data)
|
||||
GtkFileChooser *chooser)
|
||||
{
|
||||
GtkNotebook *notebook = GTK_NOTEBOOK(gui_builder_widget("o_notebook"));
|
||||
struct library *library;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (gtk_tree_selection_get_selected(selection, &c_model, &iter)) {
|
||||
if (!__collection_get_library(&iter)) {
|
||||
gtk_notebook_set_current_page(notebook,
|
||||
tempq_count() + 3);
|
||||
}
|
||||
gtk_notebook_set_current_page(notebook, tempq_count() + 3);
|
||||
library = __collection_get_library(&iter);
|
||||
if (library)
|
||||
gtk_file_chooser_set_current_folder(chooser,
|
||||
library->li_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,6 +97,7 @@ static gboolean __collection_on_idle(gpointer data)
|
|||
|
||||
void gui_collection_init()
|
||||
{
|
||||
struct db_entry *library, *next;
|
||||
GtkTreeIter parent, iter;
|
||||
GtkTreeView *treeview;
|
||||
|
||||
|
@ -106,6 +109,12 @@ void gui_collection_init()
|
|||
GTK_ICON_SIZE_LARGE_TOOLBAR,
|
||||
"<span size='large'>Collection</span>");
|
||||
|
||||
/* Add library paths. */
|
||||
db_for_each(library, next, library_db_get()) {
|
||||
gtk_tree_store_insert(GTK_TREE_STORE(c_model), &iter, &parent, -1);
|
||||
__collection_set_library(&iter, LIBRARY(library));
|
||||
}
|
||||
|
||||
/* Add "Add new Library" entry. */
|
||||
gtk_tree_store_insert(GTK_TREE_STORE(c_model), &iter, &parent, -1);
|
||||
__collection_set_header(&iter, "folder-new", GTK_ICON_SIZE_MENU,
|
||||
|
|
|
@ -629,7 +629,7 @@
|
|||
<property name="enable_tree_lines">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection2">
|
||||
<signal name="changed" handler="__collection_selection_changed" swapped="no"/>
|
||||
<signal name="changed" handler="__collection_selection_changed" object="colmgr_chooser" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
|
|
@ -79,6 +79,14 @@ static void test_collection_sidebar()
|
|||
g_main_loop_run(main_loop);
|
||||
test_equal(gtk_widget_is_visible(GTK_WIDGET(progress)), false);
|
||||
|
||||
gtk_tree_store_clear(GTK_TREE_STORE(model));
|
||||
gui_collection_init();
|
||||
gtk_tree_model_get_iter_first(model, &iter);
|
||||
test_equal(gtk_tree_model_iter_n_children(model, &iter), 2);
|
||||
gtk_tree_model_iter_nth_child(model, &child, &iter, 0);
|
||||
gtk_tree_model_get(model, &child, 5, &library, -1);
|
||||
test_equal((void *)library, (void *)library_get(0));
|
||||
|
||||
gui_builder_deinit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue