]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-presence-chooser.c
Updated Basque language
[empathy.git] / libempathy-gtk / empathy-presence-chooser.c
index 672cd981a5d6cb0868eb0ecff283de806f23a801..ba36e091c518a65419e6544c9169e3dc58b85813 100644 (file)
@@ -15,8 +15,8 @@
  *
  * You should have received a copy of the GNU General Public
  * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301  USA
  *
  * Authors: Richard Hult <richard@imendio.com>
  *          Martyn Russell <martyn@imendio.com>
 
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
-#include <glade/glade.h>
 #include <gdk/gdkkeysyms.h>
 
 #include <telepathy-glib/util.h>
-#include <libmissioncontrol/mc-enum-types.h>
 
+#include <libempathy/empathy-connectivity.h>
 #include <libempathy/empathy-idle.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-status-presets.h>
 #include "empathy-ui-utils.h"
 #include "empathy-images.h"
 #include "empathy-presence-chooser.h"
+#include "empathy-status-preset-dialog.h"
+
+/**
+ * SECTION:empathy-presence-chooser
+ * @title:EmpathyPresenceChooser
+ * @short_description: A widget used to change presence
+ * @include: libempathy-gtk/empathy-presence-chooser.h
+ *
+ * #EmpathyPresenceChooser is a widget which extends #GtkComboBoxEntry
+ * to change presence.
+ */
+
+/**
+ * EmpathyAccountChooser:
+ * @parent: parent object
+ *
+ * Widget which extends #GtkComboBoxEntry to change presence.
+ */
 
 /* Flashing delay for icons (milliseconds). */
 #define FLASH_TIMEOUT 500
 
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyPresenceChooser)
+
+/* For custom message dialog */
+enum {
+       COL_ICON,
+       COL_LABEL,
+       COL_PRESENCE,
+       COL_COUNT
+};
+
+/* For combobox's model */
+enum {
+       COL_STATUS_TEXT,
+       COL_STATE_ICON_NAME,
+       COL_STATE,
+       COL_DISPLAY_MARKUP,
+       COL_STATUS_CUSTOMISABLE,
+       COL_TYPE,
+       N_COLUMNS
+};
+
+typedef enum  {
+       ENTRY_TYPE_BUILTIN,
+       ENTRY_TYPE_SAVED,
+       ENTRY_TYPE_CUSTOM,
+       ENTRY_TYPE_SEPARATOR,
+       ENTRY_TYPE_EDIT_CUSTOM,
+} PresenceChooserEntryType;
+
 typedef struct {
        EmpathyIdle *idle;
+       EmpathyConnectivity *connectivity;
+
+       gulong state_change_signal_id;
 
        gboolean     editing_status;
        int          block_set_editing;
        int          block_changed;
        guint        focus_out_idle_source;
 
-       McPresence   state;
-       int          previous_type;
+       TpConnectionPresenceType state;
+       PresenceChooserEntryType previous_type;
 
-       McPresence   flash_state_1;
-       McPresence   flash_state_2;
+       TpConnectionPresenceType   flash_state_1;
+       TpConnectionPresenceType   flash_state_2;
        guint        flash_timeout_id;
 } EmpathyPresenceChooserPriv;
 
-typedef struct {
-       GtkWidget    *dialog;
-       GtkWidget    *checkbutton_save;
-       GtkWidget    *comboboxentry_message;
-       GtkWidget    *entry_message;
-       GtkWidget    *combobox_status;
-       GtkTreeModel *model_status;
-} CustomMessageDialog;
-
-enum {
-       COL_ICON,
-       COL_LABEL,
-       COL_PRESENCE,
-       COL_COUNT
-};
-
-static CustomMessageDialog *message_dialog = NULL;
 /* States to be listed in the menu.
  * Each state has a boolean telling if it can have custom message */
-static guint states[] = {MC_PRESENCE_AVAILABLE, TRUE,
-                        MC_PRESENCE_DO_NOT_DISTURB, TRUE,
-                        MC_PRESENCE_AWAY, TRUE,
-                        MC_PRESENCE_HIDDEN, FALSE,
-                        MC_PRESENCE_OFFLINE, FALSE};
+static struct { TpConnectionPresenceType state;
+         gboolean customisable;
+} states[] = { { TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, TRUE } ,
+                        { TP_CONNECTION_PRESENCE_TYPE_BUSY, TRUE },
+                        { TP_CONNECTION_PRESENCE_TYPE_AWAY, TRUE },
+                        { TP_CONNECTION_PRESENCE_TYPE_HIDDEN, FALSE },
+                        { TP_CONNECTION_PRESENCE_TYPE_OFFLINE, FALSE},
+                        { TP_CONNECTION_PRESENCE_TYPE_UNSET, },
+                       };
 
 static void            presence_chooser_finalize               (GObject                    *object);
 static void            presence_chooser_presence_changed_cb    (EmpathyPresenceChooser      *chooser);
 static gboolean        presence_chooser_flash_timeout_cb       (EmpathyPresenceChooser      *chooser);
 static void            presence_chooser_flash_start            (EmpathyPresenceChooser      *chooser,
-                                                               McPresence                  state_1,
-                                                               McPresence                  state_2);
+                                                               TpConnectionPresenceType                  state_1,
+                                                               TpConnectionPresenceType                  state_2);
 static void            presence_chooser_flash_stop             (EmpathyPresenceChooser      *chooser,
-                                                               McPresence                  state);
+                                                               TpConnectionPresenceType                  state);
 static void            presence_chooser_menu_add_item          (GtkWidget                  *menu,
                                                                const gchar                *str,
-                                                               McPresence                  state);
+                                                               TpConnectionPresenceType                  state);
 static void            presence_chooser_noncustom_activate_cb  (GtkWidget                  *item,
                                                                gpointer                    user_data);
