]> www.fi.muni.cz Git - evince.git/commitdiff
Escape underscores in filenames of recent file items.
authorMathias Hasselmann <mathias.hasselmann@gmx.de>
Sun, 24 Sep 2006 13:35:38 +0000 (13:35 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Sun, 24 Sep 2006 13:35:38 +0000 (13:35 +0000)
2006-09-24  Mathias Hasselmann  <mathias.hasselmann@gmx.de>

        * shell/ev-window.c: (ev_window_setup_recent),
        (ev_window_get_recent_file_label):

        Escape underscores in filenames of recent file items.

ChangeLog
shell/ev-window.c

index 0a77181aa82c37849d9be644bf460621d9b520c1..9204ff3ccfb67f66150668e01b1afb4e57291008 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,16 @@
+2006-09-24  Mathias Hasselmann  <mathias.hasselmann@gmx.de>
+
+        * 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  <nshmyrev@yandex.ru>
 
        * 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  <nshmyrev@yandex.ru>
 
index cbd504ca5eacb50c48741a266d7af7f47247695d..d10c175dd00adf741eefb084a70b27d72c2d422e 100644 (file)
@@ -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,