diff options
author | David Karlaš <david.karlas@xamarin.com> | 2015-11-24 20:46:28 +0300 |
---|---|---|
committer | David Karlaš <david.karlas@xamarin.com> | 2015-11-24 20:46:28 +0300 |
commit | fdcef13057a9c4a9bc924602c9b2b33c1da3bf63 (patch) | |
tree | f5d45bca682a39c3946dbd9fee281e152288a4aa /main/src/addins/MonoDevelop.SourceEditor2 | |
parent | ee4190106f0d102c4fdce57fc3c5637cbce7b9aa (diff) | |
parent | 07a993cf6d80660fde31099c1aca8029a3035807 (diff) |
Merge branch 'master' into newExceptionDialog
Diffstat (limited to 'main/src/addins/MonoDevelop.SourceEditor2')
-rw-r--r-- | main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/HighlightingPanel.cs | 50 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj | 2 |
2 files changed, 36 insertions, 16 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..013f184cb4 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; } @@ -179,7 +199,7 @@ namespace MonoDevelop.SourceEditor.OptionPanels void HandleButtonExportClicked (object sender, EventArgs e) { - var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), Gtk.FileChooserAction.Save) { + var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), MonoDevelop.Components.FileChooserAction.Save) { TransientFor = this.Toplevel as Gtk.Window, }; dialog.AddFilter (GettextCatalog.GetString ("Color schemes"), "*.json"); @@ -198,7 +218,7 @@ namespace MonoDevelop.SourceEditor.OptionPanels void AddColorScheme (object sender, EventArgs args) { - var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), Gtk.FileChooserAction.Open) { + var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), MonoDevelop.Components.FileChooserAction.Open) { TransientFor = this.Toplevel as Gtk.Window, }; dialog.AddFilter (GettextCatalog.GetString ("Color schemes"), "*.json"); diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj index 6030f79e7e..9c6b608723 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj @@ -44,7 +44,7 @@ </Execution> <DebugSymbols>true</DebugSymbols> <NoWarn>1591;1573</NoWarn> - <DocumentationFile>..\..\..\build\AddIns\DisplayBindings\SourceEditor\MonoDevelop.SourceEditor.xml</DocumentationFile> + <DocumentationFile>..\..\..\build\AddIns\DisplayBindings\SourceEditor\MonoDevelop.SourceEditor2.xml</DocumentationFile> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj"> |