diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-07-23 00:42:19 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-07-23 00:42:19 -0400 |
commit | 91c05f6f6bf013accca8ff583cfe66f204fcd5d0 (patch) | |
tree | 4fd450dde1e7f535a30611f8da9d5c4e64f13b02 /gtk/gtkfilechooserentry.c | |
parent | f30637bbae4686ed78dd0976cb941ebab9e28cca (diff) | |
download | gtk+-91c05f6f6bf013accca8ff583cfe66f204fcd5d0.tar.gz |
file chooser entry: Special-case ., .. and ~
Make sure entering the three special strings ".", ".." or "~" in
the location entry works as expected. They already worked correctly
if you append a '/' to force them to be recognized as the 'folder'
part, but that should not be necessary.
https://bugzilla.gnome.org/show_bug.cgi?id=752707
Diffstat (limited to 'gtk/gtkfilechooserentry.c')
-rw-r--r-- | gtk/gtkfilechooserentry.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index 821a5ee33c..100729a114 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -333,6 +333,14 @@ gtk_file_chooser_get_file_for_text (GtkFileChooserEntry *chooser_entry, return file; } +static gboolean +is_directory_shortcut (const char *text) +{ + return strcmp (text, ".") == 0 || + strcmp (text, "..") == 0 || + strcmp (text, "~" ) == 0; +} + static GFile * gtk_file_chooser_get_directory_for_text (GtkFileChooserEntry *chooser_entry, const char * text) @@ -344,7 +352,9 @@ gtk_file_chooser_get_directory_for_text (GtkFileChooserEntry *chooser_entry, if (file == NULL) return NULL; - if (text[0] == 0 || text[strlen (text) - 1] == G_DIR_SEPARATOR) + g_print ("text '%s', folder '%s'\n", text, g_file_get_path (file)); + if (text[0] == 0 || text[strlen (text) - 1] == G_DIR_SEPARATOR || + is_directory_shortcut (text)) return file; parent = g_file_get_parent (file); @@ -833,6 +843,8 @@ _gtk_file_chooser_entry_get_file_part (GtkFileChooserEntry *chooser_entry) last_slash = strrchr (text, G_DIR_SEPARATOR); if (last_slash) return last_slash + 1; + else if (is_directory_shortcut (text)) + return ""; else return text; } |