From e3bc87ba119034979006544c2bcc8f6331141580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sat, 11 Jan 2025 15:17:44 +0100 Subject: [PATCH] clapper-app: Add "Clear Queue" menu option An option to clear playback queue from UI. This is quckier and easier than manually dragging every item to bin. Closes #434 --- src/bin/clapper-app/clapper-app-application.c | 18 ++++++++++++++++++ .../clapper-app/ui/clapper-app-queue-list.ui | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index 703d8dec..0e5ab8ba 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -333,6 +333,23 @@ add_uri (GSimpleAction *action, GVariant *param, gpointer user_data) clapper_app_uri_dialog_open_uri (gtk_app); } +static void +clear_queue (GSimpleAction *action, GVariant *param, gpointer user_data) +{ + GtkApplication *gtk_app = GTK_APPLICATION (user_data); + GtkWindow *window = gtk_application_get_active_window (gtk_app); + ClapperPlayer *player; + ClapperQueue *queue; + + while (window && !CLAPPER_APP_IS_WINDOW (window)) + window = gtk_window_get_transient_for (window); + + player = clapper_app_window_get_player (CLAPPER_APP_WINDOW (window)); + queue = clapper_player_get_queue (player); + + clapper_queue_clear (queue); +} + static void new_window (GSimpleAction *action, GVariant *param, gpointer user_data) { @@ -692,6 +709,7 @@ clapper_app_application_constructed (GObject *object) static const GActionEntry app_actions[] = { { "add-files", add_files, NULL, NULL, NULL }, { "add-uri", add_uri, NULL, NULL, NULL }, + { "clear-queue", clear_queue, NULL, NULL, NULL }, { "new-window", new_window, NULL, NULL, NULL }, { "info", show_info, NULL, NULL, NULL }, { "preferences", show_preferences, NULL, NULL, NULL }, diff --git a/src/bin/clapper-app/ui/clapper-app-queue-list.ui b/src/bin/clapper-app/ui/clapper-app-queue-list.ui index 20b9f7db..577adad4 100644 --- a/src/bin/clapper-app/ui/clapper-app-queue-list.ui +++ b/src/bin/clapper-app/ui/clapper-app-queue-list.ui @@ -183,5 +183,11 @@ app.add-uri +
+ + Clear Queue + app.clear-queue + +