summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@novell.com>2009-01-21 03:16:13 +0000
committerFederico Mena Quintero <federico@src.gnome.org>2009-01-21 03:16:13 +0000
commit9f62525f2bba5e810b34bf421703eda24e02b7ab (patch)
tree7a55e3fc72c00747ddb4f57d5bf8cc4fe4d484e8
parent3f18507222b2e23ed751ddb78075b614e241d5f4 (diff)
downloadgtk+-9f62525f2bba5e810b34bf421703eda24e02b7ab.tar.gz
bgo545980 - parse URIs in GtkFileChooserEntry
2009-01-15 Federico Mena Quintero <federico@novell.com> http://bugzilla.gnome.org/show_bug.cgi?id=545980 - GtkFileChooserEntry should handle URIs * gtk/gtkfilesystem.c (_gtk_file_system_parse): Detect URI schemes and parse the full URI. (has_uri_scheme): New function, stolen from the old gtkfilesystemgnomevfs.c. Signed-off-by: Federico Mena Quintero <federico@novell.com> svn path=/trunk/; revision=22154
-rw-r--r--ChangeLog10
-rw-r--r--gtk/gtkfilesystem.c25
2 files changed, 34 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 030f2829cf..6c8d91c6af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-01-15 Federico Mena Quintero <federico@novell.com>
+
+ http://bugzilla.gnome.org/show_bug.cgi?id=545980 -
+ GtkFileChooserEntry should handle URIs
+
+ * gtk/gtkfilesystem.c (_gtk_file_system_parse): Detect URI schemes
+ and parse the full URI.
+ (has_uri_scheme): New function, stolen from the old
+ gtkfilesystemgnomevfs.c.
+
2009-01-20 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk.symbols:
diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c
index 549671da5a..46c36cb053 100644
--- a/gtk/gtkfilesystem.c
+++ b/gtk/gtkfilesystem.c
@@ -637,6 +637,29 @@ _gtk_file_system_list_bookmarks (GtkFileSystem *file_system)
return g_slist_reverse (files);
}
+static gboolean
+is_valid_scheme_character (char c)
+{
+ return g_ascii_isalnum (c) || c == '+' || c == '-' || c == '.';
+}
+
+static gboolean
+has_uri_scheme (const char *str)
+{
+ const char *p;
+
+ p = str;
+
+ if (!is_valid_scheme_character (*p))
+ return FALSE;
+
+ do
+ p++;
+ while (is_valid_scheme_character (*p));
+
+ return (strncmp (p, "://", 3) == 0);
+}
+
gboolean
_gtk_file_system_parse (GtkFileSystem *file_system,
GFile *base_file,
@@ -657,7 +680,7 @@ _gtk_file_system_parse (GtkFileSystem *file_system,
last_slash = strrchr (str, G_DIR_SEPARATOR);
- if (str[0] == '~')
+ if (str[0] == '~' || g_path_is_absolute (str) || has_uri_scheme (str))
file = g_file_parse_name (str);
else
file = g_file_resolve_relative_path (base_file, str);