-static void            presence_chooser_set_state              (McPresence                  state,
+static void            presence_chooser_set_state              (TpConnectionPresenceType                  state,
                                                                const gchar                *status);
 static void            presence_chooser_custom_activate_cb     (GtkWidget                  *item,
                                                                gpointer                    user_data);
-static void            presence_chooser_dialog_show            (GtkWindow                  *parent);
 
 G_DEFINE_TYPE (EmpathyPresenceChooser, empathy_presence_chooser, GTK_TYPE_COMBO_BOX_ENTRY);
 
@@ -124,84 +158,64 @@ empathy_presence_chooser_class_init (EmpathyPresenceChooserClass *klass)
        g_type_class_add_private (object_class, sizeof (EmpathyPresenceChooserPriv));
 }
 
-enum
-{
-       COL_STATE_ICON_NAME,
-       COL_STATE,
-       COL_STATUS_TEXT,
-       COL_DISPLAY_MARKUP,
-       COL_STATUS_CUSTOMISABLE,
-       COL_TYPE,
-       N_COLUMNS
-};
-
-enum
-{
-       ENTRY_TYPE_BUILTIN,
-       ENTRY_TYPE_SAVED,
-       ENTRY_TYPE_CUSTOM,
-       ENTRY_TYPE_SEPARATOR,
-       ENTRY_TYPE_EDIT_CUSTOM,
-};
-
-static GtkTreeModel *
-presence_chooser_create_model (void)
+static void
+presence_chooser_create_model (EmpathyPresenceChooser *self)
 {
        GtkListStore *store;
        char *custom_message;
+       int i;
 
        store = gtk_list_store_new (N_COLUMNS,
-                       G_TYPE_STRING,          /* COL_STATE_ICON_NAME */
-                       MC_TYPE_PRESENCE,       /* COL_STATE */
-                       G_TYPE_STRING,          /* COL_STATUS_TEXT */
-                       G_TYPE_STRING,          /* COL_DISPLAY_MARKUP */
-                       G_TYPE_BOOLEAN,         /* COL_STATUS_CUSTOMISABLE */
-                       G_TYPE_INT);            /* COL_TYPE */
+                                   G_TYPE_STRING,    /* COL_STATUS_TEXT */
+                                   G_TYPE_STRING,    /* COL_STATE_ICON_NAME */
+                                   G_TYPE_UINT,      /* COL_STATE */
+                                   G_TYPE_STRING,    /* COL_DISPLAY_MARKUP */
+                                   G_TYPE_BOOLEAN,   /* COL_STATUS_CUSTOMISABLE */
+                                   G_TYPE_INT);      /* COL_TYPE */
 
        custom_message = g_strdup_printf ("<i>%s</i>", _("Custom Message..."));
 
-       int i;
-       for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
+       for (i = 0; states[i].state != TP_CONNECTION_PRESENCE_TYPE_UNSET; i++) {
                GList       *list, *l;
                const char *status, *icon_name;
 
-               status = empathy_presence_get_default_message (states[i]);
-               icon_name = empathy_icon_name_for_presence (states[i]);
+               status = empathy_presence_get_default_message (states[i].state);
+               icon_name = empathy_icon_name_for_presence (states[i].state);
 
                gtk_list_store_insert_with_values (store, NULL, -1,
-                               COL_STATE_ICON_NAME, icon_name,
-                               COL_STATE, states[i],
-                               COL_STATUS_TEXT, status,
-                               COL_DISPLAY_MARKUP, status,
-                               COL_STATUS_CUSTOMISABLE, states[i+1],
-                               COL_TYPE, ENTRY_TYPE_BUILTIN,
-                               -1);
-
-               if (states[i+1]) {
+                       COL_STATUS_TEXT, status,
+                       COL_STATE_ICON_NAME, icon_name,
+                       COL_STATE, states[i].state,
+                       COL_DISPLAY_MARKUP, status,
+                       COL_STATUS_CUSTOMISABLE, states[i].customisable,
+                       COL_TYPE, ENTRY_TYPE_BUILTIN,
+                       -1);
 
+               if (states[i].customisable) {
                        /* Set custom messages if wanted */
-                       list = empathy_status_presets_get (states[i], 5);
+                       list = empathy_status_presets_get (states[i].state, -1);
+                       list = g_list_sort (list, (GCompareFunc) g_utf8_collate);
                        for (l = list; l; l = l->next) {
                                gtk_list_store_insert_with_values (store,
-                                               NULL, -1,
-                                               COL_STATE_ICON_NAME, icon_name,
-                                               COL_STATE, states[i],
-                                               COL_STATUS_TEXT, l->data,
-                                               COL_DISPLAY_MARKUP, l->data,
-                                               COL_STATUS_CUSTOMISABLE, TRUE,
-                                               COL_TYPE, ENTRY_TYPE_SAVED,
-                                               -1);
+                                       NULL, -1,
+                                       COL_STATUS_TEXT, l->data,
+                                       COL_STATE_ICON_NAME, icon_name,
+                                       COL_STATE, states[i].state,
+                                       COL_DISPLAY_MARKUP, l->data,
+                                       COL_STATUS_CUSTOMISABLE, TRUE,
+                                       COL_TYPE, ENTRY_TYPE_SAVED,
+                                       -1);
                        }
                        g_list_free (list);
 
                        gtk_list_store_insert_with_values (store, NULL, -1,
-                                       COL_STATE_ICON_NAME, icon_name,
-                                       COL_STATE, states[i],
-                                       COL_STATUS_TEXT, "",
-                                       COL_DISPLAY_MARKUP, custom_message,
-                                       COL_STATUS_CUSTOMISABLE, TRUE,
-                                       COL_TYPE, ENTRY_TYPE_CUSTOM,
-                                       -1);
+                               COL_STATUS_TEXT, _("Custom Message..."),
+                               COL_STATE_ICON_NAME, icon_name,
+                               COL_STATE, states[i].state,
+                               COL_DISPLAY_MARKUP, custom_message,
+                               COL_STATUS_CUSTOMISABLE, TRUE,
+                               COL_TYPE, ENTRY_TYPE_CUSTOM,
+                               -1);
                }
 
        }
