summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-07-31 15:01:56 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-07-31 15:01:56 +0200
commitbbe6cfdd9da8d03946c36e6ca287a6c0af9e0268 (patch)
tree356037d077e69c52f4b01211d56f405e887fead1 /plugins
parentb81f1e28ce52187df2a8d29abc9d6e81981b042b (diff)
allow forward slash in plugin action titles via \/
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/actions.c26
-rw-r--r--plugins/gtkui/prefwin.c46
-rw-r--r--plugins/hotkeys/hotkeys.c2
3 files changed, 45 insertions, 29 deletions
diff --git a/plugins/gtkui/actions.c b/plugins/gtkui/actions.c
index 4f6b977b..05dd666d 100644
--- a/plugins/gtkui/actions.c
+++ b/plugins/gtkui/actions.c
@@ -19,6 +19,7 @@
*/
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include "gtkui.h"
#include "../../deadbeef.h"
@@ -50,15 +51,25 @@ add_mainmenu_actions (GtkWidget *mainwin)
for (action = actions; action; action = action->next)
{
+ char *tmp = NULL;
if (0 == (action->flags & DB_ACTION_COMMON))
continue;
- //We won't add item directly to main menu
- if (!strchr (action->title, '/'))
+ // 1st check if we have slashes
+ const char *slash = action->title;
+ while (NULL != (slash = strchr (slash, '/'))) {
+ if (slash && slash > action->title && *(slash-1) == '\\') {
+ slash++;
+ continue;
+ }
+ break;
+ }
+ if (!slash) {
continue;
+ }
- char *tmp;
char *ptr = tmp = strdup (action->title);
+
char *prev_title = NULL;
GtkWidget *current = mainwin;
@@ -66,7 +77,13 @@ add_mainmenu_actions (GtkWidget *mainwin)
while (1)
{
+ // find unescaped forward slash
char *slash = strchr (ptr, '/');
+ if (slash && slash > ptr && *(slash-1) == '\\') {
+ ptr = slash + 1;
+ continue;
+ }
+
if (!slash)
{
GtkWidget *actionitem;
@@ -112,6 +129,9 @@ add_mainmenu_actions (GtkWidget *mainwin)
prev_title = ptr;
ptr = slash + 1;
}
+ if (tmp) {
+ free (tmp);
+ }
}
}
}
diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c
index 2f0618cf..69b25a0f 100644
--- a/plugins/gtkui/prefwin.c
+++ b/plugins/gtkui/prefwin.c
@@ -260,6 +260,21 @@ prefwin_init_theme_colors (void) {
gtk_color_button_set_color (GTK_COLOR_BUTTON (lookup_widget (prefwin, "listview_cursor")), (gtkui_get_listview_cursor_color (&clr), &clr));
}
+static void
+unescape_forward_slash (const char *src, char *dst, int size) {
+ char *start = dst;
+ while (*src) {
+ if (dst - start >= size - 1) {
+ break;
+ }
+ if (*src == '\\' && *(src+1) == '/') {
+ src++;
+ }
+ *dst++ = *src++;
+ }
+ *dst = 0;
+}
+
// this should be in separate plugin
void
prefwin_add_hotkeys_tab (GtkWidget *prefwin) {
@@ -320,30 +335,7 @@ prefwin_add_hotkeys_tab (GtkWidget *prefwin) {
g_signal_connect ((gpointer)addhotkey, "clicked", G_CALLBACK (on_addhotkey_clicked), hkstore);
g_signal_connect ((gpointer)removehotkey, "clicked", G_CALLBACK (on_removehotkey_clicked), hktree);
-#if 0
- const char *slots[] = {
- "toggle_pause",
- "play",
- "prev",
- "next",
- "stop",
- "play_random",
- "seek_fwd",
- "seek_back",
- "volume_up",
- "volume_down",
- "toggle_stop_after_current",
- NULL
- };
-#endif
GtkListStore *slots_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
-#if 0
- for (int i = 0; slots[i]; i++) {
- GtkTreeIter iter;
- gtk_list_store_append (slots_store, &iter);
- gtk_list_store_set (slots_store, &iter, 0, slots[i], -1);
- }
-#endif
// traverse all plugins and collect all exported actions to dropdown
// column0: title
// column1: name (invisible)
@@ -356,7 +348,9 @@ prefwin_add_hotkeys_tab (GtkWidget *prefwin) {
if (actions->name && actions->title) { // only add actions with both the name and the title
GtkTreeIter iter;
gtk_list_store_append (slots_store, &iter);
- gtk_list_store_set (slots_store, &iter, 0, actions->title, 1, actions->name, -1);
+ char title[100];
+ unescape_forward_slash (actions->title, title, sizeof (title));
+ gtk_list_store_set (slots_store, &iter, 0, title, 1, actions->name, -1);
}
else {
fprintf (stderr, "WARNING: action %s/%s from plugin %s is missing name and/or title\n", actions->name, actions->title, p->name);
@@ -426,7 +420,9 @@ prefwin_add_hotkeys_tab (GtkWidget *prefwin) {
if (actions->name && actions->title && !strcasecmp (actions->name, command)) { // only add actions with both the name and the title
GtkTreeIter iter;
gtk_list_store_append (hkstore, &iter);
- gtk_list_store_set (hkstore, &iter, 0, actions->title, 1, param, 2, actions->name, -1);
+ char title[100];
+ unescape_forward_slash (actions->title, title, sizeof (title));
+ gtk_list_store_set (hkstore, &iter, 0, title, 1, param, 2, actions->name, -1);
break; // found
}
actions = actions->next;
diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c
index c61bbc8b..feba4efe 100644
--- a/plugins/hotkeys/hotkeys.c
+++ b/plugins/hotkeys/hotkeys.c
@@ -628,7 +628,7 @@ static DB_plugin_action_t action_toggle_pause = {
};
static DB_plugin_action_t action_play_pause = {
- .title = "Play/Pause",
+ .title = "Play\\/Pause",
.name = "play_pause",
.flags = DB_ACTION_COMMON,
.callback = action_play_pause_cb,