diff --git a/ChangeLog b/ChangeLog index e568dd0db..6fd02c073 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-10-01 David Zeuthen + + * README.in: Add "Notes about glib 2.20" section detailing the + ramifications of the patch from bug #528670. + 2008-09-30 Behdad Esfahbod Bug 554092 – glib doesn't return G_FILE_ERROR_NOENT et al on OS X diff --git a/README.in b/README.in index a0d618dfe..e62c55df5 100644 --- a/README.in +++ b/README.in @@ -24,6 +24,21 @@ Installation See the file 'INSTALL' +Notes about GLib 2.20 +===================== + +^ The functions for launching applications (e.g. g_app_info_launch() + + friends) now passes a FUSE file:// URI if possible (requires gvfs + with the FUSE daemon to be running and operational). With gvfs 2.26, + FUSE file:// URIs will be mapped back to gio URIs in the GFile + constructors. The intent of this change is to better integrate + POSIX-only applications, see bug #528670 for the rationale. The + only user-visible change is when an application needs to examine an + URI passed to it (e.g. as a positional parameter). Instead of + looking at the given URI, the application will now need to look at + the result of g_file_get_uri() after having constructed a GFile + object with the given URI. + Notes about GLib 2.18 ===================== diff --git a/gio/ChangeLog b/gio/ChangeLog index 3d072b421..e85ca28a5 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,18 @@ +2008-10-01 David Zeuthen + + * gdesktopappinfo.c (expand_macro): If possible, always pass FUSE + file:// URIs (such as '/home/davidz/.gvfs/sftp on foo/file.avi') + instead of the gio URI (such as sftp://foo/file.avi) when using + g_app_info_launch() and friends. With a sufficiently recent gvfs, + apps using gio+gvfs will map the FUSE file:// URI back to the gio + URI (and thus bypass the fuse daemon) thanks the patch from bug + #530654. Since Nautilus is an user of g_app_info_launch() it + means that non-gio POSIX apps, such as mplayer, will Just Work(tm) + when launced via the file manager. Win. Fixes bug #528670. + + * gappinfo.c: Add some notes about the FUSE POSIX URI <-> GIO URI + mapping to the description of GAppInfo. + 2008-09-30 Tor Lillqvist * tests/Makefile.am: Build desktop-app-info only on Unix. diff --git a/gio/gappinfo.c b/gio/gappinfo.c index e32c9ba00..9b82cf2d8 100644 --- a/gio/gappinfo.c +++ b/gio/gappinfo.c @@ -34,7 +34,55 @@ * @include: gio/gio.h * * #GAppInfo and #GAppLaunchContext are used for describing and launching - * applications installed on the system. + * applications installed on the system. + * + * As of GLib 2.20, URIs will always be converted to POSIX paths + * (using g_file_get_path()) when using g_app_info_launch() even if + * the application requested an URI and not a POSIX path. For example + * for an desktop-file based application with Exec key totem + * %%U and a single URI, + * sftp://foo/file.avi, then + * /home/user/.gvfs/sftp on foo/file.avi will be + * passed. This will only work if a set of suitable GIO extensions + * (such as gvfs 2.26 compiled with FUSE support), is available and + * operational; if this is not the case, the URI will be passed + * unmodified to the application. Some URIs, such as + * mailto:, of course cannot be mapped to a POSIX + * path (in gvfs there's no FUSE mount for it); such URIs will be + * passed unmodified to the application. + * + * Specifically for gvfs 2.26 and later, the POSIX URI will be mapped + * back to the GIO URI in the #GFile constructors (since gvfs + * implements the #GVfs extension point). As such, if the application + * needs to examine the URI, it needs to use g_file_get_uri() or + * similar on #GFile. In other words, an application cannot assume + * that the URI passed to e.g. g_file_new_for_commandline_arg() is + * equal to the result of g_file_get_uri(). The following snippet + * illustrates this: + * + * + * GFile *f; + * char *uri; + * + * file = g_file_new_for_commandline_arg (uri_from_commandline); + * + * uri = g_file_get_uri (file); + * strcmp (uri, uri_from_commandline) == 0; // FALSE + * g_free (uri); + * + * if (g_file_has_uri_scheme (file, "cdda")) + * { + * // do something special with uri + * } + * g_object_unref (file); + * + * + * This code will work when both cdda://sr0/Track + * 1.wav and /home/user/.gvfs/cdda on sr0/Track + * 1.wav is passed to the application. It should be noted + * that it's generally not safe for applications to rely on the format + * of a particular URIs. Different launcher applications (e.g. file + * managers) may have different ideas of what a given URI means. * **/ diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c index 866bc3528..3ee0f344d 100644 --- a/gio/gdesktopappinfo.c +++ b/gio/gdesktopappinfo.c @@ -530,9 +530,32 @@ expand_macro (char macro, { GList *uris = *uri_list; char *expanded; - + gboolean force_file_uri; + char force_file_uri_macro; + g_return_if_fail (exec != NULL); - + + /* On %u and %U, pass POSIX file path pointing to the URI via + * the FUSE mount in ~/.gvfs. Note that if the FUSE daemon isn't + * running or the URI doesn't have a POSIX file path via FUSE + * we'll just pass the URI. + */ + switch (macro) + { + case 'u': + force_file_uri_macro = 'f'; + force_file_uri = TRUE; + break; + case 'U': + force_file_uri_macro = 'F'; + force_file_uri = TRUE; + break; + default: + force_file_uri_macro = macro; + force_file_uri = FALSE; + break; + } + switch (macro) { case 'u': @@ -541,7 +564,17 @@ expand_macro (char macro, case 'n': if (uris) { - expanded = expand_macro_single (macro, uris->data); + if (!force_file_uri) + { + expanded = expand_macro_single (macro, uris->data); + } + else + { + expanded = expand_macro_single (force_file_uri_macro, uris->data); + if (expanded == NULL) + expanded = expand_macro_single (macro, uris->data); + } + if (expanded) { g_string_append (exec, expanded); @@ -558,7 +591,17 @@ expand_macro (char macro, case 'N': while (uris) { - expanded = expand_macro_single (macro, uris->data); + if (!force_file_uri) + { + expanded = expand_macro_single (macro, uris->data); + } + else + { + expanded = expand_macro_single (force_file_uri_macro, uris->data); + if (expanded == NULL) + expanded = expand_macro_single (macro, uris->data); + } + if (expanded) { g_string_append (exec, expanded);