aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-individual-dialogs.c8
-rw-r--r--libempathy-gtk/empathy-individual-dialogs.h1
-rw-r--r--libempathy-gtk/empathy-individual-view.c170
3 files changed, 111 insertions, 68 deletions
diff --git a/libempathy-gtk/empathy-individual-dialogs.c b/libempathy-gtk/empathy-individual-dialogs.c
index b5f41db13..2e88a742b 100644
--- a/libempathy-gtk/empathy-individual-dialogs.c
+++ b/libempathy-gtk/empathy-individual-dialogs.c
@@ -179,6 +179,7 @@ contact_pretty_name (TpContact *contact)
gboolean
empathy_block_individual_dialog_show (GtkWindow *parent,
FolksIndividual *individual,
+ GdkPixbuf *avatar,
gboolean *abusive)
{
EmpathyContactManager *contact_manager =
@@ -198,6 +199,13 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
_("Block %s?"),
folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)));
+ 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);
+ }
+
/* build a list of personas that support blocking */
personas = folks_individual_get_personas (individual);
diff --git a/libempathy-gtk/empathy-individual-dialogs.h b/libempathy-gtk/empathy-individual-dialogs.h
index 1444d5ac8..e07105676 100644
--- a/libempathy-gtk/empathy-individual-dialogs.h
+++ b/libempathy-gtk/empathy-individual-dialogs.h
@@ -34,6 +34,7 @@ void empathy_new_individual_dialog_show_with_individual (GtkWindow *parent,
FolksIndividual *individual);
gboolean empathy_block_individual_dialog_show (GtkWindow *parent,
FolksIndividual *individual,
+ GdkPixbuf *avatar,
gboolean *abusive);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index 5cd2afacb..634c391a8 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -2275,7 +2275,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;
@@ -2283,6 +2284,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;
@@ -2329,7 +2337,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 ();
@@ -2399,89 +2407,115 @@ 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;
+ GdkPixbuf *avatar;
+ EmpathyIndividualManager *manager;
+ gchar *text;
+ GtkWindow *parent;
+ GList *l, *personas;
+ guint persona_count = 0;
+ 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;
- GList *l, *personas;
- guint persona_count = 0;
- gboolean can_block;
- int res;
+ DEBUG ("Could not get avatar: %s", error->message);
+ g_error_free (error);
+ }
- personas = folks_individual_get_personas (individual);
+ /* We couldn't retrieve the avatar, but that isn't a fatal error,
+ * so we still display the remove dialog. */
- /* If we have more than one TpfPersona, display a different message
- * ensuring the user knows that *all* of the meta-contacts' personas will
- * be removed. */
- for (l = personas; l != NULL; l = l->next)
- {
- if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
- continue;
+ personas = folks_individual_get_personas (individual);
- persona_count++;
- if (persona_count >= 2)
- break;
- }
+ /* If we have more than one TpfPersona, display a different message
+ * ensuring the user knows that *all* of the meta-contacts' personas will
+ * be removed. */
+ for (l = personas; l != NULL; l = l->next)
+ {
+ if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
+ continue;
- if (persona_count < 2)
- {
- /* Not a meta-contact */
- text =
- g_strdup_printf (
- _("Do you really want to remove the contact '%s'?"),
- folks_alias_details_get_alias (
- FOLKS_ALIAS_DETAILS (individual)));
- }
- else
- {
- /* Meta-contact */
- text =
- g_strdup_printf (
- _("Do you really want to remove the linked contact '%s'? "
- "Note that this will remove all the contacts which make up "
- "this linked contact."),
- folks_alias_details_get_alias (
- FOLKS_ALIAS_DETAILS (individual)));
- }
+ persona_count++;
+ if (persona_count >= 2)
+ break;
+ }
+ if (persona_count < 2)
+ {
+ /* Not a meta-contact */
+ text =
+ g_strdup_printf (
+ _("Do you really want to remove the contact '%s'?"),
+ folks_alias_details_get_alias (
+ FOLKS_ALIAS_DETAILS (individual)));
+ }
+ else
+ {
+ /* Meta-contact */
+ text =
+ g_strdup_printf (
+ _("Do you really want to remove the linked contact '%s'? "
+ "Note that this will remove all the contacts which make up "
+ "this linked contact."),
+ folks_alias_details_get_alias (
+ FOLKS_ALIAS_DETAILS (individual)));
+ }
- manager = empathy_individual_manager_dup_singleton ();
- can_block = empathy_individual_manager_supports_blocking (manager,
- individual);
- parent = empathy_get_toplevel_window (GTK_WIDGET (view));
- 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);
+ parent = empathy_get_toplevel_window (GTK_WIDGET (view));
+ res = individual_view_remove_dialog_show (parent, _("Removing contact"),
+ text, can_block, avatar);
- if (res == REMOVE_DIALOG_RESPONSE_DELETE_AND_BLOCK)
- {
- if (!empathy_block_individual_dialog_show (parent, individual,
- &abusive))
- goto finally;
+ if (res == REMOVE_DIALOG_RESPONSE_DELETE ||
+ res == REMOVE_DIALOG_RESPONSE_DELETE_AND_BLOCK)
+ {
+ gboolean abusive;
- empathy_individual_manager_set_blocked (manager, individual,
- TRUE, 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 (individual);
+ 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);
}
}