From 2cae2cd525263214fb6b0515cf2065b645429bd1 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Fri, 1 Jan 2016 11:49:19 -0500 Subject: [PATCH] gui/collection: Remove library paths with the Delete key Signed-off-by: Anna Schumaker --- gui/collection.c | 27 +++++++++++++++++++++++++++ include/tests/gui.h | 1 + share/ocarina/ocarina6.glade | 11 ++++++----- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/gui/collection.c b/gui/collection.c index 9c995c19..15714ef9 100644 --- a/gui/collection.c +++ b/gui/collection.c @@ -72,6 +72,33 @@ void __collection_toggled(GtkCellRendererToggle *toggle, gchar *path, __collection_set_library(&iter, library); } +bool __collection_keypress(GtkTreeView *treeview, GdkEventKey *event, + gpointer data) +{ + GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); + struct library *library = NULL; + GtkTreePath *path; + GtkTreeIter iter; + GList *rows; + + if (event->keyval != GDK_KEY_Delete) + return false; + + rows = gtk_tree_selection_get_selected_rows(selection, &c_model); + path = rows->data; + + if (gtk_tree_model_get_iter(c_model, &iter, path)) + library = __collection_get_library(&iter); + if (!library) + goto out; + + collection_remove(library); + gtk_tree_store_remove(GTK_TREE_STORE(c_model), &iter); +out: + g_list_free_full(rows, (GDestroyNotify)gtk_tree_path_free); + return true; +} + 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 4936b2ad..cbd3120a 100644 --- a/include/tests/gui.h +++ b/include/tests/gui.h @@ -18,6 +18,7 @@ void __sidebar_resize() {} #ifdef TEST_NEED_COLLECTION void __collection_activated() {} void __collection_add() {} +void __collection_keypress() {} void __collection_selection_changed() {} void __collection_toggled() {} #endif /* TEST_NEED_COLLECTION */ diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 5ab562c1..448c473e 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -283,8 +283,8 @@ media-skip-backward - + False @@ -318,8 +318,8 @@ 5 - + False @@ -352,8 +352,8 @@ 5 - + False @@ -386,8 +386,8 @@ media-playback-stop - + False @@ -420,8 +420,8 @@ media-skip-forward - + False @@ -627,6 +627,7 @@ False 10 True +