[iagno] Sort the entries in the themes combobox alphabetically
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Sort the entries in the themes combobox alphabetically
- Date: Sat, 17 Aug 2013 16:27:42 +0000 (UTC)
commit 6a313373f753aa9229977de70d3196a8cd58f023
Author: John Cheetham <developer johncheetham com>
Date: Mon Jun 17 19:12:07 2013 +0100
Sort the entries in the themes combobox alphabetically
This is a fix for https://bugzilla.gnome.org/show_bug.cgi?id=697469
src/iagno.vala | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/src/iagno.vala b/src/iagno.vala
index 43d3977..2b21a11 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -563,6 +563,9 @@ public class Iagno : Gtk.Application
model = new Gtk.ListStore (2, typeof (string), typeof (string));
theme_combo.model = model;
Dir dir;
+ List<string> dirlist = new List<string> ();
+
+ /* get sorted list of filenames in the themes directory */
try
{
dir = Dir.open (Path.build_filename (DATA_DIRECTORY, "themes"));
@@ -571,24 +574,31 @@ public class Iagno : Gtk.Application
var filename = dir.read_name ();
if (filename == null)
break;
- model.append (out iter);
-
- /* Create label by replacing underscores with space and stripping extension */
- var label_text = filename;
- label_text = label_text.replace ("_", " ");
- var extension_index = label_text.last_index_of_char ('.');
- if (extension_index > 0)
- label_text = label_text.substring (0, extension_index);
-
- model.set (iter, 0, label_text, 1, filename);
- if (filename == settings.get_string ("tileset"))
- theme_combo.set_active_iter (iter);
+ dirlist.insert_sorted (filename, strcmp);
}
}
catch (FileError e)
{
warning ("Failed to load themes: %s", e.message);
}
+
+ foreach (string filename in dirlist)
+ {
+ model.append (out iter);
+
+ /* Create label by replacing underscores with space and stripping extension */
+ var label_text = filename;
+
+ label_text = label_text.replace ("_", " ");
+ var extension_index = label_text.last_index_of_char ('.');
+ if (extension_index > 0)
+ label_text = label_text.substring (0, extension_index);
+
+ model.set (iter, 0, label_text, 1, filename);
+ if (filename == settings.get_string ("tileset"))
+ theme_combo.set_active_iter (iter);
+ }
+
label.set_mnemonic_widget (theme_combo);
theme_combo.changed.connect (theme_changed_cb);
grid.attach (theme_combo, 1, 5, 1, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]