summaryrefslogtreecommitdiff
path: root/gtk/gtkfilesystem.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@novell.com>2009-01-21 03:17:01 +0000
committerFederico Mena Quintero <federico@src.gnome.org>2009-01-21 03:17:01 +0000
commite4bc68ba04100e32a4945a753543549e306c1276 (patch)
treef95bf6abd65c361ba7a428fdb099399f6e3b7396 /gtk/gtkfilesystem.c
parent2c07a59e5496ba1f677a29068f5199c3f0c27b22 (diff)
downloadgtk+-e4bc68ba04100e32a4945a753543549e306c1276.tar.gz
Don't do completion in the middle of an incomplete hostname
Fix completion so it doesn't pop up for every character in a URI hostname: * gtk/gtkfilechooser.h (GtkFileChooserError): Add a GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME. * gtk/gtkfilesystem.c (_gtk_file_system_parse): Return an "incomplete hostname" error if the user has not typed a full hostname yet in an URI. * gtk/gtkfilechooserentry.c (append_common_prefix): If we get an incomplete hostname, just don't pop up an error, since that is a transient state and the user doesn't need to be notified about it. (refresh_current_folder_and_file_part): Don't revert to showing the base folder if we have an incomplete hostname. (reload_current_folder): Handle the passed folder being NULL, even if we must force a reload. Also, reload the folder if we didn't have a cancellable for it (i.e. we hadn't started to load it before). Signed-off-by: Federico Mena Quintero <federico@novell.com> svn path=/trunk/; revision=22157
Diffstat (limited to 'gtk/gtkfilesystem.c')
-rw-r--r--gtk/gtkfilesystem.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c
index 46c36cb053..bc6cbf588d 100644
--- a/gtk/gtkfilesystem.c
+++ b/gtk/gtkfilesystem.c
@@ -672,6 +672,7 @@ _gtk_file_system_parse (GtkFileSystem *file_system,
gboolean result = FALSE;
gboolean is_dir = FALSE;
gchar *last_slash = NULL;
+ gboolean is_uri;
DEBUG ("parse");
@@ -680,7 +681,37 @@ _gtk_file_system_parse (GtkFileSystem *file_system,
last_slash = strrchr (str, G_DIR_SEPARATOR);
- if (str[0] == '~' || g_path_is_absolute (str) || has_uri_scheme (str))
+ is_uri = has_uri_scheme (str);
+
+ if (is_uri)
+ {
+ const char *colon;
+ const char *slash_after_hostname;
+
+ colon = strchr (str, ':');
+ g_assert (colon != NULL);
+ g_assert (strncmp (colon, "://", 3) == 0);
+
+ slash_after_hostname = strchr (colon + 3, '/');
+
+ if (slash_after_hostname == NULL)
+ {
+ /* We don't have a full hostname yet. So, don't switch the folder
+ * until we have seen a full hostname. Otherwise, completion will
+ * happen for every character the user types for the hostname.
+ */
+
+ *folder = NULL;
+ *file_part = NULL;
+ g_set_error (error,
+ GTK_FILE_CHOOSER_ERROR,
+ GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME,
+ "Incomplete hostname");
+ return FALSE;
+ }
+ }
+
+ if (str[0] == '~' || g_path_is_absolute (str) || is_uri)
file = g_file_parse_name (str);
else
file = g_file_resolve_relative_path (base_file, str);