@@ -212,15 +226,16 @@ presence_chooser_create_model (void)
                        -1);
 
        gtk_list_store_insert_with_values (store, NULL, -1,
-                       COL_STATE_ICON_NAME, GTK_STOCK_EDIT,
-                       COL_STATUS_TEXT, "",
-                       COL_DISPLAY_MARKUP, _("Edit Custom Messages..."),
-                       COL_TYPE, ENTRY_TYPE_EDIT_CUSTOM,
-                       -1);
+               COL_STATUS_TEXT, _("Edit Custom Messages..."),
+               COL_STATE_ICON_NAME, GTK_STOCK_EDIT,
+               COL_DISPLAY_MARKUP, _("Edit Custom Messages..."),
+               COL_TYPE, ENTRY_TYPE_EDIT_CUSTOM,
+               -1);
 
        g_free (custom_message);
 
-       return GTK_TREE_MODEL (store);
+       gtk_combo_box_set_model (GTK_COMBO_BOX (self), GTK_TREE_MODEL (store));
+       g_object_unref (store);
 }
 
 static void
@@ -232,21 +247,107 @@ presence_chooser_popup_shown_cb (GObject *self,
        gboolean shown;
 
        g_object_get (self, "popup-shown", &shown, NULL);
+       if (!shown) {
+               return;
+       }
 
-       if (!shown) return;
-
-       /* see presence_chooser_entry_focus_out_cb() for what this does */
-       if (priv->focus_out_idle_source != 0)
-       {
+       /* see presence_chooser_entry_focus_out_cb () for what this does */
+       if (priv->focus_out_idle_source != 0) {
                g_source_remove (priv->focus_out_idle_source);
                priv->focus_out_idle_source = 0;
        }
 
-       GtkTreeModel *model = presence_chooser_create_model ();
+       presence_chooser_create_model (EMPATHY_PRESENCE_CHOOSER (self));
+}
+
+static PresenceChooserEntryType
+presence_chooser_get_entry_type (EmpathyPresenceChooser *self)
+{
+       GtkTreeIter iter;
+       PresenceChooserEntryType type = -1;
+
+       if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self), &iter)) {
+               type = ENTRY_TYPE_CUSTOM;
+       }
+       else {
+               GtkTreeModel *model;
+
+               model = gtk_combo_box_get_model (GTK_COMBO_BOX (self));
+               gtk_tree_model_get (model, &iter,
+                                   COL_TYPE, &type,
+                                   -1);
+       }
+
+       return type;
+}
+
+static gboolean
+presence_chooser_is_preset (EmpathyPresenceChooser *self)
+{
+       EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
+       TpConnectionPresenceType state;
+       const char *status;
+       GList *presets, *l;
+       gboolean match = FALSE;
+
+       state = empathy_idle_get_state (priv->idle);
+       status = empathy_idle_get_status (priv->idle);
+
+       presets = empathy_status_presets_get (state, -1);
+       for (l = presets; l; l = l->next) {
+               char *preset = (char *) l->data;
+
+               if (!tp_strdiff (status, preset)) {
+                       match = TRUE;
+                       break;
+               }
+       }
+
+       g_list_free (presets);
 
-       gtk_combo_box_set_model (GTK_COMBO_BOX (self), GTK_TREE_MODEL (model));
+       DEBUG ("is_preset(%i, %s) = %i\n", state, status, match);
 
-       g_object_unref (model);
+       return match;
+}
+
+static void
+presence_chooser_set_favorite_icon (EmpathyPresenceChooser *self)
+{
+       GtkWidget *entry;
+       PresenceChooserEntryType type;
+
+       entry = gtk_bin_get_child (GTK_BIN (self));
+       type = presence_chooser_get_entry_type (self);
+
+       if (type == ENTRY_TYPE_CUSTOM || type == ENTRY_TYPE_SAVED) {
+               if (presence_chooser_is_preset (self)) {
+                       /* saved entries can be removed from the list */
+                       gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
+                                          GTK_ENTRY_ICON_SECONDARY,
+                                          "empathy-starred");
+                       gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+                                        GTK_ENTRY_ICON_SECONDARY,
+                                        _("Click to remove this status as a favorite"));
+               }
+               else {
+                       /* custom entries can be favorited */
+                       gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
+                                          GTK_ENTRY_ICON_SECONDARY,
+                                          "empathy-unstarred");
+                       gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+                                        GTK_ENTRY_ICON_SECONDARY,
+                                        _("Click to make this status a favorite"));
+               }
+       }
+       else {
+               /* built-in entries cannot be favorited */
+               gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
+                                          GTK_ENTRY_ICON_SECONDARY,
+                                          NULL);
+               gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+                                        GTK_ENTRY_ICON_SECONDARY,
+                                        NULL);
+       }
 }
 
 static void
@@ -254,42 +355,41 @@ presence_chooser_set_status_editing (EmpathyPresenceChooser *self,
                                      gboolean editing)
 {
        EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
-       GtkWidget *entry = gtk_bin_get_child (GTK_BIN (self));
+       GtkWidget *entry;
 
-       if (priv->block_set_editing) return;
+       if (priv->block_set_editing) {
+               return;
+       }
 
+       entry = gtk_bin_get_child (GTK_BIN (self));
        if (editing) {
                priv->editing_status = TRUE;
 
                gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
-                               GTK_ENTRY_ICON_SECONDARY,
-                               GTK_STOCK_OK);
+                                              GTK_ENTRY_ICON_SECONDARY,
+                                              GTK_STOCK_OK);
                gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
-                               GTK_ENTRY_ICON_SECONDARY,
-                               _("Set status"));
+                                                GTK_ENTRY_ICON_SECONDARY,
+                                                _("Set status"));
                gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
-                               GTK_ENTRY_ICON_PRIMARY,
-                               FALSE);
-       }
-       else {
-               gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
-                               GTK_ENTRY_ICON_SECONDARY,
-                               NULL);
-               gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
-                               GTK_ENTRY_ICON_SECONDARY,
-                               NULL);
+                                             GTK_ENTRY_ICON_PRIMARY,
+                                             FALSE);
+       } else {
+               GtkWidget *window;
+
+               presence_chooser_set_favorite_icon (self);
                gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
-                               GTK_ENTRY_ICON_PRIMARY,
-                               TRUE);
+                                             GTK_ENTRY_ICON_PRIMARY,
+                                             TRUE);
 
                /* attempt to get the toplevel for this widget */
