/soc/2015/igor.gajowiak/chatlog: 06fab92fb09d: Added sorting bud...

Igor Gajowiak igor.gajowiak at gmail.com
Sun Aug 16 06:05:39 EDT 2015


Changeset: 06fab92fb09d67abf97d20e4806b50dd728d36e3
Author:	 Igor Gajowiak <igor.gajowiak at gmail.com>
Date:	 2015-08-16 12:05 +0200
Branch:	 default
URL: https://hg.pidgin.im/soc/2015/igor.gajowiak/chatlog/rev/06fab92fb09d

Description:

Added sorting buddies by their name in the log.

diffstat:

 pidgin/gtkgenericlog.c |  28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diffs (43 lines):

diff --git a/pidgin/gtkgenericlog.c b/pidgin/gtkgenericlog.c
--- a/pidgin/gtkgenericlog.c
+++ b/pidgin/gtkgenericlog.c
@@ -717,12 +717,38 @@ append_contact(GtkTreeStore *store, GHas
 		BLIST_TREE_STORE_COL_CONTACT, contact, -1);
 }
 
+static gint
+blist_tree_store_cmp_func(GtkTreeModel *model, GtkTreeIter *lhs,
+	GtkTreeIter *rhs, gpointer unused)
+{
+	gint ret = 0;
+	gchar *name1, *name2;
+
+	gtk_tree_model_get(model, lhs, BLIST_TREE_STORE_COL_NAME, &name1, -1);
+	gtk_tree_model_get(model, rhs, BLIST_TREE_STORE_COL_NAME, &name2, -1);
+
+	ret = g_utf8_collate(name1, name2);
+
+	g_free(name1);
+	g_free(name2);
+
+	return ret;
+}
+
 static GtkTreeStore *
 create_buddylist_store(void)
 {
 	// Stores (group_name, NULL) or (contact_name, contact)
-	return gtk_tree_store_new(BLIST_TREE_STORE_COLUMNS,
+	GtkTreeStore *store = gtk_tree_store_new(BLIST_TREE_STORE_COLUMNS,
 		G_TYPE_STRING, G_TYPE_OBJECT);
+
+	GtkTreeSortable *sortable = GTK_TREE_SORTABLE(store);
+	gtk_tree_sortable_set_sort_func(sortable, BLIST_TREE_STORE_COL_NAME,
+		blist_tree_store_cmp_func, NULL, NULL);
+	gtk_tree_sortable_set_sort_column_id(sortable, BLIST_TREE_STORE_COL_NAME,
+		GTK_SORT_ASCENDING);
+
+	return store;
 }
 
 static void



More information about the Commits mailing list