[gnome-builder] plugins/editorui: sort languages by section



commit 2c7ae134c2edf75a0130dece84af021cf26fc902
Author: Christian Hergert <chergert redhat com>
Date:   Tue Aug 16 22:03:47 2022 -0700

    plugins/editorui: sort languages by section
    
    We probably still want to add a section header for these at some point.

 src/plugins/editorui/gbp-editorui-tweaks-addin.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/plugins/editorui/gbp-editorui-tweaks-addin.c 
b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
index 60cd12217..2c759239a 100644
--- a/src/plugins/editorui/gbp-editorui-tweaks-addin.c
+++ b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
@@ -163,6 +163,18 @@ create_spaces_style (IdeTweaks       *tweaks,
   return GTK_WIDGET (list_box);
 }
 
+static int
+compare_by_section (gconstpointer a,
+                    gconstpointer b,
+                    gpointer      user_data)
+{
+  GtkSourceLanguage *l_a = (GtkSourceLanguage *)a;
+  GtkSourceLanguage *l_b = (GtkSourceLanguage *)b;
+
+  return g_strcmp0 (gtk_source_language_get_section (l_a),
+                    gtk_source_language_get_section (l_b));
+}
+
 static void
 gbp_editorui_tweaks_addin_load (IdeTweaksAddin *addin,
                                 IdeTweaks      *tweaks)
@@ -186,6 +198,8 @@ gbp_editorui_tweaks_addin_load (IdeTweaksAddin *addin,
         g_list_store_append (store, l);
     }
 
+  g_list_store_sort (store, compare_by_section, NULL);
+
   ide_tweaks_addin_set_resource_paths (IDE_TWEAKS_ADDIN (self),
                                        IDE_STRV_INIT ("/plugins/editorui/tweaks.ui",
                                                       "/plugins/editorui/tweaks-language.ui"));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]