~do-win/do/test-paths

« back to all changes in this revision

Viewing changes to Do/src/Do.UI/ColorConfigurationWidget.cs

  • Committer: Hardeep S
  • Date: 2009-06-23 05:57:47 UTC
  • Revision ID: ootz0rz@gmail.com-20090623055747-3srobsuq3q8wbn81
initial adding of Do core stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ColorConfigurationWidget.cs
 
2
// 
 
3
// Copyright (C) 2008 GNOME Do
 
4
//
 
5
// This program is free software: you can redistribute it and/or modify
 
6
// it under the terms of the GNU General Public License as published by
 
7
// the Free Software Foundation, either version 3 of the License, or
 
8
// (at your option) any later version.
 
9
//
 
10
// This program is distributed in the hope that it will be useful,
 
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
// GNU General Public License for more details.
 
14
//
 
15
// You should have received a copy of the GNU General Public License
 
16
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
//
 
18
 
 
19
using System;
 
20
using System.Linq;
 
21
using System.Collections.Generic;
 
22
 
 
23
using Mono.Unix;
 
24
 
 
25
using Do.Universe;
 
26
using Do.Platform;
 
27
using Do.Platform.Linux;
 
28
using Do.Interface;
 
29
using Do.Interface.CairoUtils;
 
30
using Do.Interface.AnimationBase;
 
31
 
 
32
namespace Do.UI
 
33
{
 
34
        public partial class ColorConfigurationWidget : Gtk.Bin, IConfigurable
 
35
        {
 
36
                List<string> themes;
 
37
 
 
38
                //TODO Make this an automatic property once mono 1.9 support is dropped
 
39
                List<string> Themes { 
 
40
                        get { return themes; }
 
41
                        set { themes = value; }
 
42
                }
 
43
 
 
44
                public ColorConfigurationWidget ()
 
45
                {
 
46
                        Build ();
 
47
                        AppPaintable = true;
 
48
                        Themes = new List<string> ();
 
49
                        Interface.Util.Appearance.SetColormap (this);
 
50
                        
 
51
                        foreach (InterfaceDescription theme in InterfaceManager.GetInterfaceDescriptions ()) {
 
52
                                theme_combo.AppendText (theme.Name);
 
53
                                Themes.Add (theme.Name);
 
54
                        }
 
55
 
 
56
                        if (!Screen.IsComposited) {
 
57
                                composite_warning_widget.Visible = true;
 
58
                                theme_combo.Sensitive = false;
 
59
                        }
 
60
                                
 
61
                        // Setup theme combo
 
62
                        theme_combo.Active = Math.Max (0, Themes.IndexOf (Do.Preferences.Theme));
 
63
                        pin_check.Active = Do.Preferences.AlwaysShowResults;
 
64
                        
 
65
                        theme_configuration_container.ShowAll ();
 
66
                }
 
67
                
 
68
                public Gtk.Bin GetConfiguration ()
 
69
                {
 
70
                        return this;
 
71
                }
 
72
 
 
73
                protected virtual void OnPinCheckClicked (object sender, System.EventArgs e)
 
74
                {
 
75
                        Do.Preferences.AlwaysShowResults = pin_check.Active;
 
76
                }
 
77
 
 
78
                protected virtual void OnThemeComboChanged (object sender, System.EventArgs e)
 
79
                {
 
80
                        Do.Preferences.Theme = Themes[theme_combo.Active];
 
81
                        SetupConfigurationWidget ();
 
82
                }
 
83
                
 
84
                void SetupConfigurationWidget ()
 
85
                {
 
86
                        if (theme_configuration_container.Child != null)
 
87
                                        theme_configuration_container.Remove (theme_configuration_container.Child);
 
88
                        
 
89
                        if (Do.Controller.Window is IConfigurable) {
 
90
                                IConfigurable window = Do.Controller.Window as IConfigurable;
 
91
                                Gtk.Bin bin = window.GetConfiguration ();
 
92
                                theme_configuration_container.Add (bin);
 
93
                        }
 
94
                        theme_configuration_container.ShowAll ();
 
95
                }
 
96
 
 
97
                protected virtual void OnCompositeWarningInfoBtnClicked (object sender, System.EventArgs e)
 
98
                {
 
99
                }
 
100
                
 
101
                public new string Name {
 
102
                        get { return Catalog.GetString ("Appearance"); }
 
103
                }
 
104
 
 
105
                public string Description {
 
106
                        get { return ""; }
 
107
                }
 
108
                
 
109
                public string Icon {
 
110
                        get { return ""; }
 
111
                }
 
112
 
 
113
                public override void Dispose ()
 
114
                {
 
115
                        if (theme_configuration_container.Child != null)
 
116
                                theme_configuration_container.Child.Dispose ();
 
117
                        base.Dispose ();
 
118
                }
 
119
        }
 
120
}