diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-12-10 01:28:43 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-12-10 01:28:43 +0800 |
commit | 194a6d0d636eb62add7719edc48b60906081a3ba (patch) | |
tree | 8c5b9d41a5327e95da9178c8bb2812dc6c577c69 | |
parent | 0ff7162d2f3b141a89d551663593c804f529945d (diff) | |
parent | 7190ca926a151a3fa1fec7ec9faf6a490a378b8e (diff) | |
download | gsoc2013-empathy-194a6d0d636eb62add7719edc48b60906081a3ba.tar gsoc2013-empathy-194a6d0d636eb62add7719edc48b60906081a3ba.tar.gz gsoc2013-empathy-194a6d0d636eb62add7719edc48b60906081a3ba.tar.bz2 gsoc2013-empathy-194a6d0d636eb62add7719edc48b60906081a3ba.tar.lz gsoc2013-empathy-194a6d0d636eb62add7719edc48b60906081a3ba.tar.xz gsoc2013-empathy-194a6d0d636eb62add7719edc48b60906081a3ba.tar.zst gsoc2013-empathy-194a6d0d636eb62add7719edc48b60906081a3ba.zip |
Merge branch 'enabled-first-604166'
-rw-r--r-- | libempathy-gtk/empathy-account-chooser.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c index 61d63b32c..bd46efc16 100644 --- a/libempathy-gtk/empathy-account-chooser.c +++ b/libempathy-gtk/empathy-account-chooser.c @@ -503,6 +503,41 @@ account_manager_prepared_cb (GObject *source_object, g_signal_emit (chooser, signals[READY], 0); } +static gint +account_cmp (GtkTreeModel *model, + GtkTreeIter *a, + GtkTreeIter *b, + gpointer user_data) +{ + 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); + + /* Enabled accounts are displayed first */ + if (a_enabled != b_enabled) + return a_enabled ? -1: 1; + + gtk_tree_model_get (model, a, COL_ACCOUNT_TEXT, &a_text, -1); + gtk_tree_model_get (model, b, COL_ACCOUNT_TEXT, &b_text, -1); + + if (a_text == b_text) + result = 0; + else if (a_text == NULL) + result = 1; + else if (b_text == NULL) + result = -1; + else + result = g_ascii_strcasecmp (a_text, b_text); + + g_free (a_text); + g_free (b_text); + + return result; +} + static void account_chooser_setup (EmpathyAccountChooser *chooser) { @@ -524,6 +559,11 @@ account_chooser_setup (EmpathyAccountChooser *chooser) G_TYPE_BOOLEAN, /* Enabled */ TP_TYPE_ACCOUNT); + gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store), + account_cmp, chooser, NULL); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), + GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING); + gtk_combo_box_set_model (combobox, GTK_TREE_MODEL (store)); renderer = gtk_cell_renderer_pixbuf_new (); |