[evince/gnome-2-30] [shell] Fix opening files with '#' in its name



commit bccc543bb9d6814f486fd7b3c0941a6897a74914
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Tue May 11 14:29:56 2010 +0200

    [shell] Fix opening files with '#' in its name
    
    See bug #616515.

 shell/main.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/shell/main.c b/shell/main.c
index 3f96c57..620cba4 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -143,6 +143,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)
 {
@@ -174,7 +196,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++;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]