From 05eb6be614f0c07dc998f4458c569b76d70cb546 Mon Sep 17 00:00:00 2001 From: Oleksiy Yakovenko Date: Fri, 2 Feb 2024 17:34:56 +0100 Subject: [PATCH] gtkui: undo/redo hotkeys --- plugins/gtkui/actionhandlers.c | 13 +++++++++++++ plugins/gtkui/actionhandlers.h | 6 ++++++ plugins/gtkui/gtkui.c | 18 +++++++++++++++++- plugins/gtkui/hotkeys.c | 2 ++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/plugins/gtkui/actionhandlers.c b/plugins/gtkui/actionhandlers.c index 6065162b06..69547ede2a 100644 --- a/plugins/gtkui/actionhandlers.c +++ b/plugins/gtkui/actionhandlers.c @@ -45,6 +45,7 @@ #include "support.h" #include "trkproperties.h" #include "wingeom.h" +#include "undo.h" // disable custom title function, until we have new title formatting (0.7) #define DISABLE_CUSTOM_TITLE @@ -856,3 +857,15 @@ action_toggle_logwindow_handler(DB_plugin_action_t *act, ddb_action_context_t ct g_idle_add (action_toggle_logwindow_handler_cb, NULL); return 0; } + +int +action_undo(DB_plugin_action_t *act, ddb_action_context_t ctx) { + gtkui_perform_undo(); + return 0; +} + +int +action_redo(DB_plugin_action_t *act, ddb_action_context_t ctx) { + gtkui_perform_redo(); + return 0; +} diff --git a/plugins/gtkui/actionhandlers.h b/plugins/gtkui/actionhandlers.h index eb34ef0fb8..c286c532de 100644 --- a/plugins/gtkui/actionhandlers.h +++ b/plugins/gtkui/actionhandlers.h @@ -218,4 +218,10 @@ action_playback_loop_cycle_handler(DB_plugin_action_t *act, ddb_action_context_t int action_toggle_logwindow_handler(DB_plugin_action_t *act, ddb_action_context_t ctx); +int +action_undo(DB_plugin_action_t *act, ddb_action_context_t ctx); + +int +action_redo(DB_plugin_action_t *act, ddb_action_context_t ctx); + #endif diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 2de972facf..f5d2475936 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -2201,9 +2201,25 @@ static DB_plugin_action_t action_view_log = { .title = "View/Show\\/Hide Log win .callback2 = action_toggle_logwindow_handler, .next = &action_find }; +static DB_plugin_action_t action_edit_undo = { + .title = "Edit/Undo", + .name = "undo", + .flags = DB_ACTION_COMMON, + .callback2 = action_undo, + .next = &action_view_log +}; + +static DB_plugin_action_t action_edit_redo = { + .title = "Edit/Redo", + .name = "redo", + .flags = DB_ACTION_COMMON, + .callback2 = action_redo, + .next = &action_edit_undo +}; + static DB_plugin_action_t * gtkui_get_actions (DB_playItem_t *it) { - return &action_view_log; + return &action_edit_redo; } #if !GTK_CHECK_VERSION(3, 0, 0) diff --git a/plugins/gtkui/hotkeys.c b/plugins/gtkui/hotkeys.c index 9038c7fe7e..90cea2b923 100644 --- a/plugins/gtkui/hotkeys.c +++ b/plugins/gtkui/hotkeys.c @@ -929,6 +929,8 @@ gtkui_set_default_hotkeys (void) { deadbeef->conf_set_str ("hotkey.key30", "b 0 0 next"); deadbeef->conf_set_str ("hotkey.key31", "n 0 0 playback_random"); deadbeef->conf_set_str ("hotkey.key32", "\"Ctrl k\" 0 0 toggle_stop_after_album"); + deadbeef->conf_set_str ("hotkey.key33", "\"Ctrl z\" 0 0 undo"); + deadbeef->conf_set_str ("hotkey.key34", "\"Ctrl Shift z\" 0 0 redo"); deadbeef->conf_save (); }