summaryrefslogtreecommitdiff
path: root/plugins/hotkeys
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-11-24 15:03:55 +0100
committerGravatar waker <wakeroid@gmail.com>2012-11-24 15:03:55 +0100
commitc1c82b6fe08560ce955afbcbcc4c9d0c9a49d0e6 (patch)
treec096fb7d3b230225ac1e2bcb932b0a54284cec21 /plugins/hotkeys
parent6176a514259311e49273a7f422885cd6561af138 (diff)
added clear playlist and invert selection hotkeys
Diffstat (limited to 'plugins/hotkeys')
-rw-r--r--plugins/hotkeys/actionhandlers.c30
-rw-r--r--plugins/hotkeys/actionhandlers.h7
-rw-r--r--plugins/hotkeys/hotkeys.c8
3 files changed, 41 insertions, 4 deletions
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
};