diff options
author | Federico Mena Quintero <federico@gnome.org> | 2013-03-05 14:20:12 -0600 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2013-03-05 17:17:42 -0600 |
commit | d484721b5ca9e82d6422cca8a3a40f001208f87b (patch) | |
tree | 6e258b8c188d11e2b559b9034af8c55a9cf8699d /gtk/gtkfilechooser.c | |
parent | 56bcb1933f6de613e5d8689e23420d47b65425c3 (diff) | |
download | gtk+-d484721b5ca9e82d6422cca8a3a40f001208f87b.tar.gz |
filechooser: Also convert get_uris() to returning native paths
It was only being done in gtk_file_chooser_get_uri().
Signed-off-by: Federico Mena Quintero <federico@gnome.org>
Diffstat (limited to 'gtk/gtkfilechooser.c')
-rw-r--r-- | gtk/gtkfilechooser.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c index 820db562bf..141e8bf76e 100644 --- a/gtk/gtkfilechooser.c +++ b/gtk/gtkfilechooser.c @@ -1201,6 +1201,22 @@ files_to_strings (GSList *files, return g_slist_reverse (strings); } +static gchar * +file_to_uri_with_native_path (GFile *file) +{ + gchar *result = NULL; + gchar *native; + + native = g_file_get_path (file); + if (native) + { + result = g_filename_to_uri (native, NULL, NULL); /* NULL-GError */ + g_free (native); + } + + return result; +} + /** * gtk_file_chooser_get_filenames: * @chooser: a #GtkFileChooser @@ -1367,18 +1383,10 @@ gtk_file_chooser_get_uri (GtkFileChooser *chooser) if (file) { if (gtk_file_chooser_get_local_only (chooser)) - { - gchar *local = g_file_get_path (file); - if (local) - { - result = g_filename_to_uri (local, NULL, NULL); - g_free (local); - } - } + result = file_to_uri_with_native_path (file); else - { result = g_file_get_uri (file); - } + g_object_unref (file); } @@ -1547,7 +1555,11 @@ gtk_file_chooser_get_uris (GtkFileChooser *chooser) files = gtk_file_chooser_get_files (chooser); - result = files_to_strings (files, g_file_get_uri); + if (gtk_file_chooser_get_local_only (chooser)) + result = files_to_strings (files, file_to_uri_with_native_path); + else + result = files_to_strings (files, g_file_get_uri); + g_slist_foreach (files, (GFunc) g_object_unref, NULL); g_slist_free (files); |