2
// Copyright (C) 2009 Robert Dyer
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
using System.Collections.Generic;
20
using System.Collections.ObjectModel;
28
using Docky.CairoHelper;
35
public class ClockThemeSelector : Gtk.Dialog
37
TreeStore labelTreeStore = new TreeStore (typeof (string));
38
TreeView labelTreeView = new TreeView ();
40
ClockDockItem DockItem { get; set; }
42
public ClockThemeSelector (ClockDockItem dockItem)
45
Title = Catalog.GetString ("Themes");
47
labelTreeView.Model = labelTreeStore;
48
labelTreeView.HeadersVisible = false;
49
labelTreeView.Selection.Changed += OnLabelSelectionChanged;
50
labelTreeView.AppendColumn (Catalog.GetString ("Theme"), new CellRendererText (), "text", 0);
52
ScrolledWindow win = new ScrolledWindow ();
53
win.Add (labelTreeView);
54
win.SetSizeRequest (200, 300);
58
AddButton ("Close", ResponseType.Close);
63
public void UpdateThemeList ()
65
List<string> themes = new List<string> ();
67
foreach (string path in DockItem.ThemeURIs)
68
if (Directory.Exists (path))
69
foreach (DirectoryInfo p in new DirectoryInfo (path).GetDirectories ())
72
labelTreeStore.Clear ();
76
int i = 0, selected = -1;
77
foreach (string p in themes.Distinct ()) {
78
if (p == DockItem.CurrentTheme)
80
labelTreeStore.AppendValues (p);
84
labelTreeView.Selection.SelectPath (new TreePath ("" + selected));
85
labelTreeView.ScrollToCell (new TreePath ("" + selected), null, false, 0, 0);
88
protected virtual void OnLabelSelectionChanged (object o, System.EventArgs args)
93
if (((TreeSelection)o).GetSelected (out model, out iter))
94
DockItem.SetTheme ((string) model.GetValue (iter, 0));
97
protected override void OnResponse (ResponseType response_id)