This patch (sorry, it is quite old but I didn't submitted for review on the mailing list) fixes parsing some keys in Exec fields for .desktop files which are KDE specific.
relevant bug : http://bugzilla.gnome.org/show_bug.cgi?id=302436 -- Frederic Crozat <[EMAIL PROTECTED]> Mandriva
? compile ? gnome-vfs-zip ? imported/fnmatch/Makefile ? imported/fnmatch/Makefile.in ? test/vfs-test.out Index: ChangeLog =================================================================== RCS file: /cvs/gnome/gnome-vfs/ChangeLog,v retrieving revision 1.2174 diff -u -p -r1.2174 ChangeLog --- ChangeLog 28 Apr 2005 22:57:28 -0000 1.2174 +++ ChangeLog 29 Apr 2005 14:54:38 -0000 @@ -1,3 +1,12 @@ +2005-04-29 Frederic Crozat <[EMAIL PROTECTED]> + + * libgnomevfs/gnome-vfs-mime-handlers.c: + (gnome_vfs_mime_application_launch_with_env), (expand_macro), + (expand_application_parameters), (test_exec_array), + (test_exec_macro_expansion), + (gnome_vfs_mime_application_new_from_desktop_id): + Fix % parameters expansion in Exec field (Mandriva bug #15357). + 2005-04-28 Nate Nielsen <[EMAIL PROTECTED]> * modules/smb-method.c: Index: libgnomevfs/gnome-vfs-mime-handlers.c =================================================================== RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime-handlers.c,v retrieving revision 1.121 diff -u -p -r1.121 gnome-vfs-mime-handlers.c --- libgnomevfs/gnome-vfs-mime-handlers.c 24 Feb 2005 08:57:43 -0000 1.121 +++ libgnomevfs/gnome-vfs-mime-handlers.c 29 Apr 2005 14:54:38 -0000 @@ -58,7 +58,7 @@ struct _GnomeVFSMimeApplicationPrivate extern GList * _gnome_vfs_configuration_get_methods_list (void); -static GnomeVFSResult expand_application_parameters (const char *exec, +static GnomeVFSResult expand_application_parameters (GnomeVFSMimeApplication *application, GList **uri_list, int *argc, char ***argv); @@ -1315,10 +1315,10 @@ gnome_vfs_mime_application_launch_with_e g_return_val_if_fail (app != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail (uris != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); - + while (uris != NULL) { - result = expand_application_parameters (app->priv->exec, &uris, + result = expand_application_parameters (app, &uris, &argc, &argv); if (result != GNOME_VFS_OK) { @@ -1389,14 +1389,16 @@ expand_macro_single (char macro, const c return result; } -static void -expand_macro (char macro, GString *exec, GList **uri_list) +static gboolean +expand_macro (char macro, GString *exec, GnomeVFSMimeApplication *application, GList **uri_list) { GList *uris = *uri_list; char *expanded; + gboolean expand = FALSE; g_return_if_fail (uris != NULL); g_return_if_fail (exec != NULL); + g_return_if_fail (application != NULL); if (uris == NULL) { return; @@ -1413,6 +1415,7 @@ expand_macro (char macro, GString *exec, g_free (expanded); } uris = uris->next; + expand = TRUE; break; case 'U': case 'F': @@ -1431,27 +1434,52 @@ expand_macro (char macro, GString *exec, g_string_append_c (exec, ' '); } } + expand = TRUE; + break; + case 'i': + if (application->priv->icon) { + g_string_append (exec, "--icon "); + g_string_append (exec, application->priv->icon); + } + expand = TRUE; + break; + case 'c': + if (application->name) { + g_string_append (exec, application->name); + } + expand = TRUE; + break; + case 'k': + if (application->priv->desktop_file_path) { + g_string_append (exec, application->priv->desktop_file_path); + } + expand = TRUE; + case 'm': /* deprecated */ + expand = TRUE; break; } *uri_list = uris; + + return expand; } static GnomeVFSResult -expand_application_parameters (const char *exec, +expand_application_parameters (GnomeVFSMimeApplication *application, GList **uris, int *argc, char ***argv) { GList *uri_list = *uris; - const char *p = exec; + const char *p = application->priv->exec; GString *expanded_exec = g_string_new (NULL); + gboolean expanded = FALSE; g_return_val_if_fail (p != NULL, GNOME_VFS_ERROR_PARSE); while (*p) { if (p[0] == '%' && p[1] != '\0') { - expand_macro (p[1], expanded_exec, uris); + expanded = expand_macro (p[1], expanded_exec, application, uris) || expanded; p++; } else { g_string_append_c (expanded_exec, *p); @@ -1460,6 +1488,12 @@ expand_application_parameters (const cha p++; } + /* URIs were not used, add first one as %f */ + if (expanded && (uri_list == *uris)) { + g_string_append_c (expanded_exec, ' '); + expand_macro ('f', expanded_exec, application, uris); + } + /* No substitutions */ if (uri_list == *uris) { return GNOME_VFS_ERROR_PARSE; @@ -1503,21 +1537,23 @@ print_macro_expansion (char **argv, Gnom } static void -test_exec_array (const char **execs, GList *uris) +test_exec_array (GList *apps, GList *uris) { - int argc, i; + int argc; char **argv; + GList *app; - for (i = 0; execs[i] != NULL; i++) + for (app = apps; app != NULL; app = app->next) { + GnomeVFSMimeApplication *application = app->data; GList *l = uris; - print_expansion_data (uris, execs[i]); + print_expansion_data (uris, application->priv->exec); while (l != NULL) { GnomeVFSResult res; res = expand_application_parameters - (execs[i], &l, &argc, &argv); + (application, &l, &argc, &argv); print_macro_expansion (argv, res); g_strfreev (argv); } @@ -1546,16 +1582,47 @@ test_exec_macro_expansion (void) "test %u", "test %U", NULL }; + const char **p; + + GList* applications = NULL; + GnomeVFSMimeApplication *application, *app; + + application = g_new0 (GnomeVFSMimeApplication, 1); + application->priv = g_new0 (GnomeVFSMimeApplicationPrivate, 1); + application->id = g_strdup ("foobar.desktop"); + aplication->name = g_strdup ("foobar"); + application->priv->icon = g_strdup ("icon.png"); + + for (p = local; p ; p++) { + app = gnome_vfs_mime_application_copy (application); + g_free (app->priv->exec); + app->priv->exec = g_strdup (*p); + applications = g_list_prepend(applications, app); + } uris = g_list_append (uris, "file:///home/test/test1.txt"); uris = g_list_append (uris, "file:///home/test/test2.txt"); - test_exec_array (local, uris); - + test_exec_array (applications, uris); + + gnome_vfs_mime_application_list_free (applications); + applications = NULL; + + for (p = remote; p ; p++) { + app = gnome_vfs_mime_application_copy (application); + g_free (app->priv->exec); + app->priv->exec = g_strdup (*p); + applications = g_list_prepend (applications, app); + } + uris = g_list_append (uris, "http://www.test.org/test1.txt"); uris = g_list_append (uris, "http://www.test.org/test2.txt"); - test_exec_array (remote, uris); + test_exec_array (applications, uris); + + gnome_vfs_mime_application_list_free (applications); g_list_free (uris); + + gnome_vfs_mime_application_free (application); } #endif @@ -1950,7 +2017,7 @@ gnome_vfs_mime_get_all_applications_for_ } /** - * gnome_vfs_mime_application_get_desktop_file_path: + * gnome_vfs_mime_application_get_desktop_id: * @app: a #GnomeVFSMimeApplication * * Returns the identifier of the desktop entry.
_______________________________________________ gnome-vfs-list mailing list gnome-vfs-list@gnome.org http://mail.gnome.org/mailman/listinfo/gnome-vfs-list