From 476bb04cbbacee2d68bbe3e66de9a948e643f4eb Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sun, 27 Oct 2013 18:49:16 +0100 Subject: gtkui: automatically import global hotkeys from 0.5, fixed initializing hotkeys on 1st run --- plugins/gtkui/hotkeys.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'plugins/gtkui/hotkeys.c') 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 (); +} -- cgit v1.2.3