]> git.0d.be Git - empathy.git/commitdiff
turn EmpathyContactWidget to be a proper GtkWidget
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 10 May 2012 12:55:39 +0000 (14:55 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 15 May 2012 09:48:15 +0000 (11:48 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=675803

libempathy-gtk/empathy-contact-widget.c
libempathy-gtk/empathy-contact-widget.h

index ee896d5b72ec0e3b5cdbba80a7eeae211a5767cb..22e4085077094a340a1f494f03fb180dc2b33011 100644 (file)
  * also allowing changing these details, if desired.
  */
 
+G_DEFINE_TYPE (EmpathyContactWidget, empathy_contact_widget, GTK_TYPE_BOX)
+
 /* Delay before updating the widget when the id entry changed (seconds) */
 #define ID_CHANGED_TIMEOUT 1
 
 #define DATA_FIELD "contact-info-field"
 
-typedef struct
+struct _EmpathyContactWidgetPriv
 {
   EmpathyContact *contact;
   EmpathyContactWidgetFlags flags;
   guint widget_id_timeout;
   gulong fav_sig_id;
 
-  GtkWidget *vbox_contact_widget;
-
   /* Contact */
   GtkWidget *widget_avatar;
   GtkWidget *widget_account;
@@ -131,11 +131,11 @@ typedef struct
   GtkWidget *vbox_client;
   GtkWidget *grid_client;
   GtkWidget *hbox_client_requested;
-} EmpathyContactWidget;
+};
 
 typedef struct
 {
-  EmpathyContactWidget *information;
+  EmpathyContactWidget *self;
   const gchar *name;
   gboolean found;
   GtkTreeIter found_iter;
@@ -186,15 +186,15 @@ set_contact_info_cb (GObject *source,
 }
 
 static void
-contact_widget_save (EmpathyContactWidget *information)
+contact_widget_save (EmpathyContactWidget *self)
 {
   TpConnection *connection;
   GList *l, *next;
 
-  connection = empathy_contact_get_connection (information->contact);
+  connection = empathy_contact_get_connection (self->priv->contact);
 
   /* Remove empty fields */
-  for (l = information->details_to_set; l != NULL; l = next)
+  for (l = self->priv->details_to_set; l != NULL; l = next)
     {
       TpContactInfoField *field = l->data;
 
@@ -203,33 +203,33 @@ contact_widget_save (EmpathyContactWidget *information)
         {
           DEBUG ("Drop empty field: %s", field->field_name);
           tp_contact_info_field_free (field);
-          information->details_to_set =
-              g_list_delete_link (information->details_to_set, l);
+          self->priv->details_to_set =
+              g_list_delete_link (self->priv->details_to_set, l);
         }
     }
 
-  if (information->details_to_set != NULL)
+  if (self->priv->details_to_set != NULL)
     {
-      if (information->details_changed)
+      if (self->priv->details_changed)
         {
           tp_connection_set_contact_info_async (connection,
-              information->details_to_set, set_contact_info_cb, NULL);
+              self->priv->details_to_set, set_contact_info_cb, NULL);
         }
 
-      tp_contact_info_list_free (information->details_to_set);
-      information->details_to_set = NULL;
+      tp_contact_info_list_free (self->priv->details_to_set);
+      self->priv->details_to_set = NULL;
     }
 }
 
 static void
-contact_widget_details_setup (EmpathyContactWidget *information)
+contact_widget_details_setup (EmpathyContactWidget *self)
 {
-  gtk_widget_hide (information->vbox_details);
+  gtk_widget_hide (self->priv->vbox_details);
 
-  information->spinner_details = gtk_spinner_new ();
-  gtk_box_pack_end (GTK_BOX (information->hbox_details_requested),
-      information->spinner_details, TRUE, TRUE, 0);
-  gtk_widget_show (information->spinner_details);
+  self->priv->spinner_details = gtk_spinner_new ();
+  gtk_box_pack_end (GTK_BOX (self->priv->hbox_details_requested),
+      self->priv->spinner_details, TRUE, TRUE, 0);
+  gtk_widget_show (self->priv->spinner_details);
 }
 
 static void
@@ -239,7 +239,7 @@ contact_widget_details_changed_cb (GtkEntry *entry,
   const gchar *strv[] = { NULL, NULL };
   TpContactInfoField *field;
 
-  self->details_changed = TRUE;
+  self->priv->details_changed = TRUE;
 
   field = g_object_get_data ((GObject *) entry, DATA_FIELD);
   g_assert (field != NULL);
@@ -259,7 +259,7 @@ contact_widget_bday_changed_cb (EmpathyCalendarButton *button,
   const gchar *strv[] = { NULL, NULL };
   TpContactInfoField *field;
 
-  self->details_changed = TRUE;
+  self->priv->details_changed = TRUE;
 
   field = g_object_get_data ((GObject *) button, DATA_FIELD);
   g_assert (field != NULL);
@@ -278,7 +278,7 @@ contact_widget_bday_changed_cb (EmpathyCalendarButton *button,
   field->field_value = g_strdupv ((GStrv) strv);
 }
 
-static void contact_widget_details_notify_cb (EmpathyContactWidget *information);
+static void contact_widget_details_notify_cb (EmpathyContactWidget *self);
 
 static gboolean
 field_name_in_field_list (GList *list,
@@ -315,7 +315,7 @@ get_spec_from_list (GList *list,
 }
 
 static guint
-contact_widget_details_update_edit (EmpathyContactWidget *information)
+contact_widget_details_update_edit (EmpathyContactWidget *self)
 {
   TpContact *contact;
   TpConnection *connection;
@@ -325,11 +325,11 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
   const char **field_names = empathy_contact_info_get_field_names (NULL);
   guint i;
 
-  g_assert (information->details_to_set == NULL);
+  g_assert (self->priv->details_to_set == NULL);
 
-  information->details_changed = FALSE;
+  self->priv->details_changed = FALSE;
 
-  contact = empathy_contact_get_tp_contact (information->contact);
+  contact = empathy_contact_get_tp_contact (self->priv->contact);
   connection = tp_contact_get_connection (contact);
 
   info = tp_contact_get_contact_info (contact);
@@ -345,7 +345,7 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
       field = tp_contact_info_field_copy (field);
       DEBUG ("Field %s is in our vCard", field->field_name);
 
-      information->details_to_set = g_list_prepend (information->details_to_set,
+      self->priv->details_to_set = g_list_prepend (self->priv->details_to_set,
           field);
     }
 
@@ -356,7 +356,7 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
       TpContactInfoField *field;
 
       /* Check if the field was in the vCard */
-      if (field_name_in_field_list (information->details_to_set,
+      if (field_name_in_field_list (self->priv->details_to_set,
             field_names[i]))
         continue;
 
@@ -368,15 +368,15 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
       /* add an empty field so user can set a value */
       field = tp_contact_info_field_new (spec->name, spec->parameters, NULL);
 
-      information->details_to_set = g_list_prepend (information->details_to_set,
+      self->priv->details_to_set = g_list_prepend (self->priv->details_to_set,
           field);
     }
 
   /* Add widgets for supported fields */
-  information->details_to_set = g_list_sort (information->details_to_set,
+  self->priv->details_to_set = g_list_sort (self->priv->details_to_set,
       (GCompareFunc) empathy_contact_info_field_spec_cmp);
 
-  for (l = information->details_to_set; l != NULL; l= g_list_next (l))
+  for (l = self->priv->details_to_set; l != NULL; l= g_list_next (l))
     {
       TpContactInfoField *field = l->data;
       GtkWidget *w;
@@ -417,7 +417,7 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
       /* TODO: if TP_CONTACT_INFO_FIELD_FLAG_PARAMETERS_EXACT is not set we
        * should allow user to tag the vCard fields (bgo#672034) */
 
-      gtk_grid_attach (GTK_GRID (information->grid_details),
+      gtk_grid_attach (GTK_GRID (self->priv->grid_details),
           w, 0, n_rows, 1, 1);
 
       gtk_misc_set_alignment (GTK_MISC (w), 1, 0.5);
@@ -440,28 +440,28 @@ contact_widget_details_update_edit (EmpathyContactWidget *information)
                 }
             }
 
-          gtk_grid_attach (GTK_GRID (information->grid_details),
+          gtk_grid_attach (GTK_GRID (self->priv->grid_details),
               w, 1, n_rows, 1, 1);
           gtk_widget_show_all (w);
 
           g_object_set_data ((GObject *) w, DATA_FIELD, field);
 
           g_signal_connect (w, "date-changed",
-            G_CALLBACK (contact_widget_bday_changed_cb), information);
+            G_CALLBACK (contact_widget_bday_changed_cb), self);
         }
       else
         {
           w = gtk_entry_new ();
           gtk_entry_set_text (GTK_ENTRY (w),
               field->field_value[0] ? field->field_value[0] : "");
-          gtk_grid_attach (GTK_GRID (information->grid_details),
+          gtk_grid_attach (GTK_GRID (self->priv->grid_details),
               w, 1, n_rows, 1, 1);
           gtk_widget_show (w);
 
           g_object_set_data ((GObject *) w, DATA_FIELD, field);
 
           g_signal_connect (w, "changed",
-            G_CALLBACK (contact_widget_details_changed_cb), information);
+            G_CALLBACK (contact_widget_details_changed_cb), self);
         }
 
       n_rows++;
@@ -489,7 +489,7 @@ add_row (GtkGrid *grid,
 }
 
 static guint
-contact_widget_details_update_show (EmpathyContactWidget *information)
+contact_widget_details_update_show (EmpathyContactWidget *self)
 {
   TpContact *contact;
   GList *info, *l;
@@ -497,7 +497,7 @@ contact_widget_details_update_show (EmpathyContactWidget *information)
   GtkWidget *channels_label;
   TpAccount *account;
 
-  contact = empathy_contact_get_tp_contact (information->contact);
+  contact = empathy_contact_get_tp_contact (self->priv->contact);
   info = tp_contact_get_contact_info (contact);
   info = g_list_sort (info, (GCompareFunc) empathy_contact_info_field_cmp);
   for (l = info; l != NULL; l = l->next)
@@ -545,16 +545,16 @@ contact_widget_details_update_show (EmpathyContactWidget *information)
           g_free (markup);
         }
 
-      if ((information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) == 0)
+      if ((self->priv->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) == 0)
         gtk_label_set_selectable (GTK_LABEL (value_widget), TRUE);
 
-      add_row (GTK_GRID (information->grid_details), n_rows, title_widget,
+      add_row (GTK_GRID (self->priv->grid_details), n_rows, title_widget,
           value_widget);
 
       n_rows++;
     }
 
-  account = empathy_contact_get_account (information->contact);
+  account = empathy_contact_get_account (self->priv->contact);
 
   channels_label = empathy_contact_info_create_channel_list_label (account,
       info, n_rows);
@@ -565,7 +565,7 @@ contact_widget_details_update_show (EmpathyContactWidget *information)
 
       title_widget =  gtk_label_new (_("Channels:"));
 
-      add_row (GTK_GRID (information->grid_details), n_rows, title_widget,
+      add_row (GTK_GRID (self->priv->grid_details), n_rows, title_widget,
           channels_label);
 
       n_rows++;
@@ -577,30 +577,30 @@ contact_widget_details_update_show (EmpathyContactWidget *information)
 }
 
 static void
-contact_widget_details_notify_cb (EmpathyContactWidget *information)
+contact_widget_details_notify_cb (EmpathyContactWidget *self)
 {
   guint n_rows;
 
-  gtk_container_foreach (GTK_CONTAINER (information->grid_details),
+  gtk_container_foreach (GTK_CONTAINER (self->priv->grid_details),
       (GtkCallback) gtk_widget_destroy, NULL);
 
-  if ((information->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) != 0)
-    n_rows = contact_widget_details_update_edit (information);
+  if ((self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) != 0)
+    n_rows = contact_widget_details_update_edit (self);
   else
-    n_rows = contact_widget_details_update_show (information);
+    n_rows = contact_widget_details_update_show (self);
 
   if (n_rows > 0)
     {
-      gtk_widget_show (information->vbox_details);
-      gtk_widget_show (information->grid_details);
+      gtk_widget_show (self->priv->vbox_details);
+      gtk_widget_show (self->priv->grid_details);
     }
   else
     {
-      gtk_widget_hide (information->vbox_details);
+      gtk_widget_hide (self->priv->vbox_details);
     }
 
-  gtk_widget_hide (information->hbox_details_requested);
-  gtk_spinner_stop (GTK_SPINNER (information->spinner_details));
+  gtk_widget_hide (self->priv->hbox_details_requested);
+  gtk_spinner_stop (GTK_SPINNER (self->priv->spinner_details));
 }
 
 static void
@@ -609,40 +609,40 @@ contact_widget_details_request_cb (GObject *object,
     gpointer user_data)
 {
   TpContact *contact = TP_CONTACT (object);
-  EmpathyContactWidget *information = user_data;
+  EmpathyContactWidget *self = user_data;
   GError *error = NULL;
 
   if (!tp_contact_request_contact_info_finish (contact, res, &error))
     {
       /* If the request got cancelled it could mean the contact widget is
-       * destroyed, so we should not dereference information */
+       * destroyed, so we should not dereference self */
       if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         {
           g_clear_error (&error);
           return;
         }
 
-      gtk_widget_hide (information->vbox_details);
+      gtk_widget_hide (self->priv->vbox_details);
       g_clear_error (&error);
     }
   else
     {
-      contact_widget_details_notify_cb (information);
+      contact_widget_details_notify_cb (self);
     }
 
   /* If we are going to edit ContactInfo, we don't want live updates */
-  if ((information->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) == 0)
+  if ((self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) == 0)
     {
       g_signal_connect_swapped (contact, "notify::contact-info",
-          G_CALLBACK (contact_widget_details_notify_cb), information);
+          G_CALLBACK (contact_widget_details_notify_cb), self);
     }
 
-  tp_clear_object (&information->details_cancellable);
+  tp_clear_object (&self->priv->details_cancellable);
 }
 
 static void
-fetch_contact_information (EmpathyContactWidget *information,
-        TpConnection *connection)
+fetch_contact_information (EmpathyContactWidget *self,
+    TpConnection *connection)
 {
   TpContact *contact;
   TpContactInfoFlags flags;
@@ -650,46 +650,46 @@ fetch_contact_information (EmpathyContactWidget *information,
   if (!tp_proxy_has_interface_by_id (connection,
           TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_INFO))
     {
-      gtk_widget_hide (information->vbox_details);
+      gtk_widget_hide (self->priv->vbox_details);
       return;
     }
 
   /* If we want to edit info, but connection does not support that, stop */
   flags = tp_connection_get_contact_info_flags (connection);
   if ((flags & TP_CONTACT_INFO_FLAG_CAN_SET) == 0 &&
-      (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) != 0)
+      (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) != 0)
     {
-      gtk_widget_hide (information->vbox_details);
+      gtk_widget_hide (self->priv->vbox_details);
       return;
     }
 
   /* Request the contact's info */
-  gtk_widget_show (information->vbox_details);
-  gtk_widget_show (information->hbox_details_requested);
-  gtk_widget_hide (information->grid_details);
-  gtk_spinner_start (GTK_SPINNER (information->spinner_details));
-
-  contact = empathy_contact_get_tp_contact (information->contact);
-  g_assert (information->details_cancellable == NULL);
-  information->details_cancellable = g_cancellable_new ();
+  gtk_widget_show (self->priv->vbox_details);
+  gtk_widget_show (self->priv->hbox_details_requested);
+  gtk_widget_hide (self->priv->grid_details);
+  gtk_spinner_start (GTK_SPINNER (self->priv->spinner_details));
+
+  contact = empathy_contact_get_tp_contact (self->priv->contact);
+  g_assert (self->priv->details_cancellable == NULL);
+  self->priv->details_cancellable = g_cancellable_new ();
   tp_contact_request_contact_info_async (contact,
-      information->details_cancellable, contact_widget_details_request_cb,
-      information);
+      self->priv->details_cancellable, contact_widget_details_request_cb,
+      self);
 }
 
 static void
-contact_widget_details_update (EmpathyContactWidget *information)
+contact_widget_details_update (EmpathyContactWidget *self)
 {
   TpContact *tp_contact = NULL;
 
-  if ((information->flags & EMPATHY_CONTACT_WIDGET_SHOW_DETAILS) == 0 &&
-      (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) == 0)
+  if ((self->priv->flags & EMPATHY_CONTACT_WIDGET_SHOW_DETAILS) == 0 &&
+      (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) == 0)
     return;
 
-  gtk_widget_hide (information->vbox_details);
+  gtk_widget_hide (self->priv->vbox_details);
 
-  if (information->contact != NULL)
-    tp_contact = empathy_contact_get_tp_contact (information->contact);
+  if (self->priv->contact != NULL)
+    tp_contact = empathy_contact_get_tp_contact (self->priv->contact);
 
   if (tp_contact != NULL)
     {
@@ -697,45 +697,45 @@ contact_widget_details_update (EmpathyContactWidget *information)
 
       connection = tp_contact_get_connection (tp_contact);
 
-      fetch_contact_information (information, connection);
+      fetch_contact_information (self, connection);
     }
 }
 
 static void
-contact_widget_client_update (EmpathyContactWidget *information)
+contact_widget_client_update (EmpathyContactWidget *self)
 {
   /* FIXME: Needs new telepathy spec */
 }
 
 static void
-contact_widget_client_setup (EmpathyContactWidget *information)
+contact_widget_client_setup (EmpathyContactWidget *self)
 {
   /* FIXME: Needs new telepathy spec */
-  gtk_widget_hide (information->vbox_client);
+  gtk_widget_hide (self->priv->vbox_client);
 }
 
 static void
-contact_widget_groups_update (EmpathyContactWidget *information)
+contact_widget_groups_update (EmpathyContactWidget *self)
 {
-  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS &&
-      information->contact != NULL)
+  if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS &&
+      self->priv->contact != NULL)
     {
       FolksPersona *persona =
-          empathy_contact_get_persona (information->contact);
+          empathy_contact_get_persona (self->priv->contact);
 
       if (FOLKS_IS_GROUP_DETAILS (persona))
         {
           empathy_groups_widget_set_group_details (
-              EMPATHY_GROUPS_WIDGET (information->groups_widget),
+              EMPATHY_GROUPS_WIDGET (self->priv->groups_widget),
               FOLKS_GROUP_DETAILS (persona));
-          gtk_widget_show (information->groups_widget);
+          gtk_widget_show (self->priv->groups_widget);
 
           return;
         }
     }
 
   /* In case of failure */
-  gtk_widget_hide (information->groups_widget);
+  gtk_widget_hide (self->priv->groups_widget);
 }
 
 /* Converts the Location's GHashTable's key to a user readable string */
@@ -798,7 +798,7 @@ location_key_to_label (const gchar *key)
 }
 
 static void
-contact_widget_location_update (EmpathyContactWidget *information)
+contact_widget_location_update (EmpathyContactWidget *self)
 {
   GHashTable *location;
   GValue *value;
@@ -826,16 +826,16 @@ contact_widget_location_update (EmpathyContactWidget *information)
   const gchar *skey;
   gboolean display_map = FALSE;
 
-  if (!(information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION))
+  if (!(self->priv->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION))
     {
-      gtk_widget_hide (information->vbox_location);
+      gtk_widget_hide (self->priv->vbox_location);
       return;
     }
 
-  location = empathy_contact_get_location (information->contact);
+  location = empathy_contact_get_location (self->priv->contact);
   if (location == NULL || g_hash_table_size (location) == 0)
     {
-      gtk_widget_hide (information->vbox_location);
+      gtk_widget_hide (self->priv->vbox_location);
       return;
     }
 
@@ -843,7 +843,7 @@ contact_widget_location_update (EmpathyContactWidget *information)
   if (value == NULL)
     {
       gchar *loc = g_strdup_printf ("<b>%s</b>", _("Location"));
-      gtk_label_set_markup (GTK_LABEL (information->label_location), loc);
+      gtk_label_set_markup (GTK_LABEL (self->priv->label_location), loc);
       g_free (loc);
     }
   else
@@ -861,21 +861,21 @@ contact_widget_location_update (EmpathyContactWidget *information)
       /* translators: format is "Location, $date" */
       text = g_strdup_printf (_("%s, %s"), tmp, user_date);
       g_free (tmp);
-      gtk_label_set_markup (GTK_LABEL (information->label_location), text);
+      gtk_label_set_markup (GTK_LABEL (self->priv->label_location), text);
       g_free (user_date);
       g_free (text);
     }
 
 
-  /* Prepare the location information grid */
-  if (information->grid_location != NULL)
+  /* Prepare the location self grid */
+  if (self->priv->grid_location != NULL)
     {
-      gtk_widget_destroy (information->grid_location);
+      gtk_widget_destroy (self->priv->grid_location);
     }
 
-  information->grid_location = gtk_grid_new ();
-  gtk_box_pack_start (GTK_BOX (information->subvbox_location),
-      information->grid_location, FALSE, FALSE, 5);
+  self->priv->grid_location = gtk_grid_new ();
+  gtk_box_pack_start (GTK_BOX (self->priv->subvbox_location),
+      self->priv->grid_location, FALSE, FALSE, 5);
 
 
   for (i = 0; (skey = ordered_geolocation_keys[i]); i++)
@@ -892,7 +892,7 @@ contact_widget_location_update (EmpathyContactWidget *information)
 
       label = gtk_label_new (user_label);
       gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-      gtk_grid_attach (GTK_GRID (information->grid_location),
+      gtk_grid_attach (GTK_GRID (self->priv->grid_location),
           label, 0, row, 1, 1);
       gtk_widget_show (label);
 
@@ -917,12 +917,12 @@ contact_widget_location_update (EmpathyContactWidget *information)
       if (svalue != NULL)
         {
           label = gtk_label_new (svalue);
-          gtk_grid_attach (GTK_GRID (information->grid_location),
+          gtk_grid_attach (GTK_GRID (self->priv->grid_location),
               label, 1, row, 1, 1);
           gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
           gtk_widget_show (label);
 
-          if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
+          if (!(self->priv->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
             gtk_label_set_selectable (GTK_LABEL (label), TRUE);
         }
 
@@ -932,7 +932,7 @@ contact_widget_location_update (EmpathyContactWidget *information)
 
 #ifdef HAVE_LIBCHAMPLAIN
   if (has_position &&
-      !(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
+      !(self->priv->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
     {
       /* Cannot be displayed in tooltips until Clutter-Gtk can deal with such
        * windows */
@@ -943,12 +943,12 @@ contact_widget_location_update (EmpathyContactWidget *information)
   if (row > 0)
     {
       /* We can display some fields */
-      gtk_widget_show (information->grid_location);
+      gtk_widget_show (self->priv->grid_location);
     }
   else if (!display_map)
     {
       /* Can't display either fields or map */
-      gtk_widget_hide (information->vbox_location);
+      gtk_widget_hide (self->priv->vbox_location);
       return;
     }
 
@@ -958,36 +958,36 @@ contact_widget_location_update (EmpathyContactWidget *information)
       ClutterActor *marker;
       ChamplainMarkerLayer *layer;
 
-      information->map_view_embed = gtk_champlain_embed_new ();
-      information->map_view = gtk_champlain_embed_get_view (
-          GTK_CHAMPLAIN_EMBED (information->map_view_embed));
+      self->priv->map_view_embed = gtk_champlain_embed_new ();
+      self->priv->map_view = gtk_champlain_embed_get_view (
+          GTK_CHAMPLAIN_EMBED (self->priv->map_view_embed));
 
-      gtk_container_add (GTK_CONTAINER (information->viewport_map),
-          information->map_view_embed);
-      g_object_set (G_OBJECT (information->map_view),
+      gtk_container_add (GTK_CONTAINER (self->priv->viewport_map),
+          self->priv->map_view_embed);
+      g_object_set (G_OBJECT (self->priv->map_view),
           "kinetic-mode", TRUE,
           "zoom-level", 10,
           NULL);
 
       layer = champlain_marker_layer_new ();
-      champlain_view_add_layer (information->map_view, CHAMPLAIN_LAYER (layer));
+      champlain_view_add_layer (self->priv->map_view, CHAMPLAIN_LAYER (layer));
 
       marker = champlain_label_new_with_text (
-          empathy_contact_get_alias (information->contact), NULL, NULL, NULL);
+          empathy_contact_get_alias (self->priv->contact), NULL, NULL, NULL);
       champlain_location_set_location (CHAMPLAIN_LOCATION (marker), lat, lon);
       champlain_marker_layer_add_marker (layer, CHAMPLAIN_MARKER (marker));
 
-      champlain_view_center_on (information->map_view, lat, lon);
-      gtk_widget_show_all (information->viewport_map);
+      champlain_view_center_on (self->priv->map_view, lat, lon);
+      gtk_widget_show_all (self->priv->viewport_map);
     }
 #endif
 
-    gtk_widget_show (information->vbox_location);
+    gtk_widget_show (self->priv->vbox_location);
 }
 
 static void
 save_avatar_menu_activate_cb (GtkWidget *widget,
-                              EmpathyContactWidget *information)
+    EmpathyContactWidget *self)
 {
   GtkWidget *dialog;
   EmpathyAvatar *avatar;
@@ -1004,7 +1004,7 @@ save_avatar_menu_activate_cb (GtkWidget *widget,
       TRUE);
 
   /* look for the avatar extension */
-  avatar = empathy_contact_get_avatar (information->contact);
+  avatar = empathy_contact_get_avatar (self->priv->contact);
   if (avatar->format != NULL)
     {
       gchar **splitted;
@@ -1026,7 +1026,7 @@ save_avatar_menu_activate_cb (GtkWidget *widget,
       gchar *id;
 
       id = tp_escape_as_identifier (empathy_contact_get_id (
-            information->contact));
+            self->priv->contact));
 
       filename = g_strdup_printf ("%s.%s", id, ext);
       gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);
@@ -1069,15 +1069,15 @@ save_avatar_menu_activate_cb (GtkWidget *widget,
 }
 
 static void
-popup_avatar_menu (EmpathyContactWidget *information,
+popup_avatar_menu (EmpathyContactWidget *self,
                    GtkWidget *parent,
                    GdkEventButton *event)
 {
   GtkWidget *menu, *item;
   gint button, event_time;
 
-  if (information->contact == NULL ||
-      empathy_contact_get_avatar (information->contact) == NULL)
+  if (self->priv->contact == NULL ||
+      empathy_contact_get_avatar (self->priv->contact) == NULL)
       return;
 
   menu = empathy_context_menu_new (parent);
@@ -1088,7 +1088,7 @@ popup_avatar_menu (EmpathyContactWidget *information,
   gtk_widget_show (item);
 
   g_signal_connect (item, "activate",
-      G_CALLBACK (save_avatar_menu_activate_cb), information);
+      G_CALLBACK (save_avatar_menu_activate_cb), self);
 
   if (event)
     {
@@ -1107,9 +1107,9 @@ popup_avatar_menu (EmpathyContactWidget *information,
 
 static gboolean
 widget_avatar_popup_menu_cb (GtkWidget *widget,
-                             EmpathyContactWidget *information)
+                             EmpathyContactWidget *self)
 {
-  popup_avatar_menu (information, widget, NULL);
+  popup_avatar_menu (self, widget, NULL);
 
   return TRUE;
 }
@@ -1117,12 +1117,12 @@ widget_avatar_popup_menu_cb (GtkWidget *widget,
 static gboolean
 widget_avatar_button_press_event_cb (GtkWidget *widget,
                                      GdkEventButton *event,
-                                     EmpathyContactWidget *information)
+                                     EmpathyContactWidget *self)
 {
   /* Ignore double-clicks and triple-clicks */
   if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
     {
-      popup_avatar_menu (information, widget, event);
+      popup_avatar_menu (self, widget, event);
       return TRUE;
     }
 
@@ -1157,7 +1157,7 @@ set_avatar_on_account (TpAccount *account,
 
 static void
 contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser,
-                                  EmpathyContactWidget *information)
+    EmpathyContactWidget *self)
 {
   const gchar *data;
   gsize size;
@@ -1165,10 +1165,10 @@ contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser,
   TpAccount *account;
 
   empathy_avatar_chooser_get_image_data (
-      EMPATHY_AVATAR_CHOOSER (information->widget_avatar),
+      EMPATHY_AVATAR_CHOOSER (self->priv->widget_avatar),
       &data, &size, &mime_type);
 
-  account = empathy_contact_get_account (information->contact);
+  account = empathy_contact_get_account (self->priv->contact);
   set_avatar_on_account (account, data, size, mime_type);
 }
 
@@ -1199,7 +1199,7 @@ update_nickname_in_contact_info (EmpathyContactWidget *self,
 
   specs = tp_connection_get_contact_info_supported_fields (connection);
 
-  for (l = self->details_to_set; l != NULL; l= g_list_next (l))
+  for (l = self->priv->details_to_set; l != NULL; l= g_list_next (l))
     {
       TpContactInfoField *field = l->data;
       TpContactInfoFieldSpec *spec;
@@ -1228,21 +1228,21 @@ update_nickname_in_contact_info (EmpathyContactWidget *self,
 
 static gboolean
 contact_widget_entry_alias_focus_event_cb (GtkEditable *editable,
-                                           GdkEventFocus *event,
-                                           EmpathyContactWidget *information)
+    GdkEventFocus *event,
+    EmpathyContactWidget *self)
 {
-  if (information->contact)
+  if (self->priv->contact)
     {
       const gchar *alias;
 
       alias = gtk_entry_get_text (GTK_ENTRY (editable));
 
-      if (empathy_contact_is_user (information->contact))
+      if (empathy_contact_is_user (self->priv->contact))
         {
           TpAccount * account;
           const gchar *current_nickname;
 
-          account = empathy_contact_get_account (information->contact);
+          account = empathy_contact_get_account (self->priv->contact);
           current_nickname = tp_account_get_nickname (account);
 
           if (tp_strdiff (current_nickname, alias))
@@ -1252,13 +1252,13 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable *editable,
               tp_account_set_nickname_async (account, alias, set_nickname_cb,
                   NULL);
 
-              update_nickname_in_contact_info (information,
-                  empathy_contact_get_connection (information->contact), alias);
+              update_nickname_in_contact_info (self,
+                  empathy_contact_get_connection (self->priv->contact), alias);
             }
         }
       else
         {
-          empathy_contact_set_alias (information->contact, alias);
+          empathy_contact_set_alias (self->priv->contact, alias);
         }
     }
 
@@ -1279,216 +1279,216 @@ update_avatar_chooser_account_cb (EmpathyAccountChooser *account_chooser,
 }
 
 static void
-contact_widget_avatar_notify_cb (EmpathyContactWidget *information)
+contact_widget_avatar_notify_cb (EmpathyContactWidget *self)
 {
   EmpathyAvatar *avatar = NULL;
 
-  if (information->contact)
-      avatar = empathy_contact_get_avatar (information->contact);
+  if (self->priv->contact)
+      avatar = empathy_contact_get_avatar (self->priv->contact);
 
-  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR)
+  if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR)
     {
-      g_signal_handlers_block_by_func (information->widget_avatar,
+      g_signal_handlers_block_by_func (self->priv->widget_avatar,
           contact_widget_avatar_changed_cb,
-          information);
+          self);
       empathy_avatar_chooser_set (
-          EMPATHY_AVATAR_CHOOSER (information->widget_avatar), avatar);
-      g_signal_handlers_unblock_by_func (information->widget_avatar,
-          contact_widget_avatar_changed_cb, information);
+          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 (information->widget_avatar), avatar);
+          EMPATHY_AVATAR_IMAGE (self->priv->widget_avatar), avatar);
 }
 
 static void
-contact_widget_name_notify_cb (EmpathyContactWidget *information)
+contact_widget_name_notify_cb (EmpathyContactWidget *self)
 {
-  if (GTK_IS_ENTRY (information->widget_alias))
-      gtk_entry_set_text (GTK_ENTRY (information->widget_alias),
-          empathy_contact_get_alias (information->contact));
+  if (GTK_IS_ENTRY (self->priv->widget_alias))
+      gtk_entry_set_text (GTK_ENTRY (self->priv->widget_alias),
+          empathy_contact_get_alias (self->priv->contact));
   else
-      gtk_label_set_label (GTK_LABEL (information->widget_alias),
-          empathy_contact_get_alias (information->contact));
+      gtk_label_set_label (GTK_LABEL (self->priv->widget_alias),
+          empathy_contact_get_alias (self->priv->contact));
 }
 
 static void
-contact_widget_presence_notify_cb (EmpathyContactWidget *information)
+contact_widget_presence_notify_cb (EmpathyContactWidget *self)
 {
   const gchar *status;
   gchar *markup_text = NULL;
 
-  status = empathy_contact_get_status (information->contact);
+  status = empathy_contact_get_status (self->priv->contact);
   if (status != NULL)
     markup_text = empathy_add_link_markup (status);
-  gtk_label_set_markup (GTK_LABEL (information->label_status), markup_text);
+  gtk_label_set_markup (GTK_LABEL (self->priv->label_status), markup_text);
   g_free (markup_text);
 
-  gtk_image_set_from_icon_name (GTK_IMAGE (information->image_state),
-      empathy_icon_name_for_contact (information->contact),
+  gtk_image_set_from_icon_name (GTK_IMAGE (self->priv->image_state),
+      empathy_icon_name_for_contact (self->priv->contact),
       GTK_ICON_SIZE_BUTTON);
-  gtk_widget_show (information->image_state);
+  gtk_widget_show (self->priv->image_state);
 }
 
 static void
-contact_widget_remove_contact (EmpathyContactWidget *information)
+contact_widget_remove_contact (EmpathyContactWidget *self)
 {
-  if (information->contact)
+  if (self->priv->contact)
     {
       TpContact *tp_contact;
 
-      contact_widget_save (information);
+      contact_widget_save (self);
 
-      g_signal_handlers_disconnect_by_func (information->contact,
-          contact_widget_name_notify_cb, information);
-      g_signal_handlers_disconnect_by_func (information->contact,
-          contact_widget_presence_notify_cb, information);
-      g_signal_handlers_disconnect_by_func (information->contact,
-          contact_widget_avatar_notify_cb, information);
+      g_signal_handlers_disconnect_by_func (self->priv->contact,
+          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 (information->contact);
+      tp_contact = empathy_contact_get_tp_contact (self->priv->contact);
       if (tp_contact != NULL)
         {
           g_signal_handlers_disconnect_by_func (tp_contact,
-              contact_widget_details_notify_cb, information);
+              contact_widget_details_notify_cb, self);
         }
 
-      g_object_unref (information->contact);
-      information->contact = NULL;
+      g_object_unref (self->priv->contact);
+      self->priv->contact = NULL;
     }
 
-  if (information->details_cancellable != NULL)
+  if (self->priv->details_cancellable != NULL)
     {
-      g_cancellable_cancel (information->details_cancellable);
-      tp_clear_object (&information->details_cancellable);
+      g_cancellable_cancel (self->priv->details_cancellable);
+      tp_clear_object (&self->priv->details_cancellable);
     }
 }
 
-static void contact_widget_change_contact (EmpathyContactWidget *information);
+static void contact_widget_change_contact (EmpathyContactWidget *self);
 
 static void
-contact_widget_contact_update (EmpathyContactWidget *information)
+contact_widget_contact_update (EmpathyContactWidget *self)
 {
   TpAccount *account = NULL;
   const gchar *id = NULL;
 
   /* Connect and get info from new contact */
-  if (information->contact)
+  if (self->priv->contact)
     {
-      g_signal_connect_swapped (information->contact, "notify::name",
-          G_CALLBACK (contact_widget_name_notify_cb), information);
-      g_signal_connect_swapped (information->contact, "notify::presence",
-          G_CALLBACK (contact_widget_presence_notify_cb), information);
-      g_signal_connect_swapped (information->contact,
+      g_signal_connect_swapped (self->priv->contact, "notify::name",
+          G_CALLBACK (contact_widget_name_notify_cb), self);
+      g_signal_connect_swapped (self->priv->contact, "notify::presence",
+          G_CALLBACK (contact_widget_presence_notify_cb), self);
+      g_signal_connect_swapped (self->priv->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);
+          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 (information->contact);
-      id = empathy_contact_get_id (information->contact);
+      account = empathy_contact_get_account (self->priv->contact);
+      id = empathy_contact_get_id (self->priv->contact);
     }
 
   /* Update account widget */
-  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
+  if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
     {
       if (account)
         {
-          g_signal_handlers_block_by_func (information->widget_account,
+          g_signal_handlers_block_by_func (self->priv->widget_account,
                    contact_widget_change_contact,
-                   information);
+                   self);
           empathy_account_chooser_set_account (
-              EMPATHY_ACCOUNT_CHOOSER (information->widget_account), account);
-          g_signal_handlers_unblock_by_func (information->widget_account,
-              contact_widget_change_contact, information);
+              EMPATHY_ACCOUNT_CHOOSER (self->priv->widget_account), account);
+          g_signal_handlers_unblock_by_func (self->priv->widget_account,
+              contact_widget_change_contact, self);
         }
     }
   else
     {
-      if (EMPATHY_IS_AVATAR_CHOOSER (information->widget_avatar))
+      if (EMPATHY_IS_AVATAR_CHOOSER (self->priv->widget_avatar))
         {
           empathy_avatar_chooser_set_account (
-              EMPATHY_AVATAR_CHOOSER (information->widget_avatar), account);
+              EMPATHY_AVATAR_CHOOSER (self->priv->widget_avatar), account);
         }
 
-      if ((information->flags & EMPATHY_CONTACT_WIDGET_NO_ACCOUNT) == 0)
+      if ((self->priv->flags & EMPATHY_CONTACT_WIDGET_NO_ACCOUNT) == 0)
         {
           if (account)
             {
               const gchar *name;
 
               name = tp_account_get_display_name (account);
-              gtk_label_set_label (GTK_LABEL (information->label_account),
+              gtk_label_set_label (GTK_LABEL (self->priv->label_account),
                   name);
 
               name = tp_account_get_icon_name (account);
               gtk_image_set_from_icon_name (
-                  GTK_IMAGE (information->image_account),
+                  GTK_IMAGE (self->priv->image_account),
                   name, GTK_ICON_SIZE_MENU);
             }
         }
     }
 
   /* Update id widget */
-  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
-      gtk_entry_set_text (GTK_ENTRY (information->widget_id), id ? id : "");
+  if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
+      gtk_entry_set_text (GTK_ENTRY (self->priv->widget_id), id ? id : "");
   else
-      gtk_label_set_label (GTK_LABEL (information->widget_id), id ? id : "");
+      gtk_label_set_label (GTK_LABEL (self->priv->widget_id), id ? id : "");
 
   /* Update other widgets */
-  if (information->contact)
+  if (self->priv->contact)
     {
-      contact_widget_name_notify_cb (information);
-      contact_widget_presence_notify_cb (information);
-      contact_widget_avatar_notify_cb (information);
+      contact_widget_name_notify_cb (self);
+      contact_widget_presence_notify_cb (self);
+      contact_widget_avatar_notify_cb (self);
 
-      gtk_widget_show (information->label_alias);
-      gtk_widget_show (information->widget_alias);
-      gtk_widget_show (information->widget_avatar);
+      gtk_widget_show (self->priv->label_alias);
+      gtk_widget_show (self->priv->widget_alias);
+      gtk_widget_show (self->priv->widget_avatar);
 
-      gtk_widget_set_visible (information->hbox_presence,
-          !(information->flags & EMPATHY_CONTACT_WIDGET_NO_STATUS));
+      gtk_widget_set_visible (self->priv->hbox_presence,
+          !(self->priv->flags & EMPATHY_CONTACT_WIDGET_NO_STATUS));
 
-      if (empathy_contact_is_user (information->contact))
-        gtk_label_set_text (GTK_LABEL (information->label_details),
+      if (empathy_contact_is_user (self->priv->contact))
+        gtk_label_set_text (GTK_LABEL (self->priv->label_details),
             _("Personal Details"));
       else
-        gtk_label_set_text (GTK_LABEL (information->label_details),
+        gtk_label_set_text (GTK_LABEL (self->priv->label_details),
             _("Contact Details"));
     }
   else
     {
-      gtk_widget_hide (information->label_alias);
-      gtk_widget_hide (information->widget_alias);
-      gtk_widget_hide (information->hbox_presence);
-      gtk_widget_hide (information->widget_avatar);
+      gtk_widget_hide (self->priv->label_alias);
+      gtk_widget_hide (self->priv->widget_alias);
+      gtk_widget_hide (self->priv->hbox_presence);
+      gtk_widget_hide (self->priv->widget_avatar);
     }
 }
 
 static void
-contact_widget_set_contact (EmpathyContactWidget *information,
+contact_widget_set_contact (EmpathyContactWidget *self,
                             EmpathyContact *contact)
 {
-  if (contact == information->contact)
+  if (contact == self->priv->contact)
     return;
 
-  contact_widget_remove_contact (information);
+  contact_widget_remove_contact (self);
   if (contact)
-    information->contact = g_object_ref (contact);
+    self->priv->contact = g_object_ref (contact);
 
   /* set the selected account to be the account this contact came from */
-  if (contact && EMPATHY_IS_ACCOUNT_CHOOSER (information->widget_account)) {
+  if (contact && EMPATHY_IS_ACCOUNT_CHOOSER (self->priv->widget_account)) {
       empathy_account_chooser_set_account (
-                     EMPATHY_ACCOUNT_CHOOSER (information->widget_account),
+                     EMPATHY_ACCOUNT_CHOOSER (self->priv->widget_account),
                      empathy_contact_get_account (contact));
   }
 
-  /* Update information for widgets */
-  contact_widget_contact_update (information);
-  contact_widget_groups_update (information);
-  contact_widget_details_update (information);
-  contact_widget_client_update (information);
-  contact_widget_location_update (information);
+  /* Update self for widgets */
+  contact_widget_contact_update (self);
+  contact_widget_groups_update (self);
+  contact_widget_details_update (self);
+  contact_widget_client_update (self);
+  contact_widget_location_update (self);
 }
 
 static void
@@ -1498,7 +1498,7 @@ contact_widget_got_contact_cb (TpConnection *connection,
                                gpointer user_data,
                                GObject *weak_object)
 {
-  EmpathyContactWidget *information = user_data;
+  EmpathyContactWidget *self = user_data;
 
   if (error != NULL)
     {
@@ -1506,29 +1506,29 @@ contact_widget_got_contact_cb (TpConnection *connection,
       return;
     }
 
-  contact_widget_set_contact (information, contact);
+  contact_widget_set_contact (self, contact);
 }
 
 static void
-contact_widget_change_contact (EmpathyContactWidget *information)
+contact_widget_change_contact (EmpathyContactWidget *self)
 {
   TpConnection *connection;
 
   connection = empathy_account_chooser_get_connection (
-      EMPATHY_ACCOUNT_CHOOSER (information->widget_account));
+      EMPATHY_ACCOUNT_CHOOSER (self->priv->widget_account));
   if (!connection)
       return;
 
-  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
+  if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
     {
       const gchar *id;
 
-      id = gtk_entry_get_text (GTK_ENTRY (information->widget_id));
+      id = gtk_entry_get_text (GTK_ENTRY (self->priv->widget_id));
       if (!EMP_STR_EMPTY (id))
         {
           empathy_tp_contact_factory_get_from_id (connection, id,
-              contact_widget_got_contact_cb, information, NULL,
-              G_OBJECT (information->vbox_contact_widget));
+              contact_widget_got_contact_cb, self, NULL,
+              G_OBJECT (self));
         }
     }
   else
@@ -1538,7 +1538,7 @@ contact_widget_change_contact (EmpathyContactWidget *information)
       contact = empathy_contact_dup_from_tp_contact (
           tp_connection_get_self_contact (connection));
 
-      contact_widget_set_contact (information, contact);
+      contact_widget_set_contact (self, contact);
       g_object_unref (contact);
     }
 }
@@ -1554,12 +1554,12 @@ static void
 contact_widget_id_changed_cb (GtkEntry *entry,
                               EmpathyContactWidget *self)
 {
-  if (self->widget_id_timeout != 0)
+  if (self->priv->widget_id_timeout != 0)
     {
-      g_source_remove (self->widget_id_timeout);
+      g_source_remove (self->priv->widget_id_timeout);
     }
 
-  self->widget_id_timeout =
+  self->priv->widget_id_timeout =
     g_timeout_add_seconds (ID_CHANGED_TIMEOUT,
         (GSourceFunc) contact_widget_id_activate_timeout, self);
 }
@@ -1567,175 +1567,180 @@ contact_widget_id_changed_cb (GtkEntry *entry,
 static gboolean
 contact_widget_id_focus_out_cb (GtkWidget *widget,
                                 GdkEventFocus *event,
-                                EmpathyContactWidget *information)
+                                EmpathyContactWidget *self)
 {
-  contact_widget_change_contact (information);
+  contact_widget_change_contact (self);
   return FALSE;
 }
 
 static void
-contact_widget_contact_setup (EmpathyContactWidget *information)
+contact_widget_contact_setup (EmpathyContactWidget *self)
 {
-  information->label_status = gtk_label_new ("");
-  gtk_label_set_line_wrap_mode (GTK_LABEL (information->label_status),
+  self->priv->label_status = gtk_label_new ("");
+  gtk_label_set_line_wrap_mode (GTK_LABEL (self->priv->label_status),
                                 PANGO_WRAP_WORD_CHAR);
-  gtk_label_set_line_wrap (GTK_LABEL (information->label_status),
+  gtk_label_set_line_wrap (GTK_LABEL (self->priv->label_status),
                            TRUE);
-  gtk_misc_set_alignment (GTK_MISC (information->label_status), 0, 0.5);
+  gtk_misc_set_alignment (GTK_MISC (self->priv->label_status), 0, 0.5);
 
-  if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
-    gtk_label_set_selectable (GTK_LABEL (information->label_status), TRUE);
+  if (!(self->priv->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
+    gtk_label_set_selectable (GTK_LABEL (self->priv->label_status), TRUE);
 
-  gtk_box_pack_start (GTK_BOX (information->hbox_presence),
-        information->label_status, TRUE, TRUE, 0);
-  gtk_widget_show (information->label_status);
+  gtk_box_pack_start (GTK_BOX (self->priv->hbox_presence),
+        self->priv->label_status, TRUE, TRUE, 0);
+  gtk_widget_show (self->priv->label_status);
 
   /* Setup account label/chooser */
-  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
+  if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
     {
-      information->widget_account = empathy_account_chooser_new ();
+      self->priv->widget_account = empathy_account_chooser_new ();
 
-      g_signal_connect_swapped (information->widget_account, "changed",
+      g_signal_connect_swapped (self->priv->widget_account, "changed",
             G_CALLBACK (contact_widget_change_contact),
-            information);
+            self);
     }
-  else if (information->flags & EMPATHY_CONTACT_WIDGET_NO_ACCOUNT)
+  else if (self->priv->flags & EMPATHY_CONTACT_WIDGET_NO_ACCOUNT)
     {
       /* Don't display the account */
-      gtk_widget_hide (information->label_left_account);
+      gtk_widget_hide (self->priv->label_left_account);
     }
   else
     {
       /* Pack the protocol icon with the account name in an hbox */
-      information->widget_account = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+      self->priv->widget_account = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
 
-      information->label_account = gtk_label_new (NULL);
-      if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
-        gtk_label_set_selectable (GTK_LABEL (information->label_account), TRUE);
+      self->priv->label_account = gtk_label_new (NULL);
+      if (!(self->priv->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
+        gtk_label_set_selectable (GTK_LABEL (self->priv->label_account), TRUE);
       }
-      gtk_misc_set_alignment (GTK_MISC (information->label_account), 0, 0.5);
-      gtk_widget_show (information->label_account);
+      gtk_misc_set_alignment (GTK_MISC (self->priv->label_account), 0, 0.5);
+      gtk_widget_show (self->priv->label_account);
 
-      information->image_account = gtk_image_new ();
-      gtk_widget_show (information->image_account);
+      self->priv->image_account = gtk_image_new ();
+      gtk_widget_show (self->priv->image_account);
 
-      gtk_box_pack_start (GTK_BOX (information->widget_account),
-          information->image_account, FALSE, FALSE, 0);
-      gtk_box_pack_start (GTK_BOX (information->widget_account),
-          information->label_account, FALSE, TRUE, 0);
+      gtk_box_pack_start (GTK_BOX (self->priv->widget_account),
+          self->priv->image_account, FALSE, FALSE, 0);
+      gtk_box_pack_start (GTK_BOX (self->priv->widget_account),
+          self->priv->label_account, FALSE, TRUE, 0);
     }
 
-  if (information->widget_account != NULL)
+  if (self->priv->widget_account != NULL)
     {
-      gtk_grid_attach (GTK_GRID (information->grid_contact),
-          information->widget_account,
+      gtk_grid_attach (GTK_GRID (self->priv->grid_contact),
+          self->priv->widget_account,
           1, 0, 1, 1);
 
-      gtk_widget_show (information->widget_account);
+      gtk_widget_show (self->priv->widget_account);
     }
 
   /* Set up avatar chooser/display */
-  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR)
+  if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR)
     {
-      information->widget_avatar = empathy_avatar_chooser_new ();
-      g_signal_connect (information->widget_avatar, "changed",
+      self->priv->widget_avatar = empathy_avatar_chooser_new ();
+      g_signal_connect (self->priv->widget_avatar, "changed",
             G_CALLBACK (contact_widget_avatar_changed_cb),
-            information);
-      if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
+            self);
+      if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
         {
-          g_signal_connect (information->widget_account, "changed",
+          g_signal_connect (self->priv->widget_account, "changed",
               G_CALLBACK (update_avatar_chooser_account_cb),
-              information->widget_avatar);
+              self->priv->widget_avatar);
           update_avatar_chooser_account_cb (
-              EMPATHY_ACCOUNT_CHOOSER (information->widget_account),
-              EMPATHY_AVATAR_CHOOSER (information->widget_avatar));
+              EMPATHY_ACCOUNT_CHOOSER (self->priv->widget_account),
+              EMPATHY_AVATAR_CHOOSER (self->priv->widget_avatar));
         }
     }
   else
     {
-      information->widget_avatar = empathy_avatar_image_new ();
+      self->priv->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);
+      g_signal_connect (self->priv->widget_avatar, "popup-menu",
+          G_CALLBACK (widget_avatar_popup_menu_cb), self);
+      g_signal_connect (self->priv->widget_avatar, "button-press-event",
+          G_CALLBACK (widget_avatar_button_press_event_cb), self);
     }
 
-  gtk_box_pack_start (GTK_BOX (information->vbox_avatar),
-          information->widget_avatar,
+  gtk_box_pack_start (GTK_BOX (self->priv->vbox_avatar),
+          self->priv->widget_avatar,
           FALSE, FALSE,
           6);
-  gtk_widget_show (information->widget_avatar);
+  gtk_widget_show (self->priv->widget_avatar);
 
   /* Setup id label/entry */
-  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
+  if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
     {
-      information->widget_id = gtk_entry_new ();
-      g_signal_connect (information->widget_id, "focus-out-event",
+      self->priv->widget_id = gtk_entry_new ();
+      g_signal_connect (self->priv->widget_id, "focus-out-event",
             G_CALLBACK (contact_widget_id_focus_out_cb),
-            information);
-      g_signal_connect (information->widget_id, "changed",
+            self);
+      g_signal_connect (self->priv->widget_id, "changed",
             G_CALLBACK (contact_widget_id_changed_cb),
-            information);
+            self);
     }
   else
     {
-      information->widget_id = gtk_label_new (NULL);
-      if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
-        gtk_label_set_selectable (GTK_LABEL (information->widget_id), TRUE);
+      self->priv->widget_id = gtk_label_new (NULL);
+      if (!(self->priv->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
+        gtk_label_set_selectable (GTK_LABEL (self->priv->widget_id), TRUE);
       }
-      gtk_misc_set_alignment (GTK_MISC (information->widget_id), 0, 0.5);
+      gtk_misc_set_alignment (GTK_MISC (self->priv->widget_id), 0, 0.5);
     }
 
-  gtk_grid_attach (GTK_GRID (information->grid_contact), information->widget_id,
+  gtk_grid_attach (GTK_GRID (self->priv->grid_contact), self->priv->widget_id,
       1, 1, 1, 1);
 
-  gtk_widget_show (information->widget_id);
+  gtk_widget_show (self->priv->widget_id);
 
   /* Setup alias label/entry */
-  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ALIAS)
+  if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_ALIAS)
     {
-      information->widget_alias = gtk_entry_new ();
+      self->priv->widget_alias = gtk_entry_new ();
 
-      if (!(information->flags & EMPATHY_CONTACT_WIDGET_NO_SET_ALIAS))
-        g_signal_connect (information->widget_alias, "focus-out-event",
+      if (!(self->priv->flags & EMPATHY_CONTACT_WIDGET_NO_SET_ALIAS))
+        g_signal_connect (self->priv->widget_alias, "focus-out-event",
               G_CALLBACK (contact_widget_entry_alias_focus_event_cb),
-              information);
+              self);
 
       /* Make return activate the window default (the Close button) */
-      gtk_entry_set_activates_default (GTK_ENTRY (information->widget_alias),
+      gtk_entry_set_activates_default (GTK_ENTRY (self->priv->widget_alias),
           TRUE);
     }
   else
     {
-      information->widget_alias = gtk_label_new (NULL);
-      if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
-        gtk_label_set_selectable (GTK_LABEL (information->widget_alias), TRUE);
+      self->priv->widget_alias = gtk_label_new (NULL);
+      if (!(self->priv->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
+        gtk_label_set_selectable (GTK_LABEL (self->priv->widget_alias), TRUE);
       }
-      gtk_misc_set_alignment (GTK_MISC (information->widget_alias), 0, 0.5);
+      gtk_misc_set_alignment (GTK_MISC (self->priv->widget_alias), 0, 0.5);
     }
 
-  gtk_grid_attach (GTK_GRID (information->grid_contact),
-      information->widget_alias, 1, 2, 1, 1);
+  gtk_grid_attach (GTK_GRID (self->priv->grid_contact),
+      self->priv->widget_alias, 1, 2, 1, 1);
 
-  if (information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) {
-    gtk_label_set_selectable (GTK_LABEL (information->label_status), FALSE);
+  if (self->priv->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) {
+    gtk_label_set_selectable (GTK_LABEL (self->priv->label_status), FALSE);
   }
-  gtk_widget_show (information->widget_alias);
+  gtk_widget_show (self->priv->widget_alias);
 }
 
 static void
-contact_widget_destroy_cb (GtkWidget *widget,
-                           EmpathyContactWidget *information)
+empathy_contact_widget_finalize (GObject *object)
 {
-  contact_widget_remove_contact (information);
+  EmpathyContactWidget *self = EMPATHY_CONTACT_WIDGET (object);
+  void (*chain_up) (GObject *) =
+      ((GObjectClass *) empathy_contact_widget_parent_class)->finalize;
+
+  contact_widget_remove_contact (self);
 
-  if (information->widget_id_timeout != 0)
+  if (self->priv->widget_id_timeout != 0)
     {
-      g_source_remove (information->widget_id_timeout);
+      g_source_remove (self->priv->widget_id_timeout);
     }
 
-  g_slice_free (EmpathyContactWidget, information);
+
+  if (chain_up != NULL)
+    chain_up (object);
 }
 
 /**
@@ -1751,64 +1756,61 @@ GtkWidget *
 empathy_contact_widget_new (EmpathyContact *contact,
                             EmpathyContactWidgetFlags flags)
 {
-  EmpathyContactWidget *information;
-  GtkBuilder *gui;
+  EmpathyContactWidget *self;
   gchar *filename;
+  GtkWidget *main_vbox;
+  GtkBuilder *gui;
 
   g_return_val_if_fail (contact == NULL || EMPATHY_IS_CONTACT (contact), NULL);
 
-  information = g_slice_new0 (EmpathyContactWidget);
-  information->flags = flags;
+  self = g_object_new (EMPATHY_TYPE_CONTACT_WIDGET, NULL);
+
+  self->priv->flags = flags;
 
   filename = empathy_file_lookup ("empathy-contact-widget.ui",
       "libempathy-gtk");
   gui = empathy_builder_get_file (filename,
-       "vbox_contact_widget", &information->vbox_contact_widget,
-       "hbox_presence", &information->hbox_presence,
-       "label_alias", &information->label_alias,
-       "image_state", &information->image_state,
-       "grid_contact", &information->grid_contact,
-       "vbox_avatar", &information->vbox_avatar,
-       "vbox_location", &information->vbox_location,
-       "subvbox_location", &information->subvbox_location,
-       "label_location", &information->label_location,
+       "vbox_contact_widget", &main_vbox,
+       "hbox_presence", &self->priv->hbox_presence,
+       "label_alias", &self->priv->label_alias,
+       "image_state", &self->priv->image_state,
+       "grid_contact", &self->priv->grid_contact,
+       "vbox_avatar", &self->priv->vbox_avatar,
+       "vbox_location", &self->priv->vbox_location,
+       "subvbox_location", &self->priv->subvbox_location,
+       "label_location", &self->priv->label_location,
 #ifdef HAVE_LIBCHAMPLAIN
-       "viewport_map", &information->viewport_map,
+       "viewport_map", &self->priv->viewport_map,
 #endif
-       "groups_widget", &information->groups_widget,
-       "vbox_details", &information->vbox_details,
-       "grid_details", &information->grid_details,
-       "hbox_details_requested", &information->hbox_details_requested,
-       "vbox_client", &information->vbox_client,
-       "grid_client", &information->grid_client,
-       "hbox_client_requested", &information->hbox_client_requested,
-       "label_details", &information->label_details,
-       "label_left_account", &information->label_left_account,
+       "groups_widget", &self->priv->groups_widget,
+       "vbox_details", &self->priv->vbox_details,
+       "grid_details", &self->priv->grid_details,
+       "hbox_details_requested", &self->priv->hbox_details_requested,
+       "vbox_client", &self->priv->vbox_client,
+       "grid_client", &self->priv->grid_client,
+       "hbox_client_requested", &self->priv->hbox_client_requested,
+       "label_details", &self->priv->label_details,
+       "label_left_account", &self->priv->label_left_account,
        NULL);
   g_free (filename);
 
-  empathy_builder_connect (gui, information,
-      "vbox_contact_widget", "destroy", contact_widget_destroy_cb,
-      NULL);
-  information->grid_location = NULL;
-
-  g_object_set_data (G_OBJECT (information->vbox_contact_widget),
-      "EmpathyContactWidget",
-      information);
+  gtk_container_add (GTK_CONTAINER (self), main_vbox);
+  gtk_widget_show (GTK_WIDGET (main_vbox));
 
   /* Create widgets */
-  contact_widget_contact_setup (information);
-  contact_widget_details_setup (information);
-  contact_widget_client_setup (information);
+  contact_widget_contact_setup (self);
+  contact_widget_details_setup (self);
+  contact_widget_client_setup (self);
 
   if (contact != NULL)
-    contact_widget_set_contact (information, contact);
-  else if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT ||
-      information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
-    contact_widget_change_contact (information);
+    contact_widget_set_contact (self, contact);
+  else if (self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT ||
+      self->priv->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
+    contact_widget_change_contact (self);
 
-  return empathy_builder_unref_and_keep_widget (gui,
-    information->vbox_contact_widget);
+  g_object_unref (gui);
+
+  return GTK_WIDGET (self);
 }
 
 /**
@@ -1822,29 +1824,17 @@ empathy_contact_widget_new (EmpathyContact *contact,
 EmpathyContact *
 empathy_contact_widget_get_contact (GtkWidget *widget)
 {
-  EmpathyContactWidget *information;
-
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+  EmpathyContactWidget *self = EMPATHY_CONTACT_WIDGET (widget);
 
-  information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
-  if (!information)
-      return NULL;
-
-  return information->contact;
+  return self->priv->contact;
 }
 
 const gchar *
 empathy_contact_widget_get_alias (GtkWidget *widget)
 {
-  EmpathyContactWidget *information;
-
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
-  information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
-  if (!information)
-      return NULL;
+  EmpathyContactWidget *self = EMPATHY_CONTACT_WIDGET (widget);
 
-  return gtk_entry_get_text (GTK_ENTRY (information->widget_alias));
+  return gtk_entry_get_text (GTK_ENTRY (self->priv->widget_alias));
 }
 
 /**
@@ -1858,16 +1848,11 @@ void
 empathy_contact_widget_set_contact (GtkWidget *widget,
                                     EmpathyContact *contact)
 {
-  EmpathyContactWidget *information;
+  EmpathyContactWidget *self = EMPATHY_CONTACT_WIDGET (widget);
 
-  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);
+  contact_widget_set_contact (self, contact);
 }
 
 /**
@@ -1885,17 +1870,28 @@ empathy_contact_widget_set_account_filter (
     EmpathyAccountChooserFilterFunc filter,
     gpointer user_data)
 {
-  EmpathyContactWidget *information;
+  EmpathyContactWidget *self = EMPATHY_CONTACT_WIDGET (widget);
   EmpathyAccountChooser *chooser;
 
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-
-  information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
-  if (!information)
-    return;
-
-  chooser = EMPATHY_ACCOUNT_CHOOSER (information->widget_account);
+  chooser = EMPATHY_ACCOUNT_CHOOSER (self->priv->widget_account);
   if (chooser)
       empathy_account_chooser_set_filter (chooser, filter, user_data);
 }
 
+static void
+empathy_contact_widget_class_init (
+    EmpathyContactWidgetClass *klass)
+{
+  GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+  oclass->finalize = empathy_contact_widget_finalize;
+
+  g_type_class_add_private (klass, sizeof (EmpathyContactWidgetPriv));
+}
+
+static void
+empathy_contact_widget_init (EmpathyContactWidget *self)
+{
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+      EMPATHY_TYPE_CONTACT_WIDGET, EmpathyContactWidgetPriv);
+}
index a50f9fa3ecd31a77e6ef0e3c0b444a9fd2df1a4c..bf4acaf8eb16013f01d8842c1c8b79c67d0a3607 100644 (file)
 
 G_BEGIN_DECLS
 
+typedef struct _EmpathyContactWidget EmpathyContactWidget;
+typedef struct _EmpathyContactWidgetClass EmpathyContactWidgetClass;
+typedef struct _EmpathyContactWidgetPriv EmpathyContactWidgetPriv;
+
+struct _EmpathyContactWidgetClass
+{
+  /*<private>*/
+  GtkBoxClass parent_class;
+};
+
+struct _EmpathyContactWidget
+{
+  /*<private>*/
+  GtkBox parent;
+  EmpathyContactWidgetPriv *priv;
+};
+
+GType empathy_contact_widget_get_type (void);
+
+/* TYPE MACROS */
+#define EMPATHY_TYPE_CONTACT_WIDGET \
+  (empathy_contact_widget_get_type ())
+#define EMPATHY_CONTACT_WIDGET(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+    EMPATHY_TYPE_CONTACT_WIDGET, \
+    EmpathyContactWidget))
+#define EMPATHY_CONTACT_WIDGET_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), \
+    EMPATHY_TYPE_CONTACT_WIDGET, \
+    EmpathyContactWidgetClass))
+#define EMPATHY_IS_CONTACT_WIDGET(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+    EMPATHY_TYPE_CONTACT_WIDGET))
+#define EMPATHY_IS_CONTACT_WIDGET_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), \
+    EMPATHY_TYPE_CONTACT_WIDGET))
+#define EMPATHY_CONTACT_WIDGET_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+    EMPATHY_TYPE_CONTACT_WIDGET, \
+    EmpathyContactWidgetClass))
+
 /**
  * EmpathyContactWidgetFlags:
  * @EMPATHY_CONTACT_WIDGET_EDIT_NONE: Don't show any widgets to edit any details