aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-profile-chooser.c
diff options
context:
space:
mode:
authorxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2007-07-28 00:18:43 +0800
committerxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2007-07-28 00:18:43 +0800
commit4cbde51c762cc732c8cfcd81b878ab54535fb02c (patch)
treebae4eed323504d83e0e2ded6ec8fac2965ceb000 /libempathy-gtk/empathy-profile-chooser.c
parent7be1b890124542b7a3f0ba4b6e33ea6d2144190a (diff)
downloadgsoc2013-empathy-4cbde51c762cc732c8cfcd81b878ab54535fb02c.tar
gsoc2013-empathy-4cbde51c762cc732c8cfcd81b878ab54535fb02c.tar.gz
gsoc2013-empathy-4cbde51c762cc732c8cfcd81b878ab54535fb02c.tar.bz2
gsoc2013-empathy-4cbde51c762cc732c8cfcd81b878ab54535fb02c.tar.lz
gsoc2013-empathy-4cbde51c762cc732c8cfcd81b878ab54535fb02c.tar.xz
gsoc2013-empathy-4cbde51c762cc732c8cfcd81b878ab54535fb02c.tar.zst
gsoc2013-empathy-4cbde51c762cc732c8cfcd81b878ab54535fb02c.zip
2007-07-27 Xavier Claessens <xclaesse@gmail.com>
* libempathy-gtk/empathy-profile-chooser.c: Sort profiles to have free protocols first. Fixes bug #460605. git-svn-id: svn+ssh://svn.gnome.org/svn/empathy/trunk@206 4ee84921-47dd-4033-b63a-18d7a039a3e4
Diffstat (limited to 'libempathy-gtk/empathy-profile-chooser.c')
-rw-r--r--libempathy-gtk/empathy-profile-chooser.c62
1 files changed, 59 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-profile-chooser.c b/libempathy-gtk/empathy-profile-chooser.c
index 1885c2fb2..a3cc9a32d 100644
--- a/libempathy-gtk/empathy-profile-chooser.c
+++ b/libempathy-gtk/empathy-profile-chooser.c
@@ -25,9 +25,8 @@
#include <gtk/gtk.h>
#include <libmissioncontrol/mc-profile.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
-
#include "empathy-profile-chooser.h"
+#include "empathy-ui-utils.h"
enum {
COL_ICON,
@@ -53,6 +52,53 @@ empathy_profile_chooser_get_selected (GtkWidget *widget)
return profile;
}
+static gint
+profile_chooser_sort_protocol_value (const gchar *protocol_name)
+{
+ if (strcmp (protocol_name, "jabber") == 0) {
+ return 0;
+ }
+ else if (strcmp (protocol_name, "salut") == 0) {
+ return 1;
+ }
+
+ return 2;
+}
+
+static gint
+profile_chooser_sort_func (GtkTreeModel *model,
+ GtkTreeIter *iter_a,
+ GtkTreeIter *iter_b,
+ gpointer user_data)
+{
+ McProfile *profile_a;
+ McProfile *profile_b;
+ const gchar *proto_a;
+ const gchar *proto_b;
+ gint cmp;
+
+ gtk_tree_model_get (model, iter_a,
+ COL_PROFILE, &profile_a,
+ -1);
+ gtk_tree_model_get (model, iter_b,
+ COL_PROFILE, &profile_b,
+ -1);
+
+ proto_a = mc_profile_get_protocol_name (profile_a);
+ proto_b = mc_profile_get_protocol_name (profile_b);
+ cmp = profile_chooser_sort_protocol_value (proto_a);
+ cmp -= profile_chooser_sort_protocol_value (proto_b);
+ if (cmp == 0) {
+ cmp = strcmp (mc_profile_get_display_name (profile_a),
+ mc_profile_get_display_name (profile_b));
+ }
+
+ g_object_unref (profile_a);
+ g_object_unref (profile_b);
+
+ return cmp;
+}
+
GtkWidget *
empathy_profile_chooser_new (void)
{
@@ -83,6 +129,15 @@ empathy_profile_chooser_new (void)
"text", COL_LABEL,
NULL);
+ /* Set the profile sort function */
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ COL_PROFILE,
+ GTK_SORT_ASCENDING);
+ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
+ COL_PROFILE,
+ profile_chooser_sort_func,
+ NULL, NULL);
+
profiles = mc_profiles_list ();
for (l = profiles; l; l = l->next) {
McProfile *profile;
@@ -95,9 +150,10 @@ empathy_profile_chooser_new (void)
COL_LABEL, mc_profile_get_display_name (profile),
COL_PROFILE, profile,
-1);
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
}
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
+
mc_profiles_free_list (profiles);
g_object_unref (store);