[gtk+] inspector: Sort themes in the various theme combos



commit a45b1d1e3c414d2b2735c9ed096b6abe1b45a7ea
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jan 7 19:49:17 2016 -0500

    inspector: Sort themes in the various theme combos
    
    It is nicer if the themes show up in a predictable order,
    so sort them alphabetically.

 gtk/inspector/visual.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index 671e2ed..9f26224 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -240,6 +240,7 @@ init_theme (GtkInspectorVisual *vis)
   GHashTable *t;
   GHashTableIter iter;
   gchar *theme, *path;
+  GList *list, *l;
 
   t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
   /* Builtin themes */
@@ -260,9 +261,18 @@ init_theme (GtkInspectorVisual *vis)
   fill_gtk (path, t);
   g_free (path);
 
+  list = NULL;
   g_hash_table_iter_init (&iter, t);
   while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL))
-    gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (vis->priv->theme_combo), theme, theme);
+    list = g_list_insert_sorted (list, theme, (GCompareFunc)strcmp);
+
+  for (l = list; l; l = l->next)
+    {
+      theme = l->data;
+      gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (vis->priv->theme_combo), theme, theme);
+    }
+
+  g_list_free (list);
   g_hash_table_destroy (t);
 
   g_object_bind_property (gtk_settings_get_default (), "gtk-theme-name",
@@ -322,6 +332,7 @@ init_icons (GtkInspectorVisual *vis)
   GHashTable *t;
   GHashTableIter iter;
   gchar *theme, *path;
+  GList *list, *l;
 
   t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
@@ -333,12 +344,19 @@ init_icons (GtkInspectorVisual *vis)
   fill_icons (path, t);
   g_free (path);
 
+  list = NULL;
   g_hash_table_iter_init (&iter, t);
   while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL))
+    list = g_list_insert_sorted (list, theme, (GCompareFunc)strcmp);
+
+  for (l = list; l; l = l->next)
     {
+      theme = l->data;
       gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (vis->priv->icon_combo), theme, theme);
     }
+
   g_hash_table_destroy (t);
+  g_list_free (list);
 
   g_object_bind_property (gtk_settings_get_default (), "gtk-icon-theme-name",
                           vis->priv->icon_combo, "active-id",
@@ -374,6 +392,7 @@ init_cursors (GtkInspectorVisual *vis)
   GHashTable *t;
   GHashTableIter iter;
   gchar *theme, *path;
+  GList *list, *l;
 
   t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
@@ -385,12 +404,19 @@ init_cursors (GtkInspectorVisual *vis)
   fill_cursors (path, t);
   g_free (path);
 
+  list = NULL;
   g_hash_table_iter_init (&iter, t);
   while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL))
+    list = g_list_insert_sorted (list, theme, (GCompareFunc)strcmp);
+
+  for (l = list; l; l = l->next)
     {
+      theme = l->data;
       gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (vis->priv->cursor_combo), theme, theme);
     }
+
   g_hash_table_destroy (t);
+  g_list_free (list);
 
   g_object_bind_property (gtk_settings_get_default (), "gtk-cursor-theme-name",
                           vis->priv->cursor_combo, "active-id",


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