diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-02-08 00:12:15 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-02-08 21:30:43 +0800 |
commit | 05f8bd96c6fc3cc62995c24678730b9fcdda9112 (patch) | |
tree | 5210dd24b799b3c0ce8a18ad938f90b1a4643861 /libempathy-gtk | |
parent | 7429c7622ffad91a96df4d729637184c3044fed1 (diff) | |
download | gsoc2013-empathy-05f8bd96c6fc3cc62995c24678730b9fcdda9112.tar gsoc2013-empathy-05f8bd96c6fc3cc62995c24678730b9fcdda9112.tar.gz gsoc2013-empathy-05f8bd96c6fc3cc62995c24678730b9fcdda9112.tar.bz2 gsoc2013-empathy-05f8bd96c6fc3cc62995c24678730b9fcdda9112.tar.lz gsoc2013-empathy-05f8bd96c6fc3cc62995c24678730b9fcdda9112.tar.xz gsoc2013-empathy-05f8bd96c6fc3cc62995c24678730b9fcdda9112.tar.zst gsoc2013-empathy-05f8bd96c6fc3cc62995c24678730b9fcdda9112.zip |
Try installing gnome-contacts using PackageKit
https://bugzilla.gnome.org/show_bug.cgi?id=669578
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-individual-menu.c | 52 |
1 files 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 <libempathy/empathy-chatroom-manager.h> #include <libempathy/empathy-utils.h> #include <libempathy/empathy-contact-list.h> +#include <libempathy/empathy-pkg-kit.h> #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); |