diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2010-02-12 21:34:59 +0800 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2010-02-12 21:43:58 +0800 |
commit | 4dd044b3c28320a935bfe0ead8fd1ef196587aac (patch) | |
tree | 886437479b28b8bddffd32d4e51ca2a04a42096c /libempathy-gtk | |
parent | f390cc946b33d2a22a2c47ec0f9b7470f254853e (diff) | |
download | gsoc2013-empathy-4dd044b3c28320a935bfe0ead8fd1ef196587aac.tar gsoc2013-empathy-4dd044b3c28320a935bfe0ead8fd1ef196587aac.tar.gz gsoc2013-empathy-4dd044b3c28320a935bfe0ead8fd1ef196587aac.tar.bz2 gsoc2013-empathy-4dd044b3c28320a935bfe0ead8fd1ef196587aac.tar.lz gsoc2013-empathy-4dd044b3c28320a935bfe0ead8fd1ef196587aac.tar.xz gsoc2013-empathy-4dd044b3c28320a935bfe0ead8fd1ef196587aac.tar.zst gsoc2013-empathy-4dd044b3c28320a935bfe0ead8fd1ef196587aac.zip |
Ensure "All" is at the top of account selector.
Fixes: #609737
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-account-chooser.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c index 1b5ddeb19..4e3b63b4c 100644 --- a/libempathy-gtk/empathy-account-chooser.c +++ b/libempathy-gtk/empathy-account-chooser.c @@ -73,10 +73,21 @@ typedef struct { gboolean set; } SetAccountData; +/* Distinguishes between store entries which are actually accounts, and special + * items like the "All" entry and the separator below it, so they can be sorted + * correctly. Higher-numbered entries will sort earlier. + */ +typedef enum { + ROW_ACCOUNT = 0, + ROW_SEPARATOR, + ROW_ALL +} RowType; + enum { COL_ACCOUNT_IMAGE, COL_ACCOUNT_TEXT, COL_ACCOUNT_ENABLED, /* Usually tied to connected state */ + COL_ACCOUNT_ROW_TYPE, COL_ACCOUNT_POINTER, COL_ACCOUNT_COUNT }; @@ -443,6 +454,7 @@ empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser, COL_ACCOUNT_TEXT, NULL, COL_ACCOUNT_ENABLED, TRUE, COL_ACCOUNT_POINTER, NULL, + COL_ACCOUNT_ROW_TYPE, ROW_SEPARATOR, -1); gtk_list_store_prepend (store, &iter); @@ -450,6 +462,7 @@ empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser, COL_ACCOUNT_TEXT, _("All"), COL_ACCOUNT_ENABLED, TRUE, COL_ACCOUNT_POINTER, NULL, + COL_ACCOUNT_ROW_TYPE, ROW_ALL, -1); } else { if (gtk_tree_model_get_iter_first (model, &iter)) { @@ -509,12 +522,25 @@ account_cmp (GtkTreeModel *model, GtkTreeIter *b, gpointer user_data) { + RowType a_type, b_type; gboolean a_enabled, b_enabled; gchar *a_text, *b_text; gint result; - gtk_tree_model_get (model, a, COL_ACCOUNT_ENABLED, &a_enabled, -1); - gtk_tree_model_get (model, b, COL_ACCOUNT_ENABLED, &b_enabled, -1); + gtk_tree_model_get (model, a, + COL_ACCOUNT_ENABLED, &a_enabled, + COL_ACCOUNT_ROW_TYPE, &a_type, + -1); + gtk_tree_model_get (model, b, + COL_ACCOUNT_ENABLED, &b_enabled, + COL_ACCOUNT_ROW_TYPE, &b_type, + -1); + + /* This assumes that we have at most one of each special row type. */ + if (a_type != b_type) { + /* Display higher-numbered special row types first. */ + return (b_type - a_type); + } /* Enabled accounts are displayed first */ if (a_enabled != b_enabled) @@ -557,6 +583,7 @@ account_chooser_setup (EmpathyAccountChooser *chooser) G_TYPE_STRING, /* Image */ G_TYPE_STRING, /* Name */ G_TYPE_BOOLEAN, /* Enabled */ + G_TYPE_UINT, /* Row type */ TP_TYPE_ACCOUNT); gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store), @@ -758,21 +785,10 @@ account_chooser_separator_func (GtkTreeModel *model, GtkTreeIter *iter, EmpathyAccountChooser *chooser) { - EmpathyAccountChooserPriv *priv; - gchar *text; - gboolean is_separator; - - priv = GET_PRIV (chooser); - - if (!priv->has_all_option) { - return FALSE; - } - - gtk_tree_model_get (model, iter, COL_ACCOUNT_TEXT, &text, -1); - is_separator = text == NULL; - g_free (text); + RowType row_type; - return is_separator; + gtk_tree_model_get (model, iter, COL_ACCOUNT_ROW_TYPE, &row_type, -1); + return (row_type == ROW_SEPARATOR); } static gboolean |