diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2015-10-02 12:04:41 +0300 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2015-10-02 12:08:11 +0300 |
commit | 4612ba4e20c067e27d9c91acad3398fcc7df704c (patch) | |
tree | 4a2312c629d45b44b01676a658d2b83e2f4c05ff /main/src/addins/MonoDevelop.SourceEditor2 | |
parent | 15db44a46c87150ce47c9958546ae8346706229a (diff) |
Fixed 'Bug 34444 - [Paper Cuts] Making a Theme error is a permanent
mistake'.
Diffstat (limited to 'main/src/addins/MonoDevelop.SourceEditor2')
-rw-r--r-- | main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/HighlightingPanel.cs | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/HighlightingPanel.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/HighlightingPanel.cs index 621ced902e..4350377ab7 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/HighlightingPanel.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/HighlightingPanel.cs @@ -38,14 +38,24 @@ namespace MonoDevelop.SourceEditor.OptionPanels public partial class HighlightingPanel : Gtk.Bin, IOptionsPanel { string schemeName; + ListStore styleStore = new ListStore (typeof (string), typeof (Mono.TextEditor.Highlighting.ColorScheme), typeof(bool)); + Lazy<Gdk.Pixbuf> errorPixbuf = new Lazy<Gdk.Pixbuf> (() => ImageService.GetIcon (Stock.DialogError, IconSize.Menu).ToPixbuf ()); - - ListStore styleStore = new ListStore (typeof (string), typeof (Mono.TextEditor.Highlighting.ColorScheme)); - public HighlightingPanel () { this.Build (); - styleTreeview.AppendColumn ("", new CellRendererText (), "markup", 0); + var col = new TreeViewColumn (); + var crpixbuf = new CellRendererPixbuf (); + col.PackStart (crpixbuf, false); + col.SetCellDataFunc (crpixbuf, (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) => { + var isError = (bool)styleStore.GetValue (iter, 2); + crpixbuf.Visible = isError; + crpixbuf.Pixbuf = isError ? errorPixbuf.Value : null; + }); + var crtext = new CellRendererText (); + col.PackEnd (crtext, true); + col.SetAttributes (crtext, "markup", 0); + styleTreeview.AppendColumn (col); styleTreeview.Model = styleStore; // ensure that custom styles are loaded. new SourceEditorDisplayBinding (); @@ -101,7 +111,11 @@ namespace MonoDevelop.SourceEditor.OptionPanels var sheme = (Mono.TextEditor.Highlighting.ColorScheme)styleStore.GetValue (iter, 1); if (sheme == null) return; - + var isError = (bool)styleStore.GetValue (iter, 2); + if (isError) { + this.removeButton.Sensitive = true; + return; + } DefaultSourceEditorOptions.Instance.ColorScheme = sheme.Name; this.buttonExport.Sensitive = true; string fileName = sheme.FileName; @@ -118,19 +132,24 @@ namespace MonoDevelop.SourceEditor.OptionPanels using (var editor = new ColorShemeEditor (this)) { var colorScheme = (Mono.TextEditor.Highlighting.ColorScheme)this.styleStore.GetValue (selectedIter, 1); editor.SetSheme (colorScheme); - MessageService.ShowCustomDialog (editor, dialog); + MessageService. ShowCustomDialog (editor, dialog); } } } - Mono.TextEditor.Highlighting.ColorScheme LoadStyle (string styleName, bool showException = true) + Mono.TextEditor.Highlighting.ColorScheme LoadStyle (string styleName, out bool error) { try { + error = false; return Mono.TextEditor.Highlighting.SyntaxModeService.GetColorStyle (styleName); } catch (Exception e) { - if (showException) - MessageService.ShowError ("Error while importing color style " + styleName, (e.InnerException ?? e).Message); - return Mono.TextEditor.Highlighting.SyntaxModeService.DefaultColorStyle; + LoggingService.LogError ("Error while loading color style " + styleName, e); + error = true; + var style = Mono.TextEditor.Highlighting.SyntaxModeService.DefaultColorStyle.Clone (); + style.Name = styleName; + style.Description = GettextCatalog.GetString ("Loading error:" + e.Message); + style.FileName = Mono.TextEditor.Highlighting.SyntaxModeService.GetFileName (styleName); + return style; } } @@ -138,11 +157,12 @@ namespace MonoDevelop.SourceEditor.OptionPanels internal void ShowStyles () { styleStore.Clear (); - TreeIter selectedIter = styleStore.AppendValues (GetMarkup (GettextCatalog.GetString ("Default"), GettextCatalog.GetString ("The default color scheme.")), LoadStyle ("Default")); + bool error; + TreeIter selectedIter = styleStore.AppendValues (GetMarkup (GettextCatalog.GetString ("Default"), GettextCatalog.GetString ("The default color scheme.")), LoadStyle ("Default", out error)); foreach (string styleName in Mono.TextEditor.Highlighting.SyntaxModeService.Styles) { if (styleName == "Default") continue; - var style = LoadStyle (styleName); + var style = LoadStyle (styleName, out error); string name = style.Name ?? ""; string description = style.Description ?? ""; // translate only build-in sheme names @@ -154,7 +174,7 @@ namespace MonoDevelop.SourceEditor.OptionPanels } catch { } } - TreeIter iter = styleStore.AppendValues (GetMarkup (name, description), style); + TreeIter iter = styleStore.AppendValues (GetMarkup (name, description), style, error); if (style.Name == DefaultSourceEditorOptions.Instance.ColorScheme) selectedIter = iter; } |