summaryrefslogtreecommitdiff
path: root/src/gui/themeList.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/themeList.vala')
-rw-r--r--src/gui/themeList.vala74
1 files changed, 36 insertions, 38 deletions
diff --git a/src/gui/themeList.vala b/src/gui/themeList.vala
index 7eadcdb..62e0721 100644
--- a/src/gui/themeList.vala
+++ b/src/gui/themeList.vala
@@ -28,6 +28,12 @@ class ThemeList : Gtk.TreeView {
/////////////////////////////////////////////////////////////////////
private Gtk.TreeIter active { private get; private set; }
+
+ /////////////////////////////////////////////////////////////////////
+ /// The positions in the data list store.
+ /////////////////////////////////////////////////////////////////////
+
+ private enum DataPos {ICON, NAME}
/////////////////////////////////////////////////////////////////////
/// C'tor, constructs the Widget.
@@ -36,58 +42,50 @@ class ThemeList : Gtk.TreeView {
public ThemeList() {
GLib.Object();
- var data = new Gtk.ListStore(2, typeof(bool), // selected
- typeof(string)); // description
- base.set_model(data);
- base.set_headers_visible(false);
- base.set_rules_hint(true);
- base.set_grid_lines(Gtk.TreeViewGridLines.NONE);
+ var data = new Gtk.ListStore(2, typeof(Gdk.Pixbuf),
+ typeof(string));
+ this.set_model(data);
+ this.set_headers_visible(true);
+ this.set_grid_lines(Gtk.TreeViewGridLines.NONE);
+ this.set_fixed_height_mode(true);
var main_column = new Gtk.TreeViewColumn();
- var check_render = new Gtk.CellRendererToggle();
- check_render.set_radio(true);
- check_render.set_activatable(true);
- main_column.pack_start(check_render, false);
-
- // switch the theme if the entry has been toggled
- check_render.toggled.connect((r, path) => {
- Gtk.TreeIter toggled;
- data.get_iter(out toggled, new Gtk.TreePath.from_string(path));
-
- if (toggled != this.active) {
- Timeout.add(10, () => {
- int index = int.parse(path);
- Config.global.theme = Config.global.themes[index];
- Config.global.theme.load();
- Config.global.theme.load_images();
- return false;
- });
-
- data.set(this.active, 0, false);
- data.set(toggled, 0, true);
-
- this.active = toggled;
- }
- });
+ main_column.title = _("Themes");
+ main_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED);
+ var icon_render = new Gtk.CellRendererPixbuf();
+ main_column.pack_start(icon_render, false);
var theme_render = new Gtk.CellRendererText();
main_column.pack_start(theme_render, true);
- base.append_column(main_column);
+ this.append_column(main_column);
+
+ main_column.add_attribute(icon_render, "pixbuf", DataPos.ICON);
+ main_column.add_attribute(theme_render, "markup", DataPos.NAME);
- main_column.add_attribute(check_render, "active", 0);
- main_column.add_attribute(theme_render, "markup", 1);
+ this.get_selection().changed.connect(() => {
+ Gtk.TreeIter active;
+ if (this.get_selection().get_selected(null, out active)) {
+ Timeout.add(10, () => {
+ int index = int.parse(data.get_path(active).to_string());
+ Config.global.theme = Config.global.themes[index];
+ Config.global.theme.load();
+ Config.global.theme.load_images();
+ return false;
+ });
+ }
+ });
// load all themes into the list
var themes = Config.global.themes;
foreach(var theme in themes) {
Gtk.TreeIter current;
data.append(out current);
- data.set(current, 0, theme == Config.global.theme);
- data.set(current, 1, "<b>" + theme.name + "</b>\n" + theme.description
- + " <small> - " + _("by") + " " + theme.author + "</small>");
+ data.set(current, DataPos.ICON, theme.preview_icon.to_pixbuf());
+ data.set(current, DataPos.NAME, "<b>"+theme.name+"</b><small> - "+theme.description+"\n"
+ +"<i>"+_("By")+" "+theme.author+"</i></small>");
if(theme == Config.global.theme)
- this.active = current;
+ get_selection().select_iter(current);
}
}
}