[gucharmap/gnome-2-32] Use locale-aware string comparision to sort the chapters
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gucharmap/gnome-2-32] Use locale-aware string comparision to sort the chapters
- Date: Mon, 11 Oct 2010 12:00:07 +0000 (UTC)
commit 19798ffae337203bc790d756aedd7d6c9b5e4422
Author: Christian Persch <chpe gnome org>
Date: Mon Oct 11 13:12:00 2010 +0200
Use locale-aware string comparision to sort the chapters
gucharmap/gucharmap-block-chapters-model.c | 2 +-
gucharmap/gucharmap-script-chapters-model.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/gucharmap/gucharmap-block-chapters-model.c b/gucharmap/gucharmap-block-chapters-model.c
index 65ce885..05cbb23 100644
--- a/gucharmap/gucharmap-block-chapters-model.c
+++ b/gucharmap/gucharmap-block-chapters-model.c
@@ -56,7 +56,7 @@ compare_iters (GtkTreeModel *model,
gtk_tree_model_get (model, iter_a, BLOCK_CHAPTERS_MODEL_LABEL, &label_a, -1);
gtk_tree_model_get (model, iter_b, BLOCK_CHAPTERS_MODEL_LABEL, &label_b, -1);
- ret = strcmp (label_a, label_b);
+ ret = g_utf8_collate (label_a, label_b);
g_free (label_a);
g_free (label_b);
diff --git a/gucharmap/gucharmap-script-chapters-model.c b/gucharmap/gucharmap-script-chapters-model.c
index da6a2ab..30f8c4b 100644
--- a/gucharmap/gucharmap-script-chapters-model.c
+++ b/gucharmap/gucharmap-script-chapters-model.c
@@ -27,6 +27,26 @@
#include "gucharmap.h"
#include "gucharmap-private.h"
+static int
+compare_iters (GtkTreeModel *model,
+ GtkTreeIter *iter_a,
+ GtkTreeIter *iter_b,
+ gpointer user_data)
+{
+ char *label_a, *label_b;
+ int ret;
+
+ gtk_tree_model_get (model, iter_a, GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL, &label_a, -1);
+ gtk_tree_model_get (model, iter_b, GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL, &label_b, -1);
+
+ ret = g_utf8_collate (label_a, label_b);
+
+ g_free (label_a);
+ g_free (label_b);
+
+ return ret;
+}
+
static void
gucharmap_script_chapters_model_init (GucharmapScriptChaptersModel *model)
{
@@ -51,6 +71,11 @@ gucharmap_script_chapters_model_init (GucharmapScriptChaptersModel *model)
-1);
}
g_free (unicode_scripts);
+
+ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model),
+ GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL,
+ (GtkTreeIterCompareFunc) compare_iters,
+ NULL, NULL);
}
static GucharmapCodepointList *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]