diff options
author | waker <wakeroid@gmail.com> | 2012-11-24 14:58:22 +0100 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2012-11-24 14:58:22 +0100 |
commit | 6176a514259311e49273a7f422885cd6561af138 (patch) | |
tree | 67b4170e8c440be6f22b033edfa6aa33a077a83b /plugins/hotkeys | |
parent | 0e9e6e3d073c5b034568ba3c7f6f85e7197628cc (diff) |
added sorting hotkeys
Diffstat (limited to 'plugins/hotkeys')
-rw-r--r-- | plugins/hotkeys/actionhandlers.c | 53 | ||||
-rw-r--r-- | plugins/hotkeys/actionhandlers.h | 17 | ||||
-rw-r--r-- | plugins/hotkeys/hotkeys.c | 24 |
3 files changed, 82 insertions, 12 deletions
diff --git a/plugins/hotkeys/actionhandlers.c b/plugins/hotkeys/actionhandlers.c index c1d49b26..ec1f305c 100644 --- a/plugins/hotkeys/actionhandlers.c +++ b/plugins/hotkeys/actionhandlers.c @@ -195,3 +195,56 @@ action_playlist10_handler (DB_plugin_action_t *act, int ctx) { return 0; } +int +action_sort_randomize_handler (DB_plugin_action_t *act, int ctx) { + ddb_playlist_t *plt = deadbeef->plt_get_curr (); + deadbeef->plt_sort (plt, PL_MAIN, -1, NULL, DDB_SORT_RANDOM); + deadbeef->plt_unref (plt); + deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); + return 0; +} + +int +action_sort_by_date_handler (DB_plugin_action_t *act, int ctx) { + ddb_playlist_t *plt = deadbeef->plt_get_curr (); + deadbeef->plt_sort (plt, PL_MAIN, -1, "%y", DDB_SORT_ASCENDING); + deadbeef->plt_unref (plt); + deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); + return 0; +} + +int +action_sort_by_artist_handler (DB_plugin_action_t *act, int ctx) { + ddb_playlist_t *plt = deadbeef->plt_get_curr (); + deadbeef->plt_sort (plt, PL_MAIN, -1, "%a", DDB_SORT_ASCENDING); + deadbeef->plt_unref (plt); + deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); + return 0; +} + +int +action_sort_by_album_handler (DB_plugin_action_t *act, int ctx) { + ddb_playlist_t *plt = deadbeef->plt_get_curr (); + deadbeef->plt_sort (plt, PL_MAIN, -1, "%b", DDB_SORT_ASCENDING); + deadbeef->plt_unref (plt); + deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); + return 0; +} + +int +action_sort_by_tracknr_handler (DB_plugin_action_t *act, int ctx) { + ddb_playlist_t *plt = deadbeef->plt_get_curr (); + deadbeef->plt_sort (plt, PL_MAIN, -1, "%n", DDB_SORT_ASCENDING); + deadbeef->plt_unref (plt); + deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); + return 0; +} + +int +action_sort_by_title_handler (DB_plugin_action_t *act, int ctx) { + ddb_playlist_t *plt = deadbeef->plt_get_curr (); + deadbeef->plt_sort (plt, PL_MAIN, -1, "%t", DDB_SORT_ASCENDING); + deadbeef->plt_unref (plt); + deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0); + return 0; +} diff --git a/plugins/hotkeys/actionhandlers.h b/plugins/hotkeys/actionhandlers.h index a8fde362..d18d4f25 100644 --- a/plugins/hotkeys/actionhandlers.h +++ b/plugins/hotkeys/actionhandlers.h @@ -66,4 +66,21 @@ action_playlist9_handler (DB_plugin_action_t *act, int ctx); int action_playlist10_handler (DB_plugin_action_t *act, int ctx); +int +action_sort_randomize_handler (DB_plugin_action_t *act, int ctx); + +int +action_sort_by_date_handler (DB_plugin_action_t *act, int ctx); + +int +action_sort_by_artist_handler (DB_plugin_action_t *act, int ctx); + +int +action_sort_by_album_handler (DB_plugin_action_t *act, int ctx); + +int +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); #endif diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c index 624e4e62..af3065d0 100644 --- a/plugins/hotkeys/hotkeys.c +++ b/plugins/hotkeys/hotkeys.c @@ -808,51 +808,51 @@ static DB_plugin_action_t action_playlist1 = { }; static DB_plugin_action_t action_sort_randomize = { - .title = "Edit/[stub] Sort Randomize", + .title = "Edit/Sort Randomize", .name = "sort_randomize", .flags = DB_ACTION_COMMON, - .callback = NULL, + .callback = action_sort_randomize_handler, .next = &action_playlist1 }; static DB_plugin_action_t action_sort_by_date = { - .title = "Edit/[stub] Sort by date", + .title = "Edit/Sort by date", .name = "sort_date", .flags = DB_ACTION_COMMON, - .callback = NULL, + .callback = action_sort_by_date_handler, .next = &action_sort_randomize }; static DB_plugin_action_t action_sort_by_artist = { - .title = "Edit/[stub] Sort by artist", + .title = "Edit/Sort by artist", .name = "sort_artist", .flags = DB_ACTION_COMMON, - .callback = NULL, + .callback = action_sort_by_artist_handler, .next = &action_sort_by_date }; static DB_plugin_action_t action_sort_by_album = { - .title = "Edit/[stub] Sort by album", + .title = "Edit/Sort by album", .name = "sort_album", .flags = DB_ACTION_COMMON, - .callback = NULL, + .callback = action_sort_by_album_handler, .next = &action_sort_by_artist }; static DB_plugin_action_t action_sort_by_tracknr = { - .title = "Edit/[stub] Sort by track number", + .title = "Edit/Sort by track number", .name = "sort_tracknr", .flags = DB_ACTION_COMMON, - .callback = NULL, + .callback = action_sort_by_tracknr_handler, .next = &action_sort_by_album }; static DB_plugin_action_t action_sort_by_title = { - .title = "Edit/[stub] Sort by title", + .title = "Edit/Sort by title", .name = "sort_title", .flags = DB_ACTION_COMMON, - .callback = NULL, + .callback = action_sort_by_title_handler, .next = &action_sort_by_tracknr }; |