diff options
author | 2013-10-27 18:49:16 +0100 | |
---|---|---|
committer | 2013-10-27 18:49:16 +0100 | |
commit | 476bb04cbbacee2d68bbe3e66de9a948e643f4eb (patch) | |
tree | 078889eac47b97ded2dfafdec4b63d92c5017637 /plugins | |
parent | 7112a75378eae33fafb114cc7b8efafa2abc0d39 (diff) |
gtkui: automatically import global hotkeys from 0.5, fixed initializing hotkeys on 1st run
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gtkui/gtkui.c | 6 | ||||
-rw-r--r-- | plugins/gtkui/hotkeys.c | 26 | ||||
-rw-r--r-- | plugins/gtkui/hotkeys.h | 3 |
3 files changed, 35 insertions, 0 deletions
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index a590d51d..5bf06308 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -61,6 +61,7 @@ #endif #include "actionhandlers.h" #include "hotkeys.h" +#include "../hotkeys/hotkeys.h" #define trace(...) { fprintf(stderr, __VA_ARGS__); } //#define trace(fmt,...) @@ -995,6 +996,11 @@ gtkui_thread (void *ctx) { // check if any hotkeys were created manually (e.g. beta versions of 0.6) if (!deadbeef->conf_find ("hotkey.key", NULL)) { gtkui_set_default_hotkeys (); + gtkui_import_0_5_global_hotkeys (); + DB_plugin_t *hkplug = deadbeef->plug_get_for_id ("hotkeys"); + if (hkplug) { + ((DB_hotkeys_plugin_t *)hkplug)->reset (); + } } deadbeef->conf_set_int ("hotkeys_created", 1); deadbeef->conf_save (); diff --git a/plugins/gtkui/hotkeys.c b/plugins/gtkui/hotkeys.c index 56b98574..33bf01e2 100644 --- a/plugins/gtkui/hotkeys.c +++ b/plugins/gtkui/hotkeys.c @@ -925,3 +925,29 @@ gtkui_set_default_hotkeys (void) { deadbeef->conf_save (); } +void +gtkui_import_0_5_global_hotkeys (void) { + int n = 40; + deadbeef->conf_lock (); + DB_conf_item_t *item = deadbeef->conf_find ("hotkeys.key", NULL); + while (item) { + char *val = strdupa (item->value); + char *colon = strchr (val, ':'); + if (colon) { + *colon++ = 0; + while (*colon && *colon == ' ') { + colon++; + } + if (*colon) { + char newkey[100]; + char newval[100]; + snprintf (newkey, sizeof (newkey), "hotkey.key%02d", n); + snprintf (newval, sizeof (newval), "\"%s\" 0 1 %s", val, colon); + deadbeef->conf_set_str (newkey, newval); + n++; + } + } + item = deadbeef->conf_find ("hotkeys.", item); + } + deadbeef->conf_unlock (); +} diff --git a/plugins/gtkui/hotkeys.h b/plugins/gtkui/hotkeys.h index ddbe27c7..4b03967e 100644 --- a/plugins/gtkui/hotkeys.h +++ b/plugins/gtkui/hotkeys.h @@ -41,5 +41,8 @@ set_button_action_label (const char *act, int action_ctx, GtkWidget *button); void gtkui_set_default_hotkeys (void); +void +gtkui_import_0_5_global_hotkeys (void); + #endif // __GTKUI_HOTKEYS_H |