]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-widget.c
Remove EmpathyPresence object and have "presence" and "presence-message" properties...
[empathy.git] / libempathy-gtk / empathy-contact-widget.c
index 2fa1b3d9f1911a1ac313cbf0b97c694909de4c69..c290ef6a3030b212efb222f080dc7e37fb876379 100644 (file)
@@ -223,6 +223,23 @@ empathy_contact_widget_get_contact (GtkWidget *widget)
        return information->contact;
 }
 
+void
+empathy_contact_widget_set_contact (GtkWidget      *widget,
+                                   EmpathyContact *contact)
+{
+       EmpathyContactWidget *information;
+
+       g_return_if_fail (GTK_IS_WIDGET (widget));
+       g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
+       information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
+       if (!information) {
+               return;
+       }
+
+       contact_widget_set_contact (information, contact);
+}
+
 void
 empathy_contact_widget_set_account_filter (GtkWidget                       *widget,
                                           EmpathyAccountChooserFilterFunc  filter,
@@ -289,6 +306,12 @@ static void
 contact_widget_set_contact (EmpathyContactWidget *information,
                            EmpathyContact        *contact)
 {
+       if (contact == information->contact ||
+           (contact && information->contact &&
+            empathy_contact_equal (contact, information->contact))) {
+               return;
+       }
+
        contact_widget_remove_contact (information);
        if (contact) {
                information->contact = g_object_ref (contact);
@@ -406,6 +429,9 @@ contact_widget_contact_update (EmpathyContactWidget *information)
                g_signal_connect_swapped (information->contact, "notify::presence",
                                          G_CALLBACK (contact_widget_presence_notify_cb),
                                          information);
+               g_signal_connect_swapped (information->contact, "notify::presence-message",
+                                         G_CALLBACK (contact_widget_presence_notify_cb),
+                                         information);
                g_signal_connect_swapped (information->contact, "notify::avatar",
                                          G_CALLBACK (contact_widget_avatar_notify_cb),
                                          information);
@@ -495,14 +521,20 @@ static void
 contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser,
                                  EmpathyContactWidget *information)
 {
-       McAccount *account;
-       gchar     *data;
-       gsize      size;
+       if (information->contact &&
+           empathy_contact_is_user (information->contact)) {
+               McAccount   *account;
+               const gchar *data;
+               gsize        size;
+               const gchar *mime_type;
 
-       account = empathy_contact_get_account (information->contact);
-       empathy_avatar_chooser_get_image_data (EMPATHY_AVATAR_CHOOSER (information->widget_avatar),
-                                              &data, &size);
-       mc_account_set_avatar_from_data (account, data, size, "png");
+               account = empathy_contact_get_account (information->contact);
+               empathy_avatar_chooser_get_image_data (EMPATHY_AVATAR_CHOOSER (information->widget_avatar),
+                                                      &data, &size, &mime_type);
+               empathy_contact_factory_set_avatar (information->factory,
+                                                   account,
+                                                   data, size, mime_type);
+       }
 }
 
 static void
@@ -527,12 +559,12 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable          *editable,
                                           EmpathyContactWidget *information)
 {
        if (information->contact) {
-               const gchar *name;
+               const gchar *alias;
 
-               name = gtk_entry_get_text (GTK_ENTRY (editable));
-               empathy_contact_factory_set_name (information->factory,
+               alias = gtk_entry_get_text (GTK_ENTRY (editable));
+               empathy_contact_factory_set_alias (information->factory,
                                                  information->contact,
-                                                 name);
+                                                 alias);
        }
 
        return FALSE;