From 05f8bd96c6fc3cc62995c24678730b9fcdda9112 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 7 Feb 2012 17:12:15 +0100 Subject: Try installing gnome-contacts using PackageKit https://bugzilla.gnome.org/show_bug.cgi?id=669578 --- libempathy-gtk/empathy-individual-menu.c | 52 +++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c index 6d9359d65..4174cc759 100644 --- a/libempathy-gtk/empathy-individual-menu.c +++ b/libempathy-gtk/empathy-individual-menu.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "empathy-account-selector-dialog.h" #include "empathy-individual-menu.h" @@ -1310,7 +1311,37 @@ show_gnome_contacts_error_dialog (void) } static void -start_gnome_contacts (FolksIndividual *individual) +start_gnome_contacts (FolksIndividual *individual, + gboolean try_installing); + +static void +install_gnome_contacts_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + FolksIndividual *individual = user_data; + GError *error = NULL; + + if (!empathy_pkg_kit_install_packages_finish (result, &error)) + { + DEBUG ("Failed to install gnome-contacts: %s", error->message); + g_error_free (error); + + show_gnome_contacts_error_dialog (); + goto out; + } + + DEBUG ("gnome-contacts installed"); + + start_gnome_contacts (individual, FALSE); + +out: + g_object_unref (individual); +} + +static void +start_gnome_contacts (FolksIndividual *individual, + gboolean try_installing) { GDesktopAppInfo *desktop_info; gchar *cmd; @@ -1326,9 +1357,20 @@ start_gnome_contacts (FolksIndividual *individual) desktop_info = g_desktop_app_info_new ("gnome-contacts.desktop"); if (desktop_info == NULL) { - DEBUG ("gnome-contacts not installed"); + 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 (); + } - show_gnome_contacts_error_dialog (); return; } @@ -1358,7 +1400,7 @@ start_gnome_contacts (FolksIndividual *individual) static void individual_info_menu_item_activate_cb (FolksIndividual *individual) { - start_gnome_contacts (individual); + start_gnome_contacts (individual, TRUE); } static GtkWidget * @@ -1377,7 +1419,7 @@ empathy_individual_info_menu_item_new (FolksIndividual *individual) gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); gtk_widget_show (image); - g_signal_connect_swapped (item, "activate", + g_signal_connect (item, "activate", G_CALLBACK (individual_info_menu_item_activate_cb), individual); -- cgit v1.2.3