[gvfs] gvfs-open: Construct full URI for local paths
- From: Tomas Bzatek <tbzatek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] gvfs-open: Construct full URI for local paths
- Date: Mon, 25 Jun 2012 15:45:35 +0000 (UTC)
commit a35863dd370b6c7a72ad161385507b9b2613bfa8
Author: Tomas Bzatek <tbzatek redhat com>
Date: Mon Jun 25 17:41:24 2012 +0200
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
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 e32b195..6836a14 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. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]