From 86a8b847b01b06709b712bd0df70e9d9fad23754 Mon Sep 17 00:00:00 2001 From: Mathias Hasselmann Date: Sun, 24 Sep 2006 13:35:38 +0000 Subject: Escape underscores in filenames of recent file items. 2006-09-24 Mathias Hasselmann * shell/ev-window.c: (ev_window_setup_recent), (ev_window_get_recent_file_label): Escape underscores in filenames of recent file items. --- diff --git a/ChangeLog b/ChangeLog index 0a77181..9204ff3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,16 @@ +2006-09-24 Mathias Hasselmann + + * shell/ev-window.c: (ev_window_setup_recent), + (ev_window_get_recent_file_label): + + Escape underscores in filenames of recent file items. + 2006-09-24 Nickolay V. Shmyrev * configure.ac: Bumped poppler requirements, really 0.5.3 is very - buggy, now we require 0.5.4 + buggy, now we require 0.5.4. 2006-09-17 Nickolay V. Shmyrev diff --git a/shell/ev-window.c b/shell/ev-window.c index cbd504c..d10c175 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -1192,6 +1192,47 @@ compare_recent_items (GtkRecentInfo *a, GtkRecentInfo *b) } #endif /* HAVE_GTK_RECENT */ +/* + * Doubles underscore to avoid spurious menu accels. + */ +static gchar * +ev_window_get_recent_file_label (gint index, const gchar *filename) +{ + GString *str; + gint length; + const gchar *p; + const gchar *end; + + g_return_val_if_fail (filename != NULL, NULL); + + length = strlen (filename); + str = g_string_sized_new (length + 10); + g_string_printf (str, "_%d. ", index); + + p = filename; + end = filename + length; + + while (p != end) + { + const gchar *next; + next = g_utf8_next_char (p); + + switch (*p) + { + case '_': + g_string_append (str, "__"); + break; + default: + g_string_append_len (str, p, next - p); + break; + } + + p = next; + } + + return g_string_free (str, FALSE); +} + static void ev_window_setup_recent (EvWindow *ev_window) { @@ -1232,9 +1273,8 @@ ev_window_setup_recent (EvWindow *ev_window) continue; action_name = g_strdup_printf ("RecentFile%u", i++); - label = g_strdup_printf ("_%d. %s", - n_items + 1, - gtk_recent_info_get_display_name (info)); + label = ev_window_get_recent_file_label ( + n_items + 1, gtk_recent_info_get_display_name (info)); action = g_object_new (GTK_TYPE_ACTION, "name", action_name, -- cgit v0.9.1