Author: lluis
Date: 2008-01-09 07:30:12 -0500 (Wed, 09 Jan 2008)
New Revision: 92497

Modified:
   branches/monodevelop/main/1.0/src/addins/MonoDevelop.SourceEditor/ChangeLog
   
branches/monodevelop/main/1.0/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui.OptionPanels/SyntaxHighlightingPanel.cs
Log:
2008-01-09  Lluis Sanchez Gual <[EMAIL PROTECTED]> 

        * MonoDevelop.SourceEditor.Gui.OptionPanels/SyntaxHighlightingPanel.cs:
          Don't store changes until OK is clicked. Fixes bug #344269.



Modified: 
branches/monodevelop/main/1.0/src/addins/MonoDevelop.SourceEditor/ChangeLog
===================================================================
--- branches/monodevelop/main/1.0/src/addins/MonoDevelop.SourceEditor/ChangeLog 
2008-01-09 12:29:08 UTC (rev 92496)
+++ branches/monodevelop/main/1.0/src/addins/MonoDevelop.SourceEditor/ChangeLog 
2008-01-09 12:30:12 UTC (rev 92497)
@@ -1,3 +1,8 @@
+2008-01-09  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
+
+       * MonoDevelop.SourceEditor.Gui.OptionPanels/SyntaxHighlightingPanel.cs:
+         Don't store changes until OK is clicked. Fixes bug #344269.
+
 2008-01-08  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
 
        * EditorBindings.glade,

Modified: 
branches/monodevelop/main/1.0/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui.OptionPanels/SyntaxHighlightingPanel.cs
===================================================================
--- 
branches/monodevelop/main/1.0/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui.OptionPanels/SyntaxHighlightingPanel.cs
      2008-01-09 12:29:08 UTC (rev 92496)
+++ 
branches/monodevelop/main/1.0/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui.OptionPanels/SyntaxHighlightingPanel.cs
      2008-01-09 12:30:12 UTC (rev 92497)
@@ -2,6 +2,7 @@
 using System.IO;
 using System.Text;
 using System.Collections;
+using System.Collections.Generic;
 
 using Gtk;
 using Pango;
@@ -52,6 +53,8 @@
                        SourceTagStyle currentStyle;
                        string styleid;
                        
+                       
Dictionary<SourceLanguage,Dictionary<string,SourceTagStyle>> changes = new 
Dictionary<SourceLanguage,Dictionary<string,SourceTagStyle>> ();
+                       
                        public SyntaxHighlightingPanelWidget () :  base 
("EditorBindings.glade", "SyntaxHighlightingPanel")
                        {
                                enableSyntaxHighlighting.Active = 
TextEditorProperties.SyntaxHighlight;
@@ -75,6 +78,11 @@
                        public void Store ()
                        {
                                TextEditorProperties.SyntaxHighlight = 
enableSyntaxHighlighting.Active;
+                               foreach 
(KeyValuePair<SourceLanguage,Dictionary<string,SourceTagStyle>> lang in 
changes) {
+                                       foreach 
(KeyValuePair<string,SourceTagStyle> style in lang.Value) {
+                                               lang.Key.SetTagStyle 
(style.Key, style.Value);
+                                       }
+                               }
                        }
 
                        void SetCurrentLanguage (string name)
@@ -120,7 +128,7 @@
                                sts.Underline = underlineToggle.Active;
                                sts.Strikethrough = strikeToggle.Active;
                                sts.IsDefault = false;
-                               currentLanguage.SetTagStyle (styleid, sts);
+                               SetTagStyle (currentLanguage, styleid, sts);
                                restoreDefaultButton.Sensitive = true;
                        }
 
@@ -134,7 +142,7 @@
                                fgColorButton.Sensitive = checkColor.Active;
                                bgColorButton.Sensitive = 
checkBackground.Active;
                                sts.IsDefault = false;
-                               currentLanguage.SetTagStyle (styleid, sts);
+                               SetTagStyle (currentLanguage, styleid, sts);
                                restoreDefaultButton.Sensitive = true;
                        }
 
@@ -166,10 +174,31 @@
 
                                if (selection.GetSelected (out model, out 
iter)) {
                                        styleid = (string) model.GetValue 
(iter, 1);
-                                       currentStyle = 
currentLanguage.GetTagStyle (styleid);
+                                       currentStyle = GetTagStyle 
(currentLanguage, styleid);
                                        SetSourceTagStyle ();
                                }
                        }
+                       
+                       SourceTagStyle GetTagStyle (SourceLanguage lang, string 
id)
+                       {
+                               Dictionary<string,SourceTagStyle> styles;
+                               if (changes.TryGetValue (lang, out styles)) {
+                                       SourceTagStyle style;
+                                       if (styles.TryGetValue (id, out style))
+                                               return style;
+                               }
+                               return currentLanguage.GetTagStyle (styleid);
+                       }
+                       
+                       void SetTagStyle (SourceLanguage lang, string id, 
SourceTagStyle style)
+                       {
+                               Dictionary<string,SourceTagStyle> styles;
+                               if (!changes.TryGetValue (lang, out styles)) {
+                                       styles = new 
Dictionary<string,SourceTagStyle> ();
+                                       changes [lang] = styles;
+                               }
+                               styles [id] = style;
+                       }
                }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to