From c1c82b6fe08560ce955afbcbcc4c9d0c9a49d0e6 Mon Sep 17 00:00:00 2001 From: waker Date: Sat, 24 Nov 2012 15:03:55 +0100 Subject: added clear playlist and invert selection hotkeys --- plugins/hotkeys/actionhandlers.c | 30 ++++++++++++++++++++++++++++++ plugins/hotkeys/actionhandlers.h | 7 +++++++ plugins/hotkeys/hotkeys.c | 8 ++++---- 3 files changed, 41 insertions(+), 4 deletions(-) (limited to 'plugins/hotkeys') diff --git a/plugins/hotkeys/actionhandlers.c b/plugins/hotkeys/actionhandlers.c index ec1f305c..ec8e00b5 100644 --- a/plugins/hotkeys/actionhandlers.c +++ b/plugins/hotkeys/actionhandlers.c @@ -248,3 +248,33 @@ action_sort_by_title_handler (DB_plugin_action_t *act, int ctx) { deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); return 0; } + +int +action_invert_selection_handler (DB_plugin_action_t *act, int ctx) { + deadbeef->pl_lock (); + DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN); + while (it) { + if (deadbeef->pl_is_selected (it)) { + deadbeef->pl_set_selected (it, 0); + } + else { + deadbeef->pl_set_selected (it, 1); + } + DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN); + deadbeef->pl_item_unref (it); + it = next; + } + deadbeef->pl_unlock (); + deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); + return 0; +} + +int +action_clear_playlist_handler (DB_plugin_action_t *act, int ctx) { + deadbeef->pl_clear (); + deadbeef->pl_save_current (); + deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); + return 0; +} + + diff --git a/plugins/hotkeys/actionhandlers.h b/plugins/hotkeys/actionhandlers.h index d18d4f25..b1f65db2 100644 --- a/plugins/hotkeys/actionhandlers.h +++ b/plugins/hotkeys/actionhandlers.h @@ -83,4 +83,11 @@ action_sort_by_tracknr_handler (DB_plugin_action_t *act, int ctx); int action_sort_by_title_handler (DB_plugin_action_t *act, int ctx); + +int +action_invert_selection_handler (DB_plugin_action_t *act, int ctx); + +int +action_clear_playlist_handler (DB_plugin_action_t *act, int ctx); + #endif diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c index af3065d0..b4cc9327 100644 --- a/plugins/hotkeys/hotkeys.c +++ b/plugins/hotkeys/hotkeys.c @@ -857,18 +857,18 @@ static DB_plugin_action_t action_sort_by_title = { }; static DB_plugin_action_t action_invert_selection = { - .title = "Edit/[stub] Invert Selection", + .title = "Edit/Invert Selection", .name = "invert_selection", .flags = DB_ACTION_COMMON, - .callback = NULL, + .callback = action_invert_selection_handler, .next = &action_sort_by_tracknr }; static DB_plugin_action_t action_clear_playlist = { - .title = "Edit/[stub] Clear playlist", + .title = "Edit/Clear playlist", .name = "clear_playlist", .flags = DB_ACTION_COMMON, - .callback = NULL, + .callback = action_clear_playlist_handler, .next = &action_invert_selection }; -- cgit v1.2.3