-               GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
+               window = gtk_widget_get_toplevel (GTK_WIDGET (self));
                if (GTK_WIDGET_TOPLEVEL (window) && GTK_IS_WINDOW (window)) {
                        /* unset the focus */
                        gtk_window_set_focus (GTK_WINDOW (window), NULL);
                }
 
-               /* see presence_chooser_entry_focus_out_cb()
+               /* see presence_chooser_entry_focus_out_cb ()
                 * for what this does */
                if (priv->focus_out_idle_source != 0) {
                        g_source_remove (priv->focus_out_idle_source);
@@ -313,17 +413,15 @@ mc_set_custom_state (EmpathyPresenceChooser *self)
        /* update the status with MC */
        status = gtk_entry_get_text (GTK_ENTRY (entry));
 
-       DEBUG ("Sending state to MC-> %s (%s)\n",
-                       g_enum_get_value (g_type_class_peek (MC_TYPE_PRESENCE),
-                               priv->state)->value_name,
-                       status);
+       DEBUG ("Sending state to MC-> %d (%s)\n", priv->state, status);
+
        empathy_idle_set_presence (priv->idle, priv->state, status);
 }
 
 static void
 ui_set_custom_state (EmpathyPresenceChooser *self,
-                          McPresence state,
-                          const char *status)
+                    TpConnectionPresenceType state,
+                    const char *status)
 {
        EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
        GtkWidget *entry;
@@ -336,9 +434,10 @@ ui_set_custom_state (EmpathyPresenceChooser *self,
 
        icon_name = empathy_icon_name_for_presence (state);
        gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
-                       GTK_ENTRY_ICON_PRIMARY,
-                       icon_name);
-       gtk_entry_set_text (GTK_ENTRY (entry), status);
+                                          GTK_ENTRY_ICON_PRIMARY,
+                                          icon_name);
+       gtk_entry_set_text (GTK_ENTRY (entry), status == NULL ? "" : status);
+       presence_chooser_set_favorite_icon (self);
 
        priv->block_changed--;
        priv->block_set_editing--;
@@ -348,39 +447,69 @@ static void
 presence_chooser_reset_status (EmpathyPresenceChooser *self)
 {
        /* recover the status that was unset */
-       presence_chooser_presence_changed_cb (self);
        presence_chooser_set_status_editing (self, FALSE);
+       presence_chooser_presence_changed_cb (self);
 }
 
 static void
-presence_chooser_entry_icon_release_cb (EmpathyPresenceChooser *self,
-                                        GtkEntryIconPosition    icon_pos,
-                                        GdkEvent               *event,
-                                       GtkEntry                *entry)
+presence_chooser_entry_icon_release_cb (EmpathyPresenceChooser *self,
+                                        GtkEntryIconPosition    icon_pos,
+                                        GdkEvent               *event,
+                                       GtkEntry               *entry)
 {
-       presence_chooser_set_status_editing (self, FALSE);
-       mc_set_custom_state (self);
+       EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
+
+       if (priv->editing_status) {
+               presence_chooser_set_status_editing (self, FALSE);
+               mc_set_custom_state (self);
+       }
+       else {
+               PresenceChooserEntryType type;
+               TpConnectionPresenceType state;
+               const char *status;
+
+               type = presence_chooser_get_entry_type (self);
+               state = empathy_idle_get_state (priv->idle);
+               status = empathy_idle_get_status (priv->idle);
+
+               if (!empathy_status_presets_is_valid (state))
+                       /* It doesn't make sense to add such presence as favorite */
+                       return;
+
+               if (presence_chooser_is_preset (self)) {
+                       /* remove the entry */
+                       DEBUG ("REMOVING PRESET (%i, %s)\n", state, status);
+                       empathy_status_presets_remove (state, status);
+               }
+               else {
+                       /* save the entry */
+                       DEBUG ("SAVING PRESET (%i, %s)\n", state, status);
+                       empathy_status_presets_set_last (state, status);
+               }
+
+               /* update the icon */
+               presence_chooser_set_favorite_icon (self);
+       }
 }
 
 static void
-presence_chooser_entry_activate_cb (EmpathyPresenceChooser     *self,
-                                    GtkEntry                   *entry)
+presence_chooser_entry_activate_cb (EmpathyPresenceChooser *self,
+                                    GtkEntry               *entry)
 {
        presence_chooser_set_status_editing (self, FALSE);
        mc_set_custom_state (self);
 }
 
 static gboolean
