From 1230d9b7587d7b4cdbc1b9bd1b12bbd5aa6020e0 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Thu, 7 Sep 2006 02:04:31 -0500 Subject: [PATCH] Use g_utf8_collate() to sort langs --- moo/mooedit/mooeditprefspage.c | 14 +++++++++++++- moo/mooedit/mooeditwindow.c | 12 ++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/moo/mooedit/mooeditprefspage.c b/moo/mooedit/mooeditprefspage.c index 11d8d3b8..86d69b04 100644 --- a/moo/mooedit/mooeditprefspage.c +++ b/moo/mooedit/mooeditprefspage.c @@ -338,6 +338,18 @@ list_to_string (GSList *list, } +static int +lang_cmp (MooLang *lang1, + MooLang *lang2) +{ + const char *name1, *name2; + + name1 = _moo_lang_display_name (lang1); + name2 = _moo_lang_display_name (lang2); + + return g_utf8_collate (name1, name2); +} + static GtkTreeModel * create_lang_model (MooEditor *editor) { @@ -349,7 +361,7 @@ create_lang_model (MooEditor *editor) char *ext, *mime; mgr = moo_editor_get_lang_mgr (editor); - langs = moo_lang_mgr_get_available_langs (mgr); + langs = g_slist_sort (moo_lang_mgr_get_available_langs (mgr), (GCompareFunc) lang_cmp); sections = moo_lang_mgr_get_sections (mgr); store = gtk_tree_store_new (6, G_TYPE_STRING, G_TYPE_STRING, MOO_TYPE_LANG, diff --git a/moo/mooedit/mooeditwindow.c b/moo/mooedit/mooeditwindow.c index b1d1d1da..53e3107c 100644 --- a/moo/mooedit/mooeditwindow.c +++ b/moo/mooedit/mooeditwindow.c @@ -2629,16 +2629,8 @@ static int cmp_langs (MooLang *lang1, MooLang *lang2) { - int result; - - result = strcmp (_moo_lang_get_section (lang1), - _moo_lang_get_section (lang2)); - - if (result) - return result; - else - return strcmp (_moo_lang_display_name (lang1), - _moo_lang_display_name (lang2)); + return g_utf8_collate (_moo_lang_display_name (lang1), + _moo_lang_display_name (lang2)); }