Use g_utf8_collate() to sort langs

This commit is contained in:
Yevgen Muntyan 2006-09-07 02:04:31 -05:00
parent 2ce565eda7
commit 1230d9b758
2 changed files with 15 additions and 11 deletions

View File

@ -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 * static GtkTreeModel *
create_lang_model (MooEditor *editor) create_lang_model (MooEditor *editor)
{ {
@ -349,7 +361,7 @@ create_lang_model (MooEditor *editor)
char *ext, *mime; char *ext, *mime;
mgr = moo_editor_get_lang_mgr (editor); 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); sections = moo_lang_mgr_get_sections (mgr);
store = gtk_tree_store_new (6, G_TYPE_STRING, G_TYPE_STRING, MOO_TYPE_LANG, store = gtk_tree_store_new (6, G_TYPE_STRING, G_TYPE_STRING, MOO_TYPE_LANG,

View File

@ -2629,15 +2629,7 @@ static int
cmp_langs (MooLang *lang1, cmp_langs (MooLang *lang1,
MooLang *lang2) MooLang *lang2)
{ {
int result; return g_utf8_collate (_moo_lang_display_name (lang1),
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)); _moo_lang_display_name (lang2));
} }