-presence_chooser_entry_key_press_event_cb (EmpathyPresenceChooser      *self,
-                                           GdkEventKey                 *event,
-                                          GtkWidget                    *entry)
+presence_chooser_entry_key_press_event_cb (EmpathyPresenceChooser *self,
+                                           GdkEventKey            *event,
+                                          GtkWidget              *entry)
 {
        EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
 
        if (priv->editing_status && event->keyval == GDK_Escape) {
                /* the user pressed Escape, undo the editing */
                presence_chooser_reset_status (self);
-
                return TRUE;
        }
        else if (event->keyval == GDK_Up || event->keyval == GDK_Down) {
@@ -416,7 +545,9 @@ presence_chooser_entry_changed_cb (EmpathyPresenceChooser *self,
 {
        EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
 
-       if (priv->block_changed) return;
+       if (priv->block_changed){
+               return;
+       }
 
        /* the combo is being edited to a custom entry */
        if (!priv->editing_status) {
@@ -428,27 +559,26 @@ static void
 presence_chooser_changed_cb (GtkComboBox *self, gpointer user_data)
 {
        EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
-
-       if (priv->block_changed) return;
-
        GtkTreeIter iter;
        char *icon_name;
-       McPresence new_state;
+       TpConnectionPresenceType new_state;
        gboolean customisable = TRUE;
-       int type = -1;
+       PresenceChooserEntryType type = -1;
        GtkWidget *entry;
+       GtkTreeModel *model;
 
-       GtkTreeModel *model = gtk_combo_box_get_model (self);
-       if (!gtk_combo_box_get_active_iter (self, &iter)) {
+       if (priv->block_changed ||
+           !gtk_combo_box_get_active_iter (self, &iter)) {
                return;
        }
 
+       model = gtk_combo_box_get_model (self);
        gtk_tree_model_get (model, &iter,
-                       COL_STATE_ICON_NAME, &icon_name,
-                       COL_STATE, &new_state,
-                       COL_STATUS_CUSTOMISABLE, &customisable,
-                       COL_TYPE, &type,
-                       -1);
+                           COL_STATE_ICON_NAME, &icon_name,
+                           COL_STATE, &new_state,
+                           COL_STATUS_CUSTOMISABLE, &customisable,
+                           COL_TYPE, &type,
+                           -1);
 
        entry = gtk_bin_get_child (GTK_BIN (self));
 
@@ -461,28 +591,31 @@ presence_chooser_changed_cb (GtkComboBox *self, gpointer user_data)
        }
 
        if (type == ENTRY_TYPE_EDIT_CUSTOM) {
+               GtkWidget *window, *dialog;
+
                presence_chooser_reset_status (EMPATHY_PRESENCE_CHOOSER (self));
 
                /* attempt to get the toplevel for this widget */
-               GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
+               window = gtk_widget_get_toplevel (GTK_WIDGET (self));
                if (!GTK_WIDGET_TOPLEVEL (window) || !GTK_IS_WINDOW (window)) {
                        window = NULL;
                }
 
-               presence_chooser_dialog_show (GTK_WINDOW (window));
+               dialog = empathy_status_preset_dialog_new (GTK_WINDOW (window));
+               gtk_dialog_run (GTK_DIALOG (dialog));
+               gtk_widget_destroy (dialog);
        }
        else if (type == ENTRY_TYPE_CUSTOM) {
                gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
-                               GTK_ENTRY_ICON_PRIMARY,
-                               icon_name);
+                                                  GTK_ENTRY_ICON_PRIMARY,
+                                                  icon_name);
 
                /* preseed the status */
                if (priv->previous_type == ENTRY_TYPE_BUILTIN) {
                        /* if their previous entry was a builtin, don't
                         * preseed */
                        gtk_entry_set_text (GTK_ENTRY (entry), "");
-               }
-               else {
+               } else {
                        /* else preseed the text of their currently entered
                         * status message */
                        const char *status;
@@ -493,18 +626,21 @@ presence_chooser_changed_cb (GtkComboBox *self, gpointer user_data)
 
                /* grab the focus */
                gtk_widget_grab_focus (entry);
-       }
-       else {
+       } else {
                char *status;
+
                /* just in case we were setting a new status when
                 * things were changed */
                presence_chooser_set_status_editing (
-                               EMPATHY_PRESENCE_CHOOSER (self),
-                               FALSE);
+                       EMPATHY_PRESENCE_CHOOSER (self),
+                       FALSE);
+               gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
+                                          GTK_ENTRY_ICON_PRIMARY,
+                                          icon_name);
 
                gtk_tree_model_get (model, &iter,
-                               COL_STATUS_TEXT, &status,
-                               -1);
+                                   COL_STATUS_TEXT, &status,
+                                   -1);
 
                empathy_idle_set_presence (priv->idle, priv->state, status);
 
@@ -522,10 +658,11 @@ combo_row_separator_func (GtkTreeModel    *model,
                          GtkTreeIter   *iter,
                          gpointer       data)
 {
-       int type;
+       PresenceChooserEntryType type;
+
        gtk_tree_model_get (model, iter,
-                       COL_TYPE, &type,
-                       -1);
+                           COL_TYPE, &type,
+                           -1);
 
        return (type == ENTRY_TYPE_SEPARATOR);
 }
@@ -567,8 +704,8 @@ presence_chooser_entry_focus_out_cb (EmpathyPresenceChooser *chooser,
                 * it will remove it, else the callback will commit the result.
                 */
                priv->focus_out_idle_source = g_idle_add (
-                               presence_chooser_entry_focus_out_idle_cb,
-                               chooser);
+                       presence_chooser_entry_focus_out_idle_cb,
+                       chooser);
        }
 
        gtk_editable_set_position (GTK_EDITABLE (entry), 0);
@@ -576,62 +713,64 @@ presence_chooser_entry_focus_out_cb (EmpathyPresenceChooser *chooser,
        return FALSE;
 }
 
+static void
+presence_chooser_connectivity_state_change (EmpathyConnectivity *connectivity,
+                                           gboolean new_online,
+                                           EmpathyPresenceChooser *chooser)
+{
+       gtk_widget_set_sensitive (GTK_WIDGET (chooser), new_online);
+}
+
 static void
 empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
 {
        EmpathyPresenceChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser,
                EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv);
-       GtkTreeModel *model;
        GtkWidget *entry;
        GtkCellRenderer *renderer;
 
        chooser->priv = priv;
 
-       model = presence_chooser_create_model ();
+       presence_chooser_create_model (chooser);
 
-       gtk_combo_box_set_model (GTK_COMBO_BOX (chooser), GTK_TREE_MODEL (model));
        gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (chooser),
-                       COL_STATUS_TEXT);
+                                            COL_STATUS_TEXT);
        gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (chooser),
-                       combo_row_separator_func,
-                       NULL, NULL);
+                                             combo_row_separator_func,
+                                             NULL, NULL);
 
        entry = gtk_bin_get_child (GTK_BIN (chooser));
        gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
