]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-widget.c
Add G_PARAM_STATIC_STRINGS to EmpathyContact properties
[empathy.git] / libempathy-gtk / empathy-contact-widget.c
index fa9fdefebb86c8c52446f7d36880b2ffc7c6e057..fc64d15c65b5c93fcb4755a83408fbcacde41c55 100644 (file)
@@ -157,7 +157,6 @@ empathy_contact_widget_new (EmpathyContact *contact,
 {
   EmpathyContactWidget *information;
   GtkBuilder *gui;
-  TpConnection *connection;
   gchar *filename;
 
   g_return_val_if_fail (contact == NULL || EMPATHY_IS_CONTACT (contact), NULL);
@@ -690,40 +689,26 @@ contact_widget_contact_update (EmpathyContactWidget *information)
 
 static void
 contact_widget_got_contact_cb (EmpathyTpContactFactory *factory,
-                               GList *contacts,
+                               EmpathyContact *contact,
+                               const GError *error,
                                gpointer user_data,
                                GObject *weak_object)
 {
   EmpathyContactWidget *information = user_data;
 
-  contact_widget_set_contact (information, contacts->data);
-}
-
-static void
-contact_widget_get_self_handle_cb (TpConnection *connection,
-                                   TpHandle self_handle,
-                                   const GError *error,
-                                   gpointer information,
-                                   GObject *weak_object)
-{
-  EmpathyTpContactFactory *factory;
-
   if (error != NULL)
     {
       DEBUG ("Error: %s", error->message);
       return;
     }
 
-  factory = empathy_tp_contact_factory_dup_singleton (connection);
-  empathy_tp_contact_factory_get_from_handles (factory, 1, &self_handle,
-      contact_widget_got_contact_cb, information, NULL,
-      weak_object);
-  g_object_unref (factory);
+  contact_widget_set_contact (information, contact);
 }
 
 static void
 contact_widget_change_contact (EmpathyContactWidget *information)
 {
+  EmpathyTpContactFactory *factory;
   TpConnection *connection;
 
   connection = empathy_account_chooser_get_connection (
@@ -731,6 +716,7 @@ contact_widget_change_contact (EmpathyContactWidget *information)
   if (!connection)
       return;
 
+  factory = empathy_tp_contact_factory_dup_singleton (connection);
   if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
     {
       const gchar *id;
@@ -738,40 +724,35 @@ contact_widget_change_contact (EmpathyContactWidget *information)
       id = gtk_entry_get_text (GTK_ENTRY (information->widget_id));
       if (!EMP_STR_EMPTY (id))
         {
-          EmpathyTpContactFactory *factory;
-
-          factory = empathy_tp_contact_factory_dup_singleton (connection);
-          empathy_tp_contact_factory_get_from_ids (factory, 1, &id,
+          empathy_tp_contact_factory_get_from_id (factory, id,
               contact_widget_got_contact_cb, information, NULL,
               G_OBJECT (information->vbox_contact_widget));
-          g_object_unref (factory);
         }
     }
   else
     {
-      /* FIXME: TpConnection should have a SelfHandle property */
-      tp_cli_connection_call_get_self_handle (connection, -1,
-          contact_widget_get_self_handle_cb, information, NULL,
+      empathy_tp_contact_factory_get_from_handle (factory,
+          tp_connection_get_self_handle (connection),
+          contact_widget_got_contact_cb, information, NULL,
           G_OBJECT (information->vbox_contact_widget));
     }
+
+  g_object_unref (factory);
 }
 
 static void
 contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser,
                                   EmpathyContactWidget *information)
 {
-  if (information->contact && empathy_contact_is_user (information->contact))
-    {
-      const gchar *data;
-      gsize size;
-      const gchar *mime_type;
-
-      empathy_avatar_chooser_get_image_data (
-          EMPATHY_AVATAR_CHOOSER (information->widget_avatar),
-          &data, &size, &mime_type);
-      empathy_tp_contact_factory_set_avatar (information->factory,
-          data, size, mime_type);
-    }
+  const gchar *data;
+  gsize size;
+  const gchar *mime_type;
+
+  empathy_avatar_chooser_get_image_data (
+      EMPATHY_AVATAR_CHOOSER (information->widget_avatar),
+      &data, &size, &mime_type);
+  empathy_tp_contact_factory_set_avatar (information->factory,
+      data, size, mime_type);
 }
 
 static gboolean