]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-widget.c
Add en_GB in gitignore
[empathy.git] / libempathy-gtk / empathy-contact-widget.c
index fb09fa3b6b9be6a5695d8ab16c190b5ea44109a2..07058e4bcbc0e4dd6fdfbf4e6beb1c09a78abe4b 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <gtk/gtk.h>
 #include <glade/glade.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 
 #include <libmissioncontrol/mc-account.h>
 #include <telepathy-glib/util.h>
@@ -84,7 +84,7 @@ typedef struct
   /* Client */
   GtkWidget *vbox_client;
   GtkWidget *table_client;
-  GtkWidget *hbow_client_requested;
+  GtkWidget *hbox_client_requested;
 } EmpathyContactWidget;
 
 typedef struct
@@ -162,7 +162,7 @@ empathy_contact_widget_new (EmpathyContact *contact,
 
   information = g_slice_new0 (EmpathyContactWidget);
   information->flags = flags;
-  information->factory = empathy_contact_factory_new ();
+  information->factory = empathy_contact_factory_dup_singleton ();
 
   filename = empathy_file_lookup ("empathy-contact-widget.glade",
       "libempathy-gtk");
@@ -186,7 +186,7 @@ empathy_contact_widget_new (EmpathyContact *contact,
        "hbox_details_requested", &information->hbox_details_requested,
        "vbox_client", &information->vbox_client,
        "table_client", &information->table_client,
-       "hbox_client_requested", &information->hbow_client_requested,
+       "hbox_client_requested", &information->hbox_client_requested,
        NULL);
   g_free (filename);
 
@@ -493,31 +493,18 @@ widget_avatar_button_press_event_cb (GtkWidget *widget,
 }
 
 static void
-contact_widget_contact_setup (EmpathyContactWidget *information)
+update_avatar_chooser_account_cb (EmpathyAccountChooser *account_chooser,
+                                  EmpathyAvatarChooser *avatar_chooser)
 {
-  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR)
-    {
-      information->widget_avatar = empathy_avatar_chooser_new ();
-      g_signal_connect (information->widget_avatar, "changed",
-            G_CALLBACK (contact_widget_avatar_changed_cb),
-            information);
-    }
-  else
-    {
-      information->widget_avatar = empathy_avatar_image_new ();
+  McAccount *account;
 
-      g_signal_connect (information->widget_avatar, "popup-menu",
-          G_CALLBACK (widget_avatar_popup_menu_cb), information);
-      g_signal_connect (information->widget_avatar, "button-press-event",
-          G_CALLBACK (widget_avatar_button_press_event_cb), information);
-    }
-  
-  gtk_box_pack_start (GTK_BOX (information->vbox_avatar),
-          information->widget_avatar,
-          FALSE, FALSE,
-          6);
-  gtk_widget_show (information->widget_avatar);
+  account = empathy_account_chooser_get_account (account_chooser);
+  g_object_set (avatar_chooser, "account", account, NULL);
+}
 
+static void
+contact_widget_contact_setup (EmpathyContactWidget *information)
+{
   /* Setup account label/chooser */
   if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
     {
@@ -530,7 +517,7 @@ contact_widget_contact_setup (EmpathyContactWidget *information)
   else
     {
       information->widget_account = gtk_label_new (NULL);
-      if (!information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) {
+      if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
         gtk_label_set_selectable (GTK_LABEL (information->widget_account), TRUE);
       }
       gtk_misc_set_alignment (GTK_MISC (information->widget_account), 0, 0.5);
@@ -540,6 +527,39 @@ contact_widget_contact_setup (EmpathyContactWidget *information)
            1, 2, 0, 1);
   gtk_widget_show (information->widget_account);
 
+  /* Set up avatar chooser/display */
+  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR)
+    {
+      information->widget_avatar = empathy_avatar_chooser_new ();
+      g_signal_connect (information->widget_avatar, "changed",
+            G_CALLBACK (contact_widget_avatar_changed_cb),
+            information);
+      if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
+        {
+          g_signal_connect (information->widget_account, "changed",
+              G_CALLBACK (update_avatar_chooser_account_cb),
+              information->widget_avatar);
+          update_avatar_chooser_account_cb (
+              EMPATHY_ACCOUNT_CHOOSER (information->widget_account),
+              EMPATHY_AVATAR_CHOOSER (information->widget_avatar));
+        }
+    }
+  else
+    {
+      information->widget_avatar = empathy_avatar_image_new ();
+
+      g_signal_connect (information->widget_avatar, "popup-menu",
+          G_CALLBACK (widget_avatar_popup_menu_cb), information);
+      g_signal_connect (information->widget_avatar, "button-press-event",
+          G_CALLBACK (widget_avatar_button_press_event_cb), information);
+    }
+
+  gtk_box_pack_start (GTK_BOX (information->vbox_avatar),
+          information->widget_avatar,
+          FALSE, FALSE,
+          6);
+  gtk_widget_show (information->widget_avatar);
+
   /* Setup id label/entry */
   if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
     {
@@ -554,7 +574,7 @@ contact_widget_contact_setup (EmpathyContactWidget *information)
   else
     {
       information->widget_id = gtk_label_new (NULL);
-      if (!information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) {
+      if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
         gtk_label_set_selectable (GTK_LABEL (information->widget_id), TRUE);
       }
       gtk_misc_set_alignment (GTK_MISC (information->widget_id), 0, 0.5);
@@ -578,7 +598,7 @@ contact_widget_contact_setup (EmpathyContactWidget *information)
   else
     {
       information->widget_alias = gtk_label_new (NULL);
-      if (!information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) {
+      if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
         gtk_label_set_selectable (GTK_LABEL (information->widget_alias), TRUE);
       }
       gtk_misc_set_alignment (GTK_MISC (information->widget_alias), 0, 0.5);
@@ -683,7 +703,7 @@ contact_widget_change_contact (EmpathyContactWidget *information)
       const gchar *id;
 
       id = gtk_entry_get_text (GTK_ENTRY (information->widget_id));
-      if (G_STR_EMPTY (id))
+      if (EMP_STR_EMPTY (id))
           return;
 
       contact = empathy_contact_factory_get_from_id (information->factory,
@@ -808,7 +828,7 @@ contact_widget_groups_setup (EmpathyContactWidget *information)
 {
   if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS)
     {
-      information->manager = empathy_contact_manager_new ();
+      information->manager = empathy_contact_manager_dup_singleton ();
       contact_widget_model_setup (information);
     }
 }
@@ -959,7 +979,7 @@ contact_widget_model_find_name (EmpathyContactWidget *information,
   GtkTreeModel *model;
   FindName data;
 
-  if (G_STR_EMPTY (name))
+  if (EMP_STR_EMPTY (name))
       return FALSE;
 
   data.information = information;
@@ -1071,7 +1091,7 @@ contact_widget_entry_group_changed_cb (GtkEditable *editable,
       gtk_widget_set_sensitive (GTK_WIDGET (information->button_group), FALSE);
   else
       gtk_widget_set_sensitive (GTK_WIDGET (information->button_group),
-          !G_STR_EMPTY (group));
+          !EMP_STR_EMPTY (group));
 }
 
 static void