-                       GTK_ENTRY_ICON_PRIMARY, FALSE);
-       g_signal_connect_object (entry, "icon-release",
-                       G_CALLBACK (presence_chooser_entry_icon_release_cb),
-                       chooser,
-                       G_CONNECT_SWAPPED);
-       g_signal_connect_object (entry, "activate",
-                       G_CALLBACK (presence_chooser_entry_activate_cb),
-                       chooser,
-                       G_CONNECT_SWAPPED);
-       g_signal_connect_object (entry, "key-press-event",
-                       G_CALLBACK (presence_chooser_entry_key_press_event_cb),
-                       chooser,
-                       G_CONNECT_SWAPPED);
-       g_signal_connect_object (entry, "button-press-event",
-                       G_CALLBACK (presence_chooser_entry_button_press_event_cb),
-                       chooser,
-                       G_CONNECT_SWAPPED);
+                                       GTK_ENTRY_ICON_PRIMARY,
+                                       FALSE);
+
+       g_signal_connect_swapped (entry, "icon-release",
+               G_CALLBACK (presence_chooser_entry_icon_release_cb),
+               chooser);
+       g_signal_connect_swapped (entry, "activate",
+               G_CALLBACK (presence_chooser_entry_activate_cb),
+               chooser);
+       g_signal_connect_swapped (entry, "key-press-event",
+               G_CALLBACK (presence_chooser_entry_key_press_event_cb),
+               chooser);
+       g_signal_connect_swapped (entry, "button-press-event",
+               G_CALLBACK (presence_chooser_entry_button_press_event_cb),
+               chooser);
 
        gtk_cell_layout_clear (GTK_CELL_LAYOUT (chooser));
 
        renderer = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser), renderer, FALSE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser), renderer,
-                       "icon-name", COL_STATE_ICON_NAME,
-                       NULL);
+                                       "icon-name", COL_STATE_ICON_NAME,
+                                       NULL);
        g_object_set (renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL);
 
        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser), renderer, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser), renderer,
-                       "markup", COL_DISPLAY_MARKUP,
-                       NULL);
-
-       g_object_unref (model);
+                                       "markup", COL_DISPLAY_MARKUP,
+                                       NULL);
 
        g_signal_connect (chooser, "notify::popup-shown",
                        G_CALLBACK (presence_chooser_popup_shown_cb), NULL);
@@ -647,13 +786,20 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
        priv->idle = empathy_idle_dup_singleton ();
        presence_chooser_presence_changed_cb (chooser);
        g_signal_connect_swapped (priv->idle, "notify",
-                       G_CALLBACK (presence_chooser_presence_changed_cb),
-                       chooser);
-
-       g_object_set (chooser,
-                       // FIXME: this string sucks
-                       "tooltip-text", _("Set your presence and current status"),
-                       NULL);
+               G_CALLBACK (presence_chooser_presence_changed_cb),
+               chooser);
+
+       /* FIXME: this string sucks */
+       gtk_widget_set_tooltip_text (GTK_WIDGET (chooser),
+               _("Set your presence and current status"));
+
+       priv->connectivity = empathy_connectivity_dup_singleton ();
+       priv->state_change_signal_id = g_signal_connect (priv->connectivity,
+               "state-change",
+               G_CALLBACK (presence_chooser_connectivity_state_change),
+               chooser);
+       presence_chooser_connectivity_state_change (priv->connectivity,
+               empathy_connectivity_is_online (priv->connectivity), chooser);
 }
 
 static void
@@ -676,9 +822,22 @@ presence_chooser_finalize (GObject *object)
                                              object);
        g_object_unref (priv->idle);
 
+       g_signal_handler_disconnect (priv->connectivity,
+                                    priv->state_change_signal_id);
+       priv->state_change_signal_id = 0;
+
+       g_object_unref (priv->connectivity);
+
        G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->finalize (object);
 }
 
+/**
+ * empathy_presence_chooser_new:
+ *
+ * Creates a new #EmpathyPresenceChooser widget.
+ *
+ * Return value: A new #EmpathyPresenceChooser widget
+ */
 GtkWidget *
 empathy_presence_chooser_new (void)
 {
@@ -693,15 +852,19 @@ static void
 presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser)
 {
        EmpathyPresenceChooserPriv *priv;
-       McPresence                 state;
-       McPresence                 flash_state;
+       TpConnectionPresenceType    state;
+       TpConnectionPresenceType    flash_state;
        const gchar                *status;
        GtkTreeModel               *model;
-       GtkTreeIter                iter;
+       GtkTreeIter                 iter;
        gboolean valid, match_state = FALSE, match = FALSE;
 
        priv = GET_PRIV (chooser);
 
+       if (priv->editing_status) {
+               return;
+       }
+
        priv->state = state = empathy_idle_get_state (priv->idle);
        status = empathy_idle_get_status (priv->idle);
        flash_state = empathy_idle_get_flash_state (priv->idle);
@@ -712,7 +875,7 @@ presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser)
             valid;
             valid = gtk_tree_model_iter_next (model, &iter)) {
                int m_type;
-               McPresence m_state;
+               TpConnectionPresenceType m_state;
                char *m_status;
 
                gtk_tree_model_get (model, &iter,
@@ -740,7 +903,7 @@ presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser)
                                COL_STATUS_TEXT, &m_status,
                                -1);
 
-               match = !strcmp (status, m_status);
+               match = !tp_strdiff (status, m_status);
 
                g_free (m_status);
 
@@ -751,13 +914,14 @@ presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser)
        if (match) {
                priv->block_changed++;
                gtk_combo_box_set_active_iter (GTK_COMBO_BOX (chooser), &iter);
+               presence_chooser_set_favorite_icon (chooser);
                priv->block_changed--;
        }
        else {
                ui_set_custom_state (chooser, state, status);
        }
 
-       if (flash_state != MC_PRESENCE_UNSET) {
+       if (flash_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
                presence_chooser_flash_start (chooser, state, flash_state);
        }
        else {
@@ -769,8 +933,9 @@ static gboolean
 presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser)
 {
        EmpathyPresenceChooserPriv *priv;
-       McPresence                 state;
-       static gboolean            on = FALSE;
+       TpConnectionPresenceType    state;
+       static gboolean             on = FALSE;
+       GtkWidget                  *entry;
 
        priv = GET_PRIV (chooser);
 
@@ -781,10 +946,10 @@ presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser)
                state = priv->flash_state_2;
        }
 
-       GtkWidget *entry = gtk_bin_get_child (GTK_BIN (chooser));
+       entry = gtk_bin_get_child (GTK_BIN (chooser));
        gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
