aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-individual-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy-gtk/empathy-individual-view.c')
-rw-r--r--libempathy-gtk/empathy-individual-view.c112
1 files changed, 73 insertions, 39 deletions
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index b121801bd..90a9fc6db 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -2237,7 +2237,8 @@ static int
individual_view_remove_dialog_show (GtkWindow *parent,
const gchar *message,
const gchar *secondary_text,
- gboolean block_button)
+ gboolean block_button,
+ GdkPixbuf *avatar)
{
GtkWidget *dialog;
gboolean res;
@@ -2245,6 +2246,13 @@ individual_view_remove_dialog_show (GtkWindow *parent,
dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", message);
+ if (avatar != NULL)
+ {
+ GtkWidget *image = gtk_image_new_from_pixbuf (avatar);
+ gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image);
+ gtk_widget_show (image);
+ }
+
if (block_button)
{
GtkWidget *button;
@@ -2292,7 +2300,7 @@ individual_view_group_remove_activate_cb (GtkMenuItem *menuitem,
group);
parent = empathy_get_toplevel_window (GTK_WIDGET (view));
if (individual_view_remove_dialog_show (parent, _("Removing group"),
- text, FALSE) == REMOVE_DIALOG_RESPONSE_DELETE)
+ text, FALSE, NULL) == REMOVE_DIALOG_RESPONSE_DELETE)
{
EmpathyIndividualManager *manager =
empathy_individual_manager_dup_singleton ();
@@ -2362,55 +2370,81 @@ empathy_individual_view_get_group_menu (EmpathyIndividualView *view)
}
static void
-individual_view_remove_activate_cb (GtkMenuItem *menuitem,
- EmpathyIndividualView *view)
+got_avatar (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- FolksIndividual *individual;
+ FolksIndividual *individual = FOLKS_INDIVIDUAL (source_object);
+ EmpathyIndividualView *view = user_data;
+ EmpathyIndividualManager *manager;
+ GdkPixbuf *avatar;
+ gchar *text;
+ GtkWindow *parent;
+ gboolean can_block;
+ GError *error = NULL;
+ gint res;
- individual = empathy_individual_view_dup_selected (view);
+ avatar = empathy_pixbuf_avatar_from_individual_scaled_finish (individual,
+ result, &error);
- if (individual != NULL)
+ if (error != NULL)
{
- EmpathyIndividualManager *manager;
- gchar *text;
- GtkWindow *parent;
- gboolean can_block;
- int res;
+ DEBUG ("Could not get avatar: %s", error->message);
+ g_error_free (error);
+ }
- manager = empathy_individual_manager_dup_singleton ();
- can_block = empathy_individual_manager_supports_blocking (manager,
- individual);
+ /* We couldn't retrieve the avatar, but that isn't a fatal error,
+ * so we still display the remove dialog. */
- parent = empathy_get_toplevel_window (GTK_WIDGET (view));
- text =
- g_strdup_printf (
- _("Are you sure you want to remove '%s' from your contacts?"),
- folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)));
- res = individual_view_remove_dialog_show (parent, _("Removing contact"),
- text, can_block);
-
- if (res == REMOVE_DIALOG_RESPONSE_DELETE ||
- res == REMOVE_DIALOG_RESPONSE_DELETE_AND_BLOCK)
- {
- gboolean abusive;
+ manager = empathy_individual_manager_dup_singleton ();
+ can_block = empathy_individual_manager_supports_blocking (manager,
+ individual);
- if (res == REMOVE_DIALOG_RESPONSE_DELETE_AND_BLOCK)
- {
- if (!empathy_block_individual_dialog_show (parent, individual,
- &abusive))
- goto finally;
+ parent = empathy_get_toplevel_window (GTK_WIDGET (view));
+ text =
+ g_strdup_printf (
+ _("Are you sure you want to remove '%s' from your contacts?"),
+ folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)));
- empathy_individual_manager_set_blocked (manager, individual,
- TRUE, abusive);
- }
+ res = individual_view_remove_dialog_show (parent, _("Removing contact"),
+ text, can_block, avatar);
+
+ if (res == REMOVE_DIALOG_RESPONSE_DELETE ||
+ res == REMOVE_DIALOG_RESPONSE_DELETE_AND_BLOCK)
+ {
+ gboolean abusive;
+
+ if (res == REMOVE_DIALOG_RESPONSE_DELETE_AND_BLOCK)
+ {
+ if (!empathy_block_individual_dialog_show (parent, individual,
+ avatar, &abusive))
+ goto finally;
- empathy_individual_manager_remove (manager, individual, "");
+ empathy_individual_manager_set_blocked (manager, individual,
+ TRUE, abusive);
}
-finally:
- g_free (text);
+ empathy_individual_manager_remove (manager, individual, "");
+ }
+
+ finally:
+ g_free (text);
+ g_object_unref (manager);
+}
+
+static void
+individual_view_remove_activate_cb (GtkMenuItem *menuitem,
+ EmpathyIndividualView *view)
+{
+ FolksIndividual *individual;
+
+ individual = empathy_individual_view_dup_selected (view);
+
+ if (individual != NULL)
+ {
+ empathy_pixbuf_avatar_from_individual_scaled_async (individual,
+ 48, 48, NULL, got_avatar, view);
g_object_unref (individual);
- g_object_unref (manager);
}
}