diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-08-03 20:12:00 +0800 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2012-08-15 20:08:45 +0800 |
commit | dd60d75a6811d1a728c290b45de343c84e298a6d (patch) | |
tree | 000eff2e29ebbe22b42e2b042e196ca143353e2a | |
parent | f4fc6c6be76bb4cdfb4ebda9ca7de6758f2f18d1 (diff) | |
download | gsoc2013-empathy-dd60d75a6811d1a728c290b45de343c84e298a6d.tar gsoc2013-empathy-dd60d75a6811d1a728c290b45de343c84e298a6d.tar.gz gsoc2013-empathy-dd60d75a6811d1a728c290b45de343c84e298a6d.tar.bz2 gsoc2013-empathy-dd60d75a6811d1a728c290b45de343c84e298a6d.tar.lz gsoc2013-empathy-dd60d75a6811d1a728c290b45de343c84e298a6d.tar.xz gsoc2013-empathy-dd60d75a6811d1a728c290b45de343c84e298a6d.tar.zst gsoc2013-empathy-dd60d75a6811d1a728c290b45de343c84e298a6d.zip |
empathy_launch_external_app: allow to pass arguments
https://bugzilla.gnome.org/show_bug.cgi?id=680778
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 33 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.h | 1 | ||||
-rw-r--r-- | src/empathy-accounts-dialog.c | 61 |
3 files changed, 38 insertions, 57 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index 905037bf8..967d59cda 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -1669,10 +1669,12 @@ launch_app_info (GAppInfo *app_info, gboolean empathy_launch_external_app (const gchar *desktop_file, + const gchar *args, GError **error) { GDesktopAppInfo *desktop_info; gboolean result; + GError *err = NULL; desktop_info = g_desktop_app_info_new (desktop_file); if (desktop_info == NULL) @@ -1684,8 +1686,35 @@ empathy_launch_external_app (const gchar *desktop_file, return FALSE; } - result = launch_app_info (G_APP_INFO (desktop_info), error); - g_object_unref (desktop_info); + if (args == NULL) + { + result = launch_app_info (G_APP_INFO (desktop_info), error); + } + else + { + gchar *cmd; + GAppInfo *app_info; + + /* glib doesn't have API to start a desktop file with args... (#637875) */ + cmd = g_strdup_printf ("%s %s", g_app_info_get_commandline ( + (GAppInfo *) desktop_info), args); + app_info = g_app_info_create_from_commandline (cmd, NULL, 0, &err); + if (app_info == NULL) + { + DEBUG ("Failed to launch '%s': %s", cmd, err->message); + g_free (cmd); + g_object_unref (desktop_info); + g_propagate_error (error, err); + return FALSE; + } + + result = launch_app_info (app_info, error); + + g_object_unref (app_info); + g_free (cmd); + } + + g_object_unref (desktop_info); return result; } diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h index 97777e5b6..73232cf52 100644 --- a/libempathy-gtk/empathy-ui-utils.h +++ b/libempathy-gtk/empathy-ui-utils.h @@ -148,6 +148,7 @@ void empathy_launch_program (const gchar *dir, void empathy_set_css_provider (GtkWidget *widget); gboolean empathy_launch_external_app (const gchar *desktop_file, + const gchar *args, GError **error); G_END_DECLS diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index a4096b86f..1023bac15 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -640,28 +640,6 @@ account_dialog_create_edit_params_dialog (EmpathyAccountsDialog *dialog) } static void -start_external_app (GAppInfo *app_info) -{ - GError *error = NULL; - GdkAppLaunchContext *context = NULL; - GdkDisplay *display; - - display = gdk_display_get_default (); - context = gdk_display_get_app_launch_context (display); - - if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context, - &error)) - { - g_critical ("Failed to launch %s: %s", - g_app_info_get_display_name (app_info), - error->message); - g_clear_error (&error); - } - - tp_clear_object (&context); -} - -static void use_external_storage_provider (EmpathyAccountsDialog *self, TpAccount *account) { @@ -670,47 +648,20 @@ use_external_storage_provider (EmpathyAccountsDialog *self, provider = tp_account_get_storage_provider (account); if (!tp_strdiff (provider, "com.meego.libsocialweb")) { - GDesktopAppInfo *desktop_info; - gchar *cmd; - GAppInfo *app_info; - GError *error = NULL; - - desktop_info = g_desktop_app_info_new ("gnome-control-center.desktop"); - if (desktop_info == NULL) - { - g_critical ("Could not locate 'gnome-control-center.desktop'"); - return; - } - - /* glib doesn't have API to start a desktop file with args... (#637875) */ - cmd = g_strdup_printf ("%s bisho.desktop", g_app_info_get_commandline ( - (GAppInfo *) desktop_info)); - - app_info = g_app_info_create_from_commandline (cmd, NULL, 0, &error); - - if (app_info == NULL) - { - DEBUG ("Failed to create app info: %s", error->message); - g_error_free (error); - } - else - { - start_external_app (app_info); - g_object_unref (app_info); - } - - g_object_unref (desktop_info); - g_free (cmd); + empathy_launch_external_app ("gnome-control-center.desktop", + "bisho.desktop", NULL); return; } else if (!tp_strdiff (provider, EMPATHY_GOA_PROVIDER)) { - empathy_launch_external_app ("gnome-online-accounts-panel.desktop", NULL); + empathy_launch_external_app ("gnome-online-accounts-panel.desktop", + NULL, NULL); return; } else if (!tp_strdiff (provider, EMPATHY_UOA_PROVIDER)) { - empathy_launch_external_app ("gnome-credentials-panel.desktop", NULL); + empathy_launch_external_app ("gnome-credentials-panel.desktop", + NULL, NULL); return; } else |