]> www.fi.muni.cz Git - evince.git/commitdiff
[shell] Fix opening files with '#' in its name
authorCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 11 May 2010 12:29:56 +0000 (14:29 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 11 May 2010 12:29:56 +0000 (14:29 +0200)
See bug #616515.

shell/main.c

index d7d6e158447564f831a23121d97cd94a1cd62af0..187a794c45d9eb76d195483eb5b6c5935f8e6b64 100644 (file)
@@ -146,6 +146,28 @@ launch_previewer (void)
        return retval;
 }
 
+static gchar *
+get_label_from_filename (const gchar *filename)
+{
+       GFile   *file;
+       gchar   *label;
+       gboolean exists;
+
+       label = g_strrstr (filename, "#");
+       if (!label)
+               return NULL;
+
+       /* Filename contains a #, check
+        * whether it's part of the path
+        * or a label
+        */
+       file = g_file_new_for_commandline_arg (filename);
+       exists = g_file_query_exists (file, NULL);
+       g_object_unref (file);
+
+       return exists ? NULL : label;
+}
+
 static void
 load_files (const char **files)
 {
@@ -179,7 +201,7 @@ load_files (const char **files)
                const gchar *app_uri;
 
                filename = files[i];
-               label = strchr (filename, '#');
+               label = get_label_from_filename (filename);
                if (label) {
                        *label = 0;
                        label++;