[gedit] Sort highlight modes by section and then by name
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Sort highlight modes by section and then by name
- Date: Fri, 4 Jun 2010 00:00:47 +0000 (UTC)
commit fbb8bda7c89e76490c1d58630f958bbc12663476
Author: Garrett Regier <alias301 gmail com>
Date: Thu Jun 3 13:08:27 2010 -0700
Sort highlight modes by section and then by name
gedit/gedit-language-manager.c | 9 ++++-----
gedit/gedit-window.c | 12 ++++++++++++
2 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gedit/gedit-language-manager.c b/gedit/gedit-language-manager.c
index 0292f21..145bf4b 100644
--- a/gedit/gedit-language-manager.c
+++ b/gedit/gedit-language-manager.c
@@ -49,12 +49,11 @@ gedit_get_language_manager (void)
}
static gint
-language_compare (gconstpointer a, gconstpointer b)
+language_compare (GtkSourceLanguage *a,
+ GtkSourceLanguage *b)
{
- GtkSourceLanguage *lang_a = (GtkSourceLanguage *)a;
- GtkSourceLanguage *lang_b = (GtkSourceLanguage *)b;
- const gchar *name_a = gtk_source_language_get_name (lang_a);
- const gchar *name_b = gtk_source_language_get_name (lang_b);
+ const gchar *name_a = gtk_source_language_get_name (a);
+ const gchar *name_b = gtk_source_language_get_name (b);
return g_utf8_collate (name_a, name_b);
}
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index d60473b..15b912c 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -1118,6 +1118,16 @@ create_language_menu_item (GtkSourceLanguage *lang,
g_free (escaped_section);
}
+static gint
+language_section_compare (GtkSourceLanguage *a,
+ GtkSourceLanguage *b)
+{
+ const gchar *section_a = gtk_source_language_get_section (a);
+ const gchar *section_b = gtk_source_language_get_section (b);
+
+ return g_utf8_collate (section_a, section_b);
+}
+
static void
create_languages_menu (GeditWindow *window)
{
@@ -1164,6 +1174,8 @@ create_languages_menu (GeditWindow *window)
gedit_get_language_manager (),
FALSE);
+ languages = g_slist_sort (languages, (GCompareFunc)language_section_compare);
+
for (l = languages, i = 0; l != NULL; l = l->next, ++i)
{
create_language_menu_item (l->data,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]