Skip to content

Commit

Permalink
gtkui: undo/redo hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksiy-Yakovenko committed Feb 2, 2024
1 parent bff2c9a commit 05eb6be
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
13 changes: 13 additions & 0 deletions plugins/gtkui/actionhandlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
6 changes: 6 additions & 0 deletions plugins/gtkui/actionhandlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 17 additions & 1 deletion plugins/gtkui/gtkui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions plugins/gtkui/hotkeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
}

Expand Down

0 comments on commit 05eb6be

Please sign in to comment.