-                       GTK_ENTRY_ICON_PRIMARY,
-                       empathy_icon_name_for_presence (state));
+                                          GTK_ENTRY_ICON_PRIMARY,
+                                          empathy_icon_name_for_presence (state));
 
        on = !on;
 
@@ -793,8 +958,8 @@ presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser)
 
 static void
 presence_chooser_flash_start (EmpathyPresenceChooser *chooser,
-                             McPresence             state_1,
-                             McPresence             state_2)
+                             TpConnectionPresenceType state_1,
+                             TpConnectionPresenceType state_2)
 {
        EmpathyPresenceChooserPriv *priv;
 
@@ -807,32 +972,36 @@ presence_chooser_flash_start (EmpathyPresenceChooser *chooser,
 
        if (!priv->flash_timeout_id) {
                priv->flash_timeout_id = g_timeout_add (FLASH_TIMEOUT,
-                                                       (GSourceFunc) presence_chooser_flash_timeout_cb,
-                                                       chooser);
+                       (GSourceFunc) presence_chooser_flash_timeout_cb,
+                       chooser);
        }
 }
 
 static void
 presence_chooser_flash_stop (EmpathyPresenceChooser *chooser,
-                            McPresence             state)
+                            TpConnectionPresenceType state)
 {
-       EmpathyPresenceChooserPriv *priv;
-
-       g_return_if_fail (EMPATHY_IS_PRESENCE_CHOOSER (chooser));
-
-       priv = GET_PRIV (chooser);
+       EmpathyPresenceChooserPriv *priv = GET_PRIV (chooser);
+       GtkWidget *entry;
 
        if (priv->flash_timeout_id) {
                g_source_remove (priv->flash_timeout_id);
                priv->flash_timeout_id = 0;
        }
-       GtkWidget *entry = gtk_bin_get_child (GTK_BIN (chooser));
 
+       entry = gtk_bin_get_child (GTK_BIN (chooser));
        gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
-                       GTK_ENTRY_ICON_PRIMARY,
-                       empathy_icon_name_for_presence (state));
+                                          GTK_ENTRY_ICON_PRIMARY,
+                                          empathy_icon_name_for_presence (state));
 }
 
