diff options
author | Alexey Yakovenko <waker@users.sourceforge.net> | 2013-10-13 15:38:47 +0200 |
---|---|---|
committer | Alexey Yakovenko <waker@users.sourceforge.net> | 2013-10-13 15:38:47 +0200 |
commit | 934a10b9a5ea67734a74a44361868654fc15297d (patch) | |
tree | 535ee399cf2a39c1aa608206faffaa71e10dd884 /plugins/gtkui/hotkeys.c | |
parent | 81eb75d90b8b963cadedbb5642e9030beac9828f (diff) |
gtkui: prettified assigned hotkey action text
Diffstat (limited to 'plugins/gtkui/hotkeys.c')
-rw-r--r-- | plugins/gtkui/hotkeys.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/plugins/gtkui/hotkeys.c b/plugins/gtkui/hotkeys.c index a8d4ee67..afe4197d 100644 --- a/plugins/gtkui/hotkeys.c +++ b/plugins/gtkui/hotkeys.c @@ -89,6 +89,27 @@ unescape_forward_slash (const char *src, char *dst, int size) { *dst = 0; } +static void +prettify_forward_slash (const char *src, char *dst, int size) { + char *start = dst; + const char arrow[] = " → "; + int larrow = strlen (arrow); + while (*src && size > 1) { + if (*src == '\\' && *(src+1) == '/') { + src++; + } + else if (*src == '/' && size > larrow) { + memcpy (dst, arrow, larrow); + src++; + dst += larrow; + size -= larrow; + continue; + } + *dst++ = *src++; + size--; + } + *dst = 0; +} static const char * get_display_action_title (const char *title) { @@ -463,7 +484,10 @@ set_button_action_label (const char *act, int action_ctx, GtkWidget *button) { } char s[200]; snprintf (s, sizeof (s), "%s%s%s", ctx_str ? ctx_str : "", ctx_str ? " ⇒ ": "", action->title); - gtk_button_set_label (GTK_BUTTON (button), s); + char s_fixed[200]; + prettify_forward_slash (s, s_fixed, sizeof (s_fixed)); + + gtk_button_set_label (GTK_BUTTON (button), s_fixed); return; } } |