diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-08-03 14:25:25 +0200 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2012-08-15 14:08:49 +0200 |
commit | 1a3c57d235bd751c4e120266cd3f24ad6afd7a8a (patch) | |
tree | ef2309f04c26edd23c40502bfcba3ec40d8c93db | |
parent | dd60d75a6811d1a728c290b45de343c84e298a6d (diff) |
use empathy_launch_external_app() to launch gnome-contacts
https://bugzilla.gnome.org/show_bug.cgi?id=680778
-rw-r--r-- | libempathy-gtk/empathy-individual-information-dialog.c | 62 |
1 files changed, 18 insertions, 44 deletions
diff --git a/libempathy-gtk/empathy-individual-information-dialog.c b/libempathy-gtk/empathy-individual-information-dialog.c index 9ac783ac..2e8fcb66 100644 --- a/libempathy-gtk/empathy-individual-information-dialog.c +++ b/libempathy-gtk/empathy-individual-information-dialog.c @@ -373,60 +373,34 @@ static void start_gnome_contacts (FolksIndividual *individual, gboolean try_installing) { - GDesktopAppInfo *desktop_info; - gchar *cmd; - GAppInfo *app_info; + gchar *args; GError *error = NULL; - GdkAppLaunchContext *context = NULL; - GdkDisplay *display; g_return_if_fail (FOLKS_IS_INDIVIDUAL (individual)); - /* Start gnome-contacts */ - display = gdk_display_get_default (); - context = gdk_display_get_app_launch_context (display); + args = g_strdup_printf ("-i %s", folks_individual_get_id (individual)); - desktop_info = g_desktop_app_info_new ("gnome-contacts.desktop"); - if (desktop_info == NULL) + if (!empathy_launch_external_app ("gnome-contacts.desktop", args, &error)) { - if (try_installing) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) { - const gchar *packages[] = { "gnome-contacts", NULL }; - - DEBUG ("gnome-contacts not installed; try to install it"); - - empathy_pkg_kit_install_packages_async (0, packages, NULL, - NULL, install_gnome_contacts_cb, g_object_ref (individual)); - } - else - { - show_gnome_contacts_error_dialog (); + if (try_installing) + { + const gchar *packages[] = { "gnome-contacts", NULL }; + + DEBUG ("gnome-contacts not installed; try to install it"); + + empathy_pkg_kit_install_packages_async (0, packages, NULL, + NULL, install_gnome_contacts_cb, g_object_ref (individual)); + } + else + { + show_gnome_contacts_error_dialog (); + } } - - return; - } - - /* glib doesn't have API to start a desktop file with args... (#637875) */ - cmd = g_strdup_printf ("%s -i %s", g_app_info_get_commandline ( - (GAppInfo *) desktop_info), folks_individual_get_id (individual)); - - 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); - return; - } - - if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context, - &error)) - { - g_critical ("Failed to start gnome-contacts: %s", error->message); - g_error_free (error); } - g_object_unref (desktop_info); - g_object_unref (app_info); + g_free (args); } /* Use gnome-contacts to display @individual or fallback to |