+/**
+ * empathy_presence_chooser_create_menu:
+ *
+ * Creates a new #GtkMenu allowing users to change their presence from a menu.
+ *
+ * Return value: a new #GtkMenu for changing presence in a menu.
+ */
 GtkWidget *
 empathy_presence_chooser_create_menu (void)
 {
@@ -844,21 +1013,21 @@ empathy_presence_chooser_create_menu (void)
 
        menu = gtk_menu_new ();
 
-       for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
+       for (i = 0; states[i].state != TP_CONNECTION_PRESENCE_TYPE_UNSET; i++) {
                GList       *list, *l;
 
-               status = empathy_presence_get_default_message (states[i]);
+               status = empathy_presence_get_default_message (states[i].state);
                presence_chooser_menu_add_item (menu,
                                                status,
-                                               states[i]);
+                                               states[i].state);
 
-               if (states[i+1]) {
+               if (states[i].customisable) {
                        /* Set custom messages if wanted */
-                       list = empathy_status_presets_get (states[i], 5);
+                       list = empathy_status_presets_get (states[i].state, 5);
                        for (l = list; l; l = l->next) {
                                presence_chooser_menu_add_item (menu,
                                                                l->data,
-                                                               states[i]);
+                                                               states[i].state);
                        }
                        g_list_free (list);
                }
@@ -889,7 +1058,7 @@ empathy_presence_chooser_create_menu (void)
 static void
 presence_chooser_menu_add_item (GtkWidget   *menu,
                                const gchar *str,
-                               McPresence   state)
+                               TpConnectionPresenceType state)
 {
        GtkWidget   *item;
        GtkWidget   *image;
@@ -906,6 +1075,7 @@ presence_chooser_menu_add_item (GtkWidget   *menu,
        gtk_widget_show (image);
 
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+       gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
        gtk_widget_show (item);
 
        g_object_set_data_full (G_OBJECT (item),
@@ -921,7 +1091,7 @@ static void
 presence_chooser_noncustom_activate_cb (GtkWidget *item,
                                        gpointer   user_data)
 {
-       McPresence   state;
+       TpConnectionPresenceType state;
        const gchar *status;
 
        status = g_object_get_data (G_OBJECT (item), "status");
@@ -931,7 +1101,7 @@ presence_chooser_noncustom_activate_cb (GtkWidget *item,
 }
 
 static void
-presence_chooser_set_state (McPresence   state,
+presence_chooser_set_state (TpConnectionPresenceType state,
                            const gchar *status)
 {
        EmpathyIdle *idle;
@@ -945,225 +1115,9 @@ static void
 presence_chooser_custom_activate_cb (GtkWidget *item,
                                     gpointer   user_data)
 {
-       presence_chooser_dialog_show (NULL);
-}
+       GtkWidget *dialog;
 
-static McPresence
-presence_chooser_dialog_get_selected (CustomMessageDialog *dialog)
-{
-       GtkTreeModel *model;
-       GtkTreeIter   iter;
-       McPresence    presence = LAST_MC_PRESENCE;
-
-       model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->combobox_status));
-       if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->combobox_status), &iter)) {
-               gtk_tree_model_get (model, &iter,
-                                   COL_PRESENCE, &presence,
-                                   -1);
-       }
-
-       return presence;
+       dialog = empathy_status_preset_dialog_new (NULL);
+       gtk_dialog_run (GTK_DIALOG (dialog));
+       gtk_widget_destroy (dialog);
 }
-
-static void
-presence_chooser_dialog_status_changed_cb (GtkWidget           *widget,
-                                          CustomMessageDialog *dialog)
-{
-       GtkListStore *store;
-       GtkTreeIter   iter;
-       McPresence    presence = LAST_MC_PRESENCE;
-       GList        *messages, *l;
-
-       presence = presence_chooser_dialog_get_selected (dialog);
-
-       store = gtk_list_store_new (1, G_TYPE_STRING);
-       messages = empathy_status_presets_get (presence, -1);
-       for (l = messages; l; l = l->next) {
-               gtk_list_store_append (store, &iter);
-               gtk_list_store_set (store, &iter, 0, l->data, -1);
-       }
-
-       gtk_entry_set_text (GTK_ENTRY (dialog->entry_message),
-                           messages ? messages->data : "");
-
-       g_list_free (messages);
-
-       gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->comboboxentry_message),
-                                GTK_TREE_MODEL (store));
-
-       g_object_unref (store);
-}
-
-static void
-presence_chooser_dialog_message_changed_cb (GtkWidget           *widget,
-                                           CustomMessageDialog *dialog)
-{
-       McPresence   presence;
-       GList       *messages, *l;
-       const gchar *text;
-       gboolean     found = FALSE;
-
-       presence = presence_chooser_dialog_get_selected (dialog);
-       text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message));
-
-       messages = empathy_status_presets_get (presence, -1);
-       for (l = messages; l; l = l->next) {
-               if (!tp_strdiff (text, l->data)) {
-                       found = TRUE;
-                       break;
-               }
-       }
-       g_list_free (messages);
-
-       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_save),
-                                     found);
-}
-
-static void
-presence_chooser_dialog_save_toggled_cb (GtkWidget           *widget,
-                                        CustomMessageDialog *dialog)
-{
-       gboolean     active;
-       McPresence   state;
-       const gchar *text;
-
-       active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_save));
-       state = presence_chooser_dialog_get_selected (dialog);
-       text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message));
-
-       if (active) {
-               empathy_status_presets_set_last (state, text);
-       }
-       else {
-               empathy_status_presets_remove (state, text);
-       }
-}
-
-static void
-presence_chooser_dialog_setup (CustomMessageDialog *dialog)
-{
-       GtkListStore    *store;
-       GtkCellRenderer *renderer;
-       GtkTreeIter      iter;
-       guint            i;
-
-       store = gtk_list_store_new (COL_COUNT,
-                                   G_TYPE_STRING,     /* Icon name */
-                                   G_TYPE_STRING,     /* Label     */
-                                   MC_TYPE_PRESENCE); /* Presence   */
-       gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->combobox_status),
-                                GTK_TREE_MODEL (store));
-
-       renderer = gtk_cell_renderer_pixbuf_new ();
-       gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, FALSE);
-       gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer,
-                                       "icon-name", COL_ICON,
-                                       NULL);
-       g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
-
-       renderer = gtk_cell_renderer_text_new ();
-       gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, TRUE);
-       gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer,
-                                       "text", COL_LABEL,
-                                       NULL);
-
-       for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
-               if (!states[i+1]) {
-                       continue;
-               }
-
-               gtk_list_store_append (store, &iter);
-               gtk_list_store_set (store, &iter,
-                                   COL_ICON, empathy_icon_name_for_presence (states[i]),
-                                   COL_LABEL, empathy_presence_get_default_message (states[i]),
-                                   COL_PRESENCE, states[i],
-                                   -1);
-       }
-
-       gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_status), 0);
-}
-
-static void
-presence_chooser_dialog_response_cb (GtkWidget           *widget,
-                                    gint                 response,
-                                    CustomMessageDialog *dialog)
-{
-       if (response == GTK_RESPONSE_APPLY) {
-               McPresence   state;
-               const gchar *text;
-
-               state = presence_chooser_dialog_get_selected (dialog);
-               text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message));
-
-               presence_chooser_set_state (state, text);
-       }
-
-       gtk_widget_destroy (widget);
-}
-
-static void
-presence_chooser_dialog_destroy_cb (GtkWidget           *widget,
-                                   CustomMessageDialog *dialog)
-{
-
-       g_free (dialog);
-       message_dialog = NULL;
-}
-
-static void
-presence_chooser_dialog_show (GtkWindow *parent)
-{
-       GladeXML *glade;
-       gchar    *filename;
-
-       if (message_dialog) {
-               gtk_window_present (GTK_WINDOW (message_dialog->dialog));
-               return;
-       }
-
-       message_dialog = g_new0 (CustomMessageDialog, 1);
-
-       filename = empathy_file_lookup ("empathy-presence-chooser.glade",
-                                       "libempathy-gtk");
-       glade = empathy_glade_get_file (filename,
-                                      "custom_message_dialog",
-                                      NULL,
-                                      "custom_message_dialog", &message_dialog->dialog,
-                                      "checkbutton_save", &message_dialog->checkbutton_save,
-                                      "comboboxentry_message", &message_dialog->comboboxentry_message,
-                                      "combobox_status", &message_dialog->combobox_status,
-                                      NULL);
-       g_free (filename);
-
-       empathy_glade_connect (glade,
-                              message_dialog,
-                              "custom_message_dialog", "destroy", presence_chooser_dialog_destroy_cb,
-                              "custom_message_dialog", "response", presence_chooser_dialog_response_cb,
-                              "combobox_status", "changed", presence_chooser_dialog_status_changed_cb,
-                              "checkbutton_save", "toggled", presence_chooser_dialog_save_toggled_cb,
-                              NULL);
-
-       g_object_unref (glade);
-
-       /* Setup the message combobox */
-       message_dialog->entry_message = GTK_BIN (message_dialog->comboboxentry_message)->child;
-       gtk_entry_set_activates_default (GTK_ENTRY (message_dialog->entry_message), TRUE);
-       gtk_entry_set_width_chars (GTK_ENTRY (message_dialog->entry_message), 25);
-       g_signal_connect (message_dialog->entry_message, "changed",
-                         G_CALLBACK (presence_chooser_dialog_message_changed_cb),
-                         message_dialog);
-
-       presence_chooser_dialog_setup (message_dialog);
-
-       gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (message_dialog->comboboxentry_message), 0);
-
-       if (parent)
-       {
-               gtk_window_set_transient_for (
-                               GTK_WINDOW (message_dialog->dialog),
-                               parent);
-       }
-
-       gtk_widget_show_all (message_dialog->dialog);
-}
-