diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2007-07-28 00:18:43 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2007-07-28 00:18:43 +0800 |
commit | 19eacf8730a0ae8abb9fb7db4696ff4d67d86c5d (patch) | |
tree | bae4eed323504d83e0e2ded6ec8fac2965ceb000 | |
parent | 8d2fed5419db02570826e964f4e48f57d81b2dab (diff) | |
download | gsoc2013-empathy-19eacf8730a0ae8abb9fb7db4696ff4d67d86c5d.tar gsoc2013-empathy-19eacf8730a0ae8abb9fb7db4696ff4d67d86c5d.tar.gz gsoc2013-empathy-19eacf8730a0ae8abb9fb7db4696ff4d67d86c5d.tar.bz2 gsoc2013-empathy-19eacf8730a0ae8abb9fb7db4696ff4d67d86c5d.tar.lz gsoc2013-empathy-19eacf8730a0ae8abb9fb7db4696ff4d67d86c5d.tar.xz gsoc2013-empathy-19eacf8730a0ae8abb9fb7db4696ff4d67d86c5d.tar.zst gsoc2013-empathy-19eacf8730a0ae8abb9fb7db4696ff4d67d86c5d.zip |
Sort profiles to have free protocols first. Fixes bug #460605.
2007-07-27 Xavier Claessens <xclaesse@gmail.com>
* libempathy-gtk/empathy-profile-chooser.c: Sort profiles to have
free protocols first. Fixes bug #460605.
svn path=/trunk/; revision=206
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | libempathy-gtk/empathy-profile-chooser.c | 62 |
2 files changed, 64 insertions, 3 deletions
@@ -1,5 +1,10 @@ 2007-07-27 Xavier Claessens <xclaesse@gmail.com> + * libempathy-gtk/empathy-profile-chooser.c: Sort profiles to have + free protocols first. Fixes bug #460605. + +2007-07-27 Xavier Claessens <xclaesse@gmail.com> + * libempathy/empathy-message.c: * libempathy/empathy-message.h: * libempathy/empathy-log-manager.c: Add message type in log files. 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); |