diff --git a/CHANGELOG b/CHANGELOG index 0648b399..00ec2644 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ 6.4.11: +- Move collection enabled checkboxes into a right click menu - Various UI tweaks 6.4.11-rc: diff --git a/gui/collection.c b/gui/collection.c index 49e3eaff..fa60eb86 100644 --- a/gui/collection.c +++ b/gui/collection.c @@ -10,8 +10,6 @@ enum collection_sidebar_columns { C_SB_IMAGE, - C_SB_ENABLED, - C_SB_SHOW_ENABLED, C_SB_PATH, C_SB_LIBRARY, }; @@ -28,8 +26,6 @@ static void __collection_set_header(GtkTreeIter *iter, const gchar *image, static void __collection_set_library(GtkTreeIter *iter, struct library *library) { gtk_tree_store_set(GTK_TREE_STORE(c_model), iter, - C_SB_ENABLED, library->li_enabled, - C_SB_SHOW_ENABLED, true, C_SB_IMAGE, "folder", C_SB_PATH, library->li_path, C_SB_LIBRARY, library, -1); @@ -58,18 +54,25 @@ void __collection_activated(GtkTreeView *treeview, GtkTreePath *path, gui_collection_idle_enable(); } -void __collection_toggled(GtkCellRendererToggle *toggle, gchar *path, - gpointer data) +void __collection_toggled(GtkCheckMenuItem *check, gpointer data) { + GtkTreeView *treeview = GTK_TREE_VIEW(gui_builder_widget("o_collection_view")); + GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); struct library *library = NULL; + GtkTreePath *path; GtkTreeIter iter; + GList *rows; - if (gtk_tree_model_get_iter_from_string(c_model, &iter, path)) + rows = gtk_tree_selection_get_selected_rows(selection, &c_model); + if (!rows) + return; + path = rows->data; + if (gtk_tree_model_get_iter(c_model, &iter, path)) library = __collection_get_library(&iter); if (!library) return; - collection_set_enabled(library, !library->li_enabled); + collection_set_enabled(library, gtk_check_menu_item_get_active(check)); __collection_set_library(&iter, library); } @@ -100,6 +103,35 @@ out: return true; } +bool __collection_buttonpress(GtkWidget *widget, GdkEventButton *event, gpointer data) +{ + GtkCheckMenuItem *check = GTK_CHECK_MENU_ITEM(gui_builder_widget("o_collection_enabled")); + GtkTreeView *treeview = GTK_TREE_VIEW(gui_builder_widget("o_collection_view")); + GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); + GtkMenu *menu = GTK_MENU(gui_builder_widget("o_collection_rc")); + struct library *library = NULL; + GtkTreePath *path; + GtkTreeIter iter; + + if (event->button != 3) + return false; + + if (gtk_tree_view_get_path_at_pos(treeview, event->x, event->y, + &path, NULL, NULL, NULL)) + gtk_tree_selection_select_path(selection, path); + if (gtk_tree_model_get_iter(c_model, &iter, path)) + library = __collection_get_library(&iter); + + if (library) { + gtk_check_menu_item_set_active(check, library->li_enabled); + gtk_menu_popup(menu, NULL, NULL, NULL, NULL, + event->button, event->time); + } + + gtk_tree_path_free(path); + return true; +} + void __collection_add(GtkButton *button, GtkFileChooser *chooser) { gchar *filename = gtk_file_chooser_get_filename(chooser); diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 67da87aa..4cf0e69c 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -210,14 +210,23 @@ False window-close + + True + False + + + True + False + Library Path Enabled + True + + + + - - - - @@ -747,6 +756,7 @@ o_collection_store False True + @@ -767,28 +777,13 @@ - - - Enabled - - - - - - 2 - 1 - - - - Path - 3 - 3 + 1 diff --git a/tests/gui/collection.c b/tests/gui/collection.c index 40c1e739..5f6d79dd 100644 --- a/tests/gui/collection.c +++ b/tests/gui/collection.c @@ -70,7 +70,7 @@ static void test_collection_sidebar() 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, 4, &library, -1); + gtk_tree_model_get(model, &child, 2, &library, -1); test_equal((void *)library, (void *)library_get(0)); /* Run two idle events to scan the added path. */ @@ -85,7 +85,7 @@ static void test_collection_sidebar() 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, 4, &library, -1); + gtk_tree_model_get(model, &child, 2, &library, -1); test_equal((void *)library, (void *)library_get(0)); path = gtk_tree_model_get_path(model, &child);