~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/IDEStyleOptionsPanel.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
namespace MonoDevelop.Ide.Gui.OptionPanels
42
42
{
43
 
        internal class IDEStyleOptionsPanel : OptionsPanel
 
43
        class IDEStyleOptionsPanel : OptionsPanel
44
44
        {
45
45
                IDEStyleOptionsPanelWidget widget;
46
46
 
57
57
        
58
58
        public partial class IDEStyleOptionsPanelWidget : Gtk.Bin
59
59
        {
60
 
                readonly Gtk.IconSize[] sizes = new Gtk.IconSize [] { Gtk.IconSize.Menu, Gtk.IconSize.SmallToolbar, Gtk.IconSize.LargeToolbar };
61
 
                                
 
60
                static Lazy<List<string>> themes = new Lazy<List<string>> (() => {
 
61
                        var searchDirs = new List<string> ();
 
62
 
 
63
                        string prefix = Environment.GetEnvironmentVariable ("MONO_INSTALL_PREFIX");
 
64
                        FilePath homeDir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
 
65
 
 
66
                        searchDirs.Add (homeDir.Combine (".themes"));
 
67
                        searchDirs.Add (Gtk.Rc.ThemeDir);
 
68
                        if (!string.IsNullOrEmpty (prefix))
 
69
                                searchDirs.Add (new FilePath (prefix).Combine ("share").Combine ("themes"));
 
70
                        
 
71
 
 
72
                        var themes = FindThemes (searchDirs).ToList ();
 
73
                        themes.Sort ();
 
74
                        return themes;
 
75
                });
 
76
 
 
77
                public static IList<string> InstalledThemes {
 
78
                        get {
 
79
                                return themes.Value;
 
80
                        }
 
81
                }
 
82
                
 
83
 
62
84
                public IDEStyleOptionsPanelWidget ()
63
85
                {
64
86
                        this.Build();
67
89
                
68
90
                void Load ()
69
91
                {
70
 
                        string name = fontOutputButton.Style.FontDescription.ToString ();
71
 
                        
72
92
                        for (int n=1; n < isoCodes.Length; n += 2)
73
93
                                comboLanguage.AppendText (GettextCatalog.GetString (isoCodes [n]));
74
94
                        
78
98
                        
79
99
                        comboTheme.AppendText (GettextCatalog.GetString ("(Default)"));
80
100
 
81
 
                        FilePath homeDir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
82
 
                        string[] searchDirs = { homeDir.Combine (".themes"), Gtk.Rc.ThemeDir };
83
 
                        var themes = FindThemes (searchDirs).ToList ();
84
 
                        themes.Sort ();
85
 
                        
86
 
                        foreach (string t in themes)
 
101
                        foreach (string t in InstalledThemes)
87
102
                                comboTheme.AppendText (t);
88
103
                        
89
 
                        comboTheme.Active = themes.IndexOf (IdeApp.Preferences.UserInterfaceTheme) + 1;
90
 
                        
91
 
                        documentSwitcherButton.Active = PropertyService.Get ("MonoDevelop.Core.Gui.EnableDocumentSwitchDialog", true);
92
 
                        fontCheckbox.Active = IdeApp.Preferences.CustomPadFont != null;
93
 
                        fontButton.FontName = IdeApp.Preferences.CustomPadFont ?? name;
94
 
                        fontButton.Sensitive = fontCheckbox.Active;
95
 
                        fontOutputCheckbox.Active = IdeApp.Preferences.CustomOutputPadFont != null;
96
 
                        fontOutputButton.FontName = IdeApp.Preferences.CustomOutputPadFont ?? name;
97
 
                        fontOutputButton.Sensitive = fontOutputCheckbox.Active;
98
 
                        
99
 
                        fontCheckbox.Toggled += new EventHandler (FontCheckboxToggled);
100
 
                        fontOutputCheckbox.Toggled += new EventHandler (FontOutputCheckboxToggled);
101
 
 
102
 
                        Gtk.IconSize curSize = IdeApp.Preferences.ToolbarSize;
103
 
                        toolbarCombobox.Active = Array.IndexOf (sizes, curSize);
104
 
                        
105
 
                        comboCompact.Active = (int) IdeApp.Preferences.WorkbenchCompactness;
 
104
                        comboTheme.Active = themes.Value.IndexOf (IdeApp.Preferences.UserInterfaceTheme) + 1;
 
105
 
 
106
                        labelTheme.Visible = comboTheme.Visible = !Platform.IsMac && !Platform.IsWindows;
106
107
                }
107
108
                
108
109
                // Code for getting the list of themes based on f-spot
109
 
                ICollection<string> FindThemes (params string[] themeDirs)
 
110
                static ICollection<string> FindThemes (IEnumerable<string> themeDirs)
110
111
                {
111
112
                        var themes = new HashSet<string> ();
112
113
                        string gtkrc = System.IO.Path.Combine ("gtk-2.0", "gtkrc");
114
115
                                if (string.IsNullOrEmpty (themeDir) || !System.IO.Directory.Exists (themeDir))
115
116
                                        continue;
116
117
                                foreach (FilePath dir in System.IO.Directory.GetDirectories (themeDir)) {
117
 
                                        if (System.IO.File.Exists (dir.Combine (gtkrc)))
118
 
                                                themes.Add (dir.FileName);
 
118
                                        if (System.IO.File.Exists (dir.Combine (gtkrc))) {
 
119
                                                if (!IdeStartup.FailingGtkThemes.Any (t => t == dir.FileName))
 
120
                                                        themes.Add (dir.FileName);
 
121
                                        }
119
122
                                }
120
123
                        }
121
124
                        return themes;
122
125
                }
123
126
                
124
 
                void FontOutputCheckboxToggled (object sender, EventArgs e)
125
 
                {
126
 
                        fontOutputButton.Sensitive = fontOutputCheckbox.Active;
127
 
                }
128
 
                void FontCheckboxToggled (object sender, EventArgs e)
129
 
                {
130
 
                        fontButton.Sensitive = fontCheckbox.Active;
131
 
                }
132
 
                
133
127
                public void Store()
134
128
                {
135
129
                        string lc = isoCodes [comboLanguage.Active * 2];
136
130
                        if (lc != IdeApp.Preferences.UserInterfaceLanguage) {
137
131
                                IdeApp.Preferences.UserInterfaceLanguage = lc;
138
 
                                MessageService.ShowMessage (GettextCatalog.GetString ("The user interface language change will take effect the next time you start MonoDevelop"));
 
132
                                MessageService.ShowMessage (
 
133
                                        GettextCatalog.GetString (
 
134
                                                "The user interface language change will take effect the next time you start {0}",
 
135
                                                BrandingService.ApplicationName
 
136
                                        )
 
137
                                );
139
138
                        }
140
139
                        string theme;
141
140
                        if (comboTheme.Active == 0) {
149
148
                        
150
149
                        if (theme != Gtk.Settings.Default.ThemeName)
151
150
                                Gtk.Settings.Default.ThemeName = theme;
152
 
                        
153
 
                        if (fontCheckbox.Active)
154
 
                                IdeApp.Preferences.CustomPadFont = fontButton.FontName;
155
 
                        else
156
 
                                IdeApp.Preferences.CustomPadFont = null;
157
 
                        
158
 
                        if (fontOutputCheckbox.Active)
159
 
                                IdeApp.Preferences.CustomOutputPadFont = fontOutputButton.FontName;
160
 
                        else
161
 
                                IdeApp.Preferences.CustomOutputPadFont = null;
162
 
                        
163
 
                        IdeApp.Preferences.ToolbarSize = sizes [toolbarCombobox.Active];
164
 
                        
165
 
                        IdeApp.Preferences.WorkbenchCompactness = (WorkbenchCompactness) comboCompact.Active;
166
 
 
167
 
                        PropertyService.Set ("MonoDevelop.Core.Gui.EnableDocumentSwitchDialog", documentSwitcherButton.Active);
168
151
                }
169
152
                
170
153
                static string[] isoCodes = new string[] {