Skip to content

Commit e3bc87b

Browse files
committed
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
1 parent b542aa1 commit e3bc87b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/bin/clapper-app/clapper-app-application.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,23 @@ add_uri (GSimpleAction *action, GVariant *param, gpointer user_data)
333333
clapper_app_uri_dialog_open_uri (gtk_app);
334334
}
335335

336+
static void
337+
clear_queue (GSimpleAction *action, GVariant *param, gpointer user_data)
338+
{
339+
GtkApplication *gtk_app = GTK_APPLICATION (user_data);
340+
GtkWindow *window = gtk_application_get_active_window (gtk_app);
341+
ClapperPlayer *player;
342+
ClapperQueue *queue;
343+
344+
while (window && !CLAPPER_APP_IS_WINDOW (window))
345+
window = gtk_window_get_transient_for (window);
346+
347+
player = clapper_app_window_get_player (CLAPPER_APP_WINDOW (window));
348+
queue = clapper_player_get_queue (player);
349+
350+
clapper_queue_clear (queue);
351+
}
352+
336353
static void
337354
new_window (GSimpleAction *action, GVariant *param, gpointer user_data)
338355
{
@@ -692,6 +709,7 @@ clapper_app_application_constructed (GObject *object)
692709
static const GActionEntry app_actions[] = {
693710
{ "add-files", add_files, NULL, NULL, NULL },
694711
{ "add-uri", add_uri, NULL, NULL, NULL },
712+
{ "clear-queue", clear_queue, NULL, NULL, NULL },
695713
{ "new-window", new_window, NULL, NULL, NULL },
696714
{ "info", show_info, NULL, NULL, NULL },
697715
{ "preferences", show_preferences, NULL, NULL, NULL },

src/bin/clapper-app/ui/clapper-app-queue-list.ui

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,11 @@
183183
<attribute name="action">app.add-uri</attribute>
184184
</item>
185185
</section>
186+
<section>
187+
<item>
188+
<attribute name="label" translatable="yes">Clear Queue</attribute>
189+
<attribute name="action">app.clear-queue</attribute>
190+
</item>
191+
</section>
186192
</menu>
187193
</interface>

0 commit comments

Comments
 (0)