glib2/gio-2.16-only-pass-uri-to-gio-apps.patch

110 lines
3.7 KiB
Diff
Raw Normal View History

2008-07-03 14:57:14 +00:00
diff -up glib-2.17.3/gio/gdesktopappinfo.c.only-pass-uri-to-gio-apps glib-2.17.3/gio/gdesktopappinfo.c
--- glib-2.17.3/gio/gdesktopappinfo.c.only-pass-uri-to-gio-apps 2008-07-02 17:13:13.000000000 -0400
+++ glib-2.17.3/gio/gdesktopappinfo.c 2008-07-03 10:55:58.000000000 -0400
@@ -1,3 +1,5 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
/* GIO - GLib Input, Output and Streaming Library
*
* Copyright (C) 2006-2007 Red Hat, Inc.
2008-07-03 14:57:14 +00:00
@@ -89,6 +91,7 @@ struct _GDesktopAppInfo
char *exec;
char *binary;
char *path;
+ char *vfs_system;
guint nodisplay : 1;
guint hidden : 1;
2008-07-03 14:57:14 +00:00
@@ -151,6 +154,7 @@ g_desktop_app_info_finalize (GObject *ob
g_free (info->try_exec);
g_free (info->exec);
g_free (info->binary);
+ g_free (info->vfs_system);
g_free (info->path);
G_OBJECT_CLASS (g_desktop_app_info_parent_class)->finalize (object);
2008-07-03 14:57:14 +00:00
@@ -254,6 +258,7 @@ g_desktop_app_info_new_from_keyfile (GKe
info->terminal = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TERMINAL, NULL) != FALSE;
info->startup_notify = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, NULL) != FALSE;
info->hidden = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, NULL) != FALSE;
+ info->vfs_system = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, "X-Gnome-Vfs-System", NULL);
2008-07-03 14:57:14 +00:00
info->icon = NULL;
if (info->icon_name)
@@ -517,9 +522,35 @@ 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, only pass gio URI's if the desktop file has the
+ * X-Gnome-Vfs-System key set to 'gio' or if FUSE is not available.
+ * Otherwise we pass in a POSIX file path pointing to the URI via
+ * the FUSE mount in ~/.gvfs.
+ */
+ force_file_uri = FALSE;
+ if (macro == 'u' || macro == 'U')
+ {
+ if (info->vfs_system == NULL || strcmp (info->vfs_system, "gio") != 0)
+ {
+ 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;
+ }
+ }
+ }
+
switch (macro)
{
case 'u':
2008-07-03 14:57:14 +00:00
@@ -528,7 +559,17 @@ expand_macro (char macro,
case 'n':
if (uris)
{
- expanded = expand_macro_single (macro, uris->data);
+ if (!force_file_uri || g_str_has_prefix (uris->data, "http"))
+ {
+ 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);
2008-07-03 14:57:14 +00:00
@@ -545,7 +586,17 @@ expand_macro (char macro,
case 'N':
while (uris)
{
- expanded = expand_macro_single (macro, uris->data);
+ if (!force_file_uri || g_str_has_prefix (uris->data, "http"))
+ {
+ 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);