=================================================================== RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime-handlers.c,v retrieving revision 1.127 retrieving revision 1.127.2.1 diff -u -r1.127 -r1.127.2.1 --- gnome-vfs-mime-handlers.c 2006/02/06 10:55:55 1.127 +++ libgnomevfs/gnome-vfs-mime-handlers.c 2006/04/26 09:22:34 1.127.2.1 @@ -58,7 +58,7 @@ 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); @@ -1374,7 +1374,7 @@ while (uris != NULL) { - result = expand_application_parameters (app->priv->exec, &uris, + result = expand_application_parameters (app, &uris, &argc, &argv); if (result != GNOME_VFS_OK) { @@ -1446,7 +1446,7 @@ } static void -expand_macro (char macro, GString *exec, GList **uri_list) +expand_macro (char macro, GString *exec, GnomeVFSMimeApplication *application, GList **uri_list) { GList *uris = *uri_list; char *expanded; @@ -1488,26 +1488,43 @@ } } break; + case 'i': + if (application->priv->icon) { + g_string_append (exec, "--icon "); + g_string_append (exec, application->priv->icon); + } + break; + case 'c': + if (application->name) { + g_string_append (exec, application->name); + } + break; + case 'k': + if (application->priv->desktop_file_path) { + g_string_append (exec, application->priv->desktop_file_path); + } + case 'm': /* deprecated */ + break; } *uri_list = uris; } 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); 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); + expand_macro (p[1], expanded_exec, application, uris); p++; } else { g_string_append_c (expanded_exec, *p); @@ -1559,21 +1576,23 @@ } 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); } @@ -1602,16 +1621,47 @@ "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 @@ -1999,7 +2049,7 @@ } /** - * 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.