]> git.0d.be Git - empathy.git/commitdiff
EmpathyUserInfo: Update identifier/alias when they change on the account
authorXavier Claessens <xavier.claessens@collabora.co.uk>
Thu, 8 Aug 2013 12:50:26 +0000 (14:50 +0200)
committerXavier Claessens <xavier.claessens@collabora.co.uk>
Fri, 9 Aug 2013 08:43:53 +0000 (10:43 +0200)
When the account goes online the account's nickname quickly changes from
the identifier to the actual nickname from the self VCard.

Identifier can change as well when editing account settings.

https://bugzilla.gnome.org/show_bug.cgi?id=705668

libempathy-gtk/empathy-user-info.c

index 451caec8e9fcfe9f508c14cef271119e9e3f8b18..a814c1545dbaed61d770efa4e715af4bc8501e0d 100644 (file)
@@ -38,6 +38,7 @@ struct _EmpathyUserInfoPrivate
   TpAccount *account;
 
   GtkWidget *avatar_chooser;
+  GtkWidget *identifier_label;
   GtkWidget *nickname_entry;
   GtkWidget *details_label;
   GtkWidget *details_spinner;
@@ -438,13 +439,30 @@ connection_notify_cb (EmpathyUserInfo *self)
   reload_contact_info (self);
 }
 
+static void
+identifier_notify_cb (TpAccount *account,
+    GParamSpec *param_spec,
+    EmpathyUserInfo *self)
+{
+  gtk_label_set_label (GTK_LABEL (self->priv->identifier_label),
+      tp_account_get_normalized_name (self->priv->account));
+}
+
+static void
+nickname_notify_cb (TpAccount *account,
+    GParamSpec *param_spec,
+    EmpathyUserInfo *self)
+{
+  gtk_entry_set_text (GTK_ENTRY (self->priv->nickname_entry),
+      tp_account_get_nickname (self->priv->account));
+}
+
 static void
 empathy_user_info_constructed (GObject *object)
 {
   EmpathyUserInfo *self = (EmpathyUserInfo *) object;
   GtkGrid *grid = (GtkGrid *) self;
   GtkWidget *title;
-  GtkWidget *value;
 
   G_OBJECT_CLASS (empathy_user_info_parent_class)->constructed (object);
 
@@ -453,8 +471,11 @@ empathy_user_info_constructed (GObject *object)
 
   /* Setup id label */
   title = gtk_label_new (_("Identifier"));
-  value = gtk_label_new (tp_account_get_normalized_name (self->priv->account));
-  add_row (grid, title, value, FALSE);
+  self->priv->identifier_label = gtk_label_new (
+      tp_account_get_normalized_name (self->priv->account));
+  add_row (grid, title, self->priv->identifier_label, FALSE);
+  g_signal_connect_object (self->priv->account, "notify::normalized-name",
+      G_CALLBACK (identifier_notify_cb), self, 0);
 
   /* Setup nickname entry */
   title = gtk_label_new (_("Alias"));
@@ -462,6 +483,8 @@ empathy_user_info_constructed (GObject *object)
   gtk_entry_set_text (GTK_ENTRY (self->priv->nickname_entry),
       tp_account_get_nickname (self->priv->account));
   add_row (grid, title, self->priv->nickname_entry, FALSE);
+  g_signal_connect_object (self->priv->account, "notify::nickname",
+      G_CALLBACK (nickname_notify_cb), self, 0);
 
   /* Set up avatar chooser */
   self->priv->avatar_chooser = empathy_avatar_chooser_new (self->priv->account);