From 0e9e6e3d073c5b034568ba3c7f6f85e7197628cc Mon Sep 17 00:00:00 2001 From: waker Date: Sat, 24 Nov 2012 14:22:12 +0100 Subject: gtkui: added hotkeys for switching to playlist1-10; removed old play_random hardcoded hotkey --- plugins/gtkui/callbacks.c | 14 ------ plugins/gtkui/gtkui.c | 10 ++++ plugins/hotkeys/actionhandlers.c | 101 +++++++++++++++++++++++++++++++++++++++ plugins/hotkeys/actionhandlers.h | 30 ++++++++++++ plugins/hotkeys/hotkeys.c | 86 +++++++++++++++++++++++++++++++-- 5 files changed, 224 insertions(+), 17 deletions(-) diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 24eeef9f..dae393a4 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -211,20 +211,6 @@ on_mainwin_key_press_event (GtkWidget *widget, } trace ("action not found\n"); - uint32_t maskedstate = (event->state &~ (GDK_LOCK_MASK | GDK_MOD2_MASK | GDK_MOD3_MASK | GDK_MOD5_MASK)) & 0xfff; - if ((maskedstate == GDK_MOD1_MASK || maskedstate == 0) && event->keyval == GDK_n) { - // button for that one is not in toolbar anymore, so handle it manually - deadbeef->sendmessage (DB_EV_PLAY_RANDOM, 0, 0, 0); - return TRUE; - } - else if ((maskedstate == GDK_MOD1_MASK || maskedstate == 0) && event->keyval >= GDK_1 && event->keyval <= GDK_9) { - int pl = event->keyval - GDK_1; - if (pl >= 0 && pl < deadbeef->plt_get_count ()) { - deadbeef->plt_set_curr_idx (pl); - deadbeef->conf_set_int ("playlist.current", pl); - } - return TRUE; - } return FALSE; } diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index adfb4869..f003be37 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -949,6 +949,16 @@ gtkui_thread (void *ctx) { deadbeef->conf_set_str ("hotkey.key11", "\"Ctrl w\" 0 0 remove_current_playlist"); deadbeef->conf_set_str ("hotkey.key14", "\"Return\" 0 0 play"); deadbeef->conf_set_str ("hotkey.key15", "\"Ctrl p\" 0 0 toggle_pause"); + deadbeef->conf_set_str ("hotkey.key16", "\"Alt 1\" 0 0 playlist1"); + deadbeef->conf_set_str ("hotkey.key17", "\"Alt 2\" 0 0 playlist2"); + deadbeef->conf_set_str ("hotkey.key18", "\"Alt 3\" 0 0 playlist3"); + deadbeef->conf_set_str ("hotkey.key19", "\"Alt 4\" 0 0 playlist4"); + deadbeef->conf_set_str ("hotkey.key20", "\"Alt 5\" 0 0 playlist5"); + deadbeef->conf_set_str ("hotkey.key21", "\"Alt 6\" 0 0 playlist6"); + deadbeef->conf_set_str ("hotkey.key22", "\"Alt 7\" 0 0 playlist7"); + deadbeef->conf_set_str ("hotkey.key23", "\"Alt 8\" 0 0 playlist8"); + deadbeef->conf_set_str ("hotkey.key24", "\"Alt 9\" 0 0 playlist9"); + deadbeef->conf_set_str ("hotkey.key25", "\"Alt 0\" 0 0 playlist10"); } // construct mainwindow widgets diff --git a/plugins/hotkeys/actionhandlers.c b/plugins/hotkeys/actionhandlers.c index 72e3f3cb..c1d49b26 100644 --- a/plugins/hotkeys/actionhandlers.c +++ b/plugins/hotkeys/actionhandlers.c @@ -94,3 +94,104 @@ action_prev_playlist_handler (DB_plugin_action_t *act, int ctx) { } return 0; } + +int +action_playlist1_handler (DB_plugin_action_t *act, int ctx) { + int pl = 0; + if (pl < deadbeef->plt_get_count ()) { + deadbeef->plt_set_curr_idx (pl); + deadbeef->conf_set_int ("playlist.current", pl); + } + return 0; +} + +int +action_playlist2_handler (DB_plugin_action_t *act, int ctx) { + int pl = 1; + if (pl < deadbeef->plt_get_count ()) { + deadbeef->plt_set_curr_idx (pl); + deadbeef->conf_set_int ("playlist.current", pl); + } + return 0; +} + +int +action_playlist3_handler (DB_plugin_action_t *act, int ctx) { + int pl = 2; + if (pl < deadbeef->plt_get_count ()) { + deadbeef->plt_set_curr_idx (pl); + deadbeef->conf_set_int ("playlist.current", pl); + } + return 0; +} + +int +action_playlist4_handler (DB_plugin_action_t *act, int ctx) { + int pl = 3; + if (pl < deadbeef->plt_get_count ()) { + deadbeef->plt_set_curr_idx (pl); + deadbeef->conf_set_int ("playlist.current", pl); + } + return 0; +} + +int +action_playlist5_handler (DB_plugin_action_t *act, int ctx) { + int pl = 4; + if (pl < deadbeef->plt_get_count ()) { + deadbeef->plt_set_curr_idx (pl); + deadbeef->conf_set_int ("playlist.current", pl); + } + return 0; +} + +int +action_playlist6_handler (DB_plugin_action_t *act, int ctx) { + int pl = 5; + if (pl < deadbeef->plt_get_count ()) { + deadbeef->plt_set_curr_idx (pl); + deadbeef->conf_set_int ("playlist.current", pl); + } + return 0; +} + +int +action_playlist7_handler (DB_plugin_action_t *act, int ctx) { + int pl = 6; + if (pl < deadbeef->plt_get_count ()) { + deadbeef->plt_set_curr_idx (pl); + deadbeef->conf_set_int ("playlist.current", pl); + } + return 0; +} + +int +action_playlist8_handler (DB_plugin_action_t *act, int ctx) { + int pl = 7; + if (pl < deadbeef->plt_get_count ()) { + deadbeef->plt_set_curr_idx (pl); + deadbeef->conf_set_int ("playlist.current", pl); + } + return 0; +} + +int +action_playlist9_handler (DB_plugin_action_t *act, int ctx) { + int pl = 8; + if (pl < deadbeef->plt_get_count ()) { + deadbeef->plt_set_curr_idx (pl); + deadbeef->conf_set_int ("playlist.current", pl); + } + return 0; +} + +int +action_playlist10_handler (DB_plugin_action_t *act, int ctx) { + int pl = 9; + if (pl < deadbeef->plt_get_count ()) { + deadbeef->plt_set_curr_idx (pl); + deadbeef->conf_set_int ("playlist.current", pl); + } + return 0; +} + diff --git a/plugins/hotkeys/actionhandlers.h b/plugins/hotkeys/actionhandlers.h index 20f7f660..a8fde362 100644 --- a/plugins/hotkeys/actionhandlers.h +++ b/plugins/hotkeys/actionhandlers.h @@ -36,4 +36,34 @@ action_next_playlist_handler (DB_plugin_action_t *act, int ctx); int action_prev_playlist_handler (DB_plugin_action_t *act, int ctx); +int +action_playlist1_handler (DB_plugin_action_t *act, int ctx); + +int +action_playlist2_handler (DB_plugin_action_t *act, int ctx); + +int +action_playlist3_handler (DB_plugin_action_t *act, int ctx); + +int +action_playlist4_handler (DB_plugin_action_t *act, int ctx); + +int +action_playlist5_handler (DB_plugin_action_t *act, int ctx); + +int +action_playlist6_handler (DB_plugin_action_t *act, int ctx); + +int +action_playlist7_handler (DB_plugin_action_t *act, int ctx); + +int +action_playlist8_handler (DB_plugin_action_t *act, int ctx); + +int +action_playlist9_handler (DB_plugin_action_t *act, int ctx); + +int +action_playlist10_handler (DB_plugin_action_t *act, int ctx); + #endif diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c index 676e9a13..624e4e62 100644 --- a/plugins/hotkeys/hotkeys.c +++ b/plugins/hotkeys/hotkeys.c @@ -713,7 +713,7 @@ static DB_plugin_action_t action_jump_to_current = { static DB_plugin_action_t action_next_playlist = { .title = "Edit/Next playlist", - .name = "sort_next_playlist", + .name = "next_playlist", .flags = DB_ACTION_COMMON, .callback = action_next_playlist_handler, .next = &action_jump_to_current @@ -721,18 +721,98 @@ static DB_plugin_action_t action_next_playlist = { static DB_plugin_action_t action_prev_playlist = { .title = "Edit/Prev playlist", - .name = "sort_prev_playlist", + .name = "prev_playlist", .flags = DB_ACTION_COMMON, .callback = action_prev_playlist_handler, .next = &action_next_playlist }; +static DB_plugin_action_t action_playlist10 = { + .title = "Edit/Switch to playlist 10", + .name = "playlist10", + .flags = DB_ACTION_COMMON, + .callback = action_playlist10_handler, + .next = &action_prev_playlist +}; + +static DB_plugin_action_t action_playlist9 = { + .title = "Edit/Switch to playlist 9", + .name = "playlist9", + .flags = DB_ACTION_COMMON, + .callback = action_playlist9_handler, + .next = &action_playlist10 +}; + +static DB_plugin_action_t action_playlist8 = { + .title = "Edit/Switch to playlist 8", + .name = "playlist8", + .flags = DB_ACTION_COMMON, + .callback = action_playlist8_handler, + .next = &action_playlist9 +}; + +static DB_plugin_action_t action_playlist7 = { + .title = "Edit/Switch to playlist 7", + .name = "playlist7", + .flags = DB_ACTION_COMMON, + .callback = action_playlist7_handler, + .next = &action_playlist8 +}; + +static DB_plugin_action_t action_playlist6 = { + .title = "Edit/Switch to playlist 6", + .name = "playlist6", + .flags = DB_ACTION_COMMON, + .callback = action_playlist6_handler, + .next = &action_playlist7 +}; + +static DB_plugin_action_t action_playlist5 = { + .title = "Edit/Switch to playlist 5", + .name = "playlist5", + .flags = DB_ACTION_COMMON, + .callback = action_playlist5_handler, + .next = &action_playlist6 +}; + +static DB_plugin_action_t action_playlist4 = { + .title = "Edit/Switch to playlist 4", + .name = "playlist4", + .flags = DB_ACTION_COMMON, + .callback = action_playlist4_handler, + .next = &action_playlist5 +}; + +static DB_plugin_action_t action_playlist3 = { + .title = "Edit/Switch to playlist 3", + .name = "playlist3", + .flags = DB_ACTION_COMMON, + .callback = action_playlist3_handler, + .next = &action_playlist4 +}; + +static DB_plugin_action_t action_playlist2 = { + .title = "Edit/Switch to playlist 2", + .name = "playlist2", + .flags = DB_ACTION_COMMON, + .callback = action_playlist2_handler, + .next = &action_playlist3 +}; + +static DB_plugin_action_t action_playlist1 = { + .title = "Edit/Switch to playlist 1", + .name = "playlist1", + .flags = DB_ACTION_COMMON, + .callback = action_playlist1_handler, + .next = &action_playlist2 +}; + static DB_plugin_action_t action_sort_randomize = { .title = "Edit/[stub] Sort Randomize", .name = "sort_randomize", .flags = DB_ACTION_COMMON, .callback = NULL, - .next = &action_prev_playlist + .next = &action_playlist1 }; static DB_plugin_action_t action_sort_by_date = { -- cgit v1.2.3