diff options
author | Tomas Bzatek <tbzatek@redhat.com> | 2012-06-25 17:41:24 +0200 |
---|---|---|
committer | Tomas Bzatek <tbzatek@redhat.com> | 2012-06-25 17:41:24 +0200 |
commit | a35863dd370b6c7a72ad161385507b9b2613bfa8 (patch) | |
tree | b11354a9947d1c7c98404197cb3ae1793fc9b344 /programs | |
parent | ff748cd275fba9b6cc14f1efa94534fbf0f23caa (diff) | |
download | gvfs-a35863dd370b6c7a72ad161385507b9b2613bfa8.tar.gz |
gvfs-open: Construct full URI for local paths
Apparently g_app_info_launch_default_for_uri() can't handle invalid
URIs like the plain local path, returning G_IO_ERROR_NOT_SUPPORTED.
Let's go through GFile to get a full URI as a fallback.
https://bugzilla.gnome.org/show_bug.cgi?id=676313
Diffstat (limited to 'programs')
-rw-r--r-- | programs/gvfs-open.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/programs/gvfs-open.c b/programs/gvfs-open.c index e32b1950..6836a14a 100644 --- a/programs/gvfs-open.c +++ b/programs/gvfs-open.c @@ -46,6 +46,8 @@ main (int argc, char *argv[]) gchar *summary; int i; gboolean success; + gboolean res; + GFile *file; setlocale (LC_ALL, ""); @@ -100,9 +102,22 @@ main (int argc, char *argv[]) do { - if (!g_app_info_launch_default_for_uri (locations[i], - NULL, - &error)) + res = g_app_info_launch_default_for_uri (locations[i], + NULL, + &error); + + if (!res && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) + { + /* g_app_info_launch_default_for_uri() can't properly handle non-URI (local) locations */ + g_clear_error (&error); + file = g_file_new_for_commandline_arg (locations[i]); + res = g_app_info_launch_default_for_uri (g_file_get_uri (file), + NULL, + &error); + g_object_unref (file); + } + + if (!res) { /* Translators: the first %s is the program name, the second one */ /* is the URI of the file, the third is the error message. */ |