diff --git a/gui/playlist.c b/gui/playlist.c index 804a04ea..af5fcd5a 100644 --- a/gui/playlist.c +++ b/gui/playlist.c @@ -112,6 +112,35 @@ gboolean __playlist_on_select(GtkTreeSelection *selection, GtkTreeModel *model, return queue != NULL; } +bool __playlist_keypress(GtkTreeView *treeview, GdkEventKey *event, + gpointer data) +{ + GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); + GtkTreeModel *model = GTK_TREE_MODEL(p_store); + gchar *name = NULL; + GtkTreePath *path; + GtkTreeIter iter; + GList *rows; + + if (event->keyval != GDK_KEY_Delete) + return false; + + rows = gtk_tree_selection_get_selected_rows(selection, &model); + path = rows->data; + + if (gtk_tree_model_get_iter(model, &iter, path)) + name = __playlist_name(&iter); + if (!name) + goto out; + + if (playlist_delete(__playlist_type(&iter), name)) + gtk_tree_store_remove(GTK_TREE_STORE(model), &iter); + g_free(name); +out: + g_list_free_full(rows, (GDestroyNotify)gtk_tree_path_free); + return true; +} + static bool __playlist_queue_set_size(struct queue *queue, GtkTreeIter *iter) { struct gui_queue *gq = gui_queue(queue); diff --git a/include/tests/gui.h b/include/tests/gui.h index 8cf55be8..38a53afe 100644 --- a/include/tests/gui.h +++ b/include/tests/gui.h @@ -31,6 +31,7 @@ void __collection_toggled() {} #endif /* TEST_NEED_COLLECTION */ #ifdef TEST_NEED_PLAYLIST +void __playlist_keypress() {} void __playlist_selection_changed() {} #endif /* TEST_NEED_PLAYLIST */ diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 03a8c450..a8ba14b3 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -954,6 +954,7 @@ False 1 True +