From 9c9fcb09c9dd2523fc53858d84b44eb19fd1a7bf Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 27 Jul 2012 15:16:40 +0200 Subject: [PATCH] EmpathyContactWidget: Stop using EmpathyAvatarChooser Changing avatar is only used for editing user's information, and it will soon be replaced by a dedicated widget. This is done to make easier to change EmpathyAvatarChooser's API before introducing the new widget. https://bugzilla.gnome.org/show_bug.cgi?id=680449 --- libempathy-gtk/empathy-contact-widget.c | 109 +----------------------- libempathy-gtk/empathy-contact-widget.h | 3 - src/empathy-accounts-dialog.c | 6 -- 3 files changed, 1 insertion(+), 117 deletions(-) diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index d28d980e..36d00a26 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -1121,49 +1121,6 @@ widget_avatar_button_press_event_cb (GtkWidget *widget, return FALSE; } -static void -set_avatar_cb (GObject *source, - GAsyncResult *res, - gpointer user_data) -{ - GError *error = NULL; - - if (!tp_account_set_avatar_finish (TP_ACCOUNT (source), res, &error)) { - DEBUG ("Failed to set Account.Avatar: %s", error->message); - g_error_free (error); - } -} - -static void -set_avatar_on_account (TpAccount *account, - const gchar *data, - gsize size, - const gchar *mime_type) -{ - DEBUG ("%s Account.Avatar on %s", size > 0 ? "Set": "Clear", - tp_proxy_get_object_path (account)); - - tp_account_set_avatar_async (account, (const guchar *) data, size, - mime_type, set_avatar_cb, NULL); -} - -static void -contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser, - EmpathyContactWidget *self) -{ - const gchar *data; - gsize size; - const gchar *mime_type; - TpAccount *account; - - empathy_avatar_chooser_get_image_data ( - EMPATHY_AVATAR_CHOOSER (self->priv->widget_avatar), - &data, &size, &mime_type); - - account = empathy_contact_get_account (self->priv->contact); - set_avatar_on_account (account, data, size, mime_type); -} - static void set_nickname_cb (GObject *source, GAsyncResult *res, @@ -1257,42 +1214,6 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable *editable, return FALSE; } -static void -update_avatar_chooser_account_cb (EmpathyAccountChooser *account_chooser, - EmpathyAvatarChooser *avatar_chooser) -{ - TpAccount *account; - - account = empathy_account_chooser_get_account (account_chooser); - if (account == NULL) - return; - - empathy_avatar_chooser_set_account (avatar_chooser, account); -} - -static void -contact_widget_avatar_notify_cb (EmpathyContactWidget *self) -{ - EmpathyAvatar *avatar = NULL; - - if (self->priv->contact) - avatar = empathy_contact_get_avatar (self->priv->contact); - - if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR) - { - g_signal_handlers_block_by_func (self->priv->widget_avatar, - contact_widget_avatar_changed_cb, - self); - empathy_avatar_chooser_set ( - EMPATHY_AVATAR_CHOOSER (self->priv->widget_avatar), avatar); - g_signal_handlers_unblock_by_func (self->priv->widget_avatar, - contact_widget_avatar_changed_cb, self); - } - else - empathy_avatar_image_set ( - EMPATHY_AVATAR_IMAGE (self->priv->widget_avatar), avatar); -} - static void contact_widget_name_notify_cb (EmpathyContactWidget *self) { @@ -1335,8 +1256,6 @@ contact_widget_remove_contact (EmpathyContactWidget *self) contact_widget_name_notify_cb, self); g_signal_handlers_disconnect_by_func (self->priv->contact, contact_widget_presence_notify_cb, self); - g_signal_handlers_disconnect_by_func (self->priv->contact, - contact_widget_avatar_notify_cb, self); tp_contact = empathy_contact_get_tp_contact (self->priv->contact); if (tp_contact != NULL) @@ -1374,8 +1293,6 @@ contact_widget_contact_update (EmpathyContactWidget *self) g_signal_connect_swapped (self->priv->contact, "notify::presence-message", G_CALLBACK (contact_widget_presence_notify_cb), self); - g_signal_connect_swapped (self->priv->contact, "notify::avatar", - G_CALLBACK (contact_widget_avatar_notify_cb), self); account = empathy_contact_get_account (self->priv->contact); id = empathy_contact_get_id (self->priv->contact); @@ -1397,12 +1314,6 @@ contact_widget_contact_update (EmpathyContactWidget *self) } else { - if (EMPATHY_IS_AVATAR_CHOOSER (self->priv->widget_avatar)) - { - empathy_avatar_chooser_set_account ( - EMPATHY_AVATAR_CHOOSER (self->priv->widget_avatar), account); - } - if ((self->priv->flags & EMPATHY_CONTACT_WIDGET_NO_ACCOUNT) == 0) { if (account) @@ -1432,7 +1343,6 @@ contact_widget_contact_update (EmpathyContactWidget *self) { contact_widget_name_notify_cb (self); contact_widget_presence_notify_cb (self); - contact_widget_avatar_notify_cb (self); gtk_widget_show (self->priv->label_alias); gtk_widget_show (self->priv->widget_alias); @@ -1639,24 +1549,7 @@ contact_widget_contact_setup (EmpathyContactWidget *self) gtk_widget_show (self->priv->widget_account); } - /* Set up avatar chooser/display */ - if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR) - { - self->priv->widget_avatar = empathy_avatar_chooser_new (); - g_signal_connect (self->priv->widget_avatar, "changed", - G_CALLBACK (contact_widget_avatar_changed_cb), - self); - if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) - { - g_signal_connect (self->priv->widget_account, "changed", - G_CALLBACK (update_avatar_chooser_account_cb), - self->priv->widget_avatar); - update_avatar_chooser_account_cb ( - EMPATHY_ACCOUNT_CHOOSER (self->priv->widget_account), - EMPATHY_AVATAR_CHOOSER (self->priv->widget_avatar)); - } - } - else + /* Set up avatar display */ { self->priv->widget_avatar = empathy_avatar_image_new (); diff --git a/libempathy-gtk/empathy-contact-widget.h b/libempathy-gtk/empathy-contact-widget.h index bf4acaf8..00423c7f 100644 --- a/libempathy-gtk/empathy-contact-widget.h +++ b/libempathy-gtk/empathy-contact-widget.h @@ -77,8 +77,6 @@ GType empathy_contact_widget_get_type (void); * information about a contact. * @EMPATHY_CONTACT_WIDGET_EDIT_ALIAS: Show a #GtkEntry allowing changes to the * contact's alias. - * @EMPATHY_CONTACT_WIDGET_EDIT_AVATAR: Show an #EmpathyAvatarChooser allowing - * changes to the contact's avatar. * @EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT: Show an #EmpathyAccountChooser allowing * changes to the contact's account. * @EMPATHY_CONTACT_WIDGET_EDIT_ID: Show a #GtkEntry allowing changes to the @@ -95,7 +93,6 @@ typedef enum { EMPATHY_CONTACT_WIDGET_EDIT_NONE = 0, EMPATHY_CONTACT_WIDGET_EDIT_ALIAS = 1 << 0, - EMPATHY_CONTACT_WIDGET_EDIT_AVATAR = 1 << 1, EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT = 1 << 2, EMPATHY_CONTACT_WIDGET_EDIT_ID = 1 << 3, EMPATHY_CONTACT_WIDGET_EDIT_GROUPS = 1 << 4, diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index ecbcbf00..92d0ffcc 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -799,7 +799,6 @@ create_contact_info_editor (EmpathyAccountsDialog *self, GtkWidget *editor, *alig; EmpathyContact *contact; EmpathyContactWidgetFlags flags; - TpConnection *conn; contact = empathy_contact_dup_from_tp_contact (tp_contact); @@ -810,11 +809,6 @@ create_contact_info_editor (EmpathyAccountsDialog *self, EMPATHY_CONTACT_WIDGET_EDIT_DETAILS | EMPATHY_CONTACT_WIDGET_NO_ACCOUNT; - conn = tp_contact_get_connection (tp_contact); - if (tp_proxy_has_interface_by_id (conn, - TP_IFACE_QUARK_CONNECTION_INTERFACE_AVATARS)) - flags |= EMPATHY_CONTACT_WIDGET_EDIT_AVATAR; - /* create the contact info editor for this account */ editor = empathy_contact_widget_new (contact, flags); -- 2.39.2