diff options
author | Lluis Sanchez Gual <lluis@novell.com> | 2011-01-24 16:14:03 +0300 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@novell.com> | 2011-01-24 16:14:23 +0300 |
commit | fb479c3d4c83757906c3f6d23bd26e68a1454552 (patch) | |
tree | ae5f2788acebc5e6a6fa49bdf755966677b35ccd | |
parent | e9ab48e7fb3babf87221957a5de18dcd4f5b119f (diff) |
Properly refresh the policies combo. Fix stack overflow.
Add missing options panel.
3 files changed, 64 insertions, 43 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/MimeTypePolicyOptionsSection.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/MimeTypePolicyOptionsSection.cs index 4d0328f4e7..1f1e2f5ddd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/MimeTypePolicyOptionsSection.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/MimeTypePolicyOptionsSection.cs @@ -53,6 +53,8 @@ namespace MonoDevelop.Ide.Gui.Dialogs HBox warningMessage; bool isGlobalPolicy; List<PolicySet> setsInCombo = new List<PolicySet> (); + bool synchingPoliciesCombo; + bool selectingPolicy; public MimeTypePolicyOptionsSection () { @@ -164,26 +166,34 @@ namespace MonoDevelop.Ide.Gui.Dialogs void HandlePolicyComboChanged (object sender, EventArgs e) { - loading = true; + if (loading || synchingPoliciesCombo) + return; - if (policyCombo.Active == 0 && !isRoot) { - panelData.UseParentPolicy = true; - notebook.Sensitive = false; - } - else { - string activeName = policyCombo.ActiveText; - PolicySet pset = PolicyService.GetPolicySet (activeName); - if (pset != null) - panelData.AssignPolicies (pset); - else - panelData.UseParentPolicy = false; - notebook.Sensitive = true; + selectingPolicy = true; + try { + if (policyCombo.Active == 0 && !isRoot) { + panelData.UseParentPolicy = true; + notebook.Sensitive = false; + } + else { + string activeName = policyCombo.ActiveText; + PolicySet pset = PolicyService.GetPolicySet (activeName); + if (pset != null) + panelData.AssignPolicies (pset); + else + panelData.UseParentPolicy = false; + notebook.Sensitive = true; + } + } finally { + selectingPolicy = false; } - loading = false; } public void FillPolicies () { + if (selectingPolicy) + return; + ((ListStore)store).Clear (); if (IsCustomUserPolicy) { @@ -210,38 +220,43 @@ namespace MonoDevelop.Ide.Gui.Dialogs public void UpdateSelectedNamedPolicy () { - if (loading) + if (selectingPolicy) return; - // Find a policy set which is common to all policy types - - if (!isRoot && panelData.UseParentPolicy) { - policyCombo.Active = 0; - return; - } - - int active = -1; - - PolicySet matchedSet = panelData.GetMatchingSet (setsInCombo); - - TreeIter iter; - int i = 0; - if (matchedSet != null && store.GetIterFirst (out iter)) { - do { - PolicySet s2 = store.GetValue (iter, 1) as PolicySet; - if (s2 != null && s2.Id == matchedSet.Id) { - active = i; - break; - } - i++; - } while (store.IterNext (ref iter)); + synchingPoliciesCombo = true; + try { + // Find a policy set which is common to all policy types + + if (!isRoot && panelData.UseParentPolicy) { + policyCombo.Active = 0; + return; + } + + int active = -1; + + PolicySet matchedSet = panelData.GetMatchingSet (setsInCombo); + + TreeIter iter; + int i = 0; + if (matchedSet != null && store.GetIterFirst (out iter)) { + do { + PolicySet s2 = store.GetValue (iter, 1) as PolicySet; + if (s2 != null && s2.Id == matchedSet.Id) { + active = i; + break; + } + i++; + } while (store.IterNext (ref iter)); + } + if (active != -1) + policyCombo.Active = active; + else + policyCombo.Active = store.IterNChildren () - 1; + + warningMessage.Visible = isGlobalPolicy && panelData.Modified; + } finally { + synchingPoliciesCombo = false; } - if (active != -1) - policyCombo.Active = active; - else - policyCombo.Active = store.IterNChildren () - 1; - - warningMessage.Visible = isGlobalPolicy && panelData.Modified; } bool IsCustomUserPolicy { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CodeFormattingPanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CodeFormattingPanel.cs index 4a55041b9b..1f6a9af462 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CodeFormattingPanel.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CodeFormattingPanel.cs @@ -98,6 +98,10 @@ namespace MonoDevelop.Ide.Projects.OptionPanels } if (modified) pd.UseParentPolicy = useParentPolicy; + if (pd.SectionLoaded) { + pd.SectionPanel.FillPolicies (); + pd.SectionPanel.UpdateSelectedNamedPolicy (); + } } if (widget != null) widget.Refresh (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml index 3b5027a782..ac49192adc 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml @@ -640,9 +640,11 @@ </Section> <Condition id="ItemType" value="Solution"> <Section id="CodeFormattingPolicies" _label="Code Formatting" icon="md-formatting" fill = "true" class="MonoDevelop.Ide.Projects.OptionPanels.CodeFormattingPanel" /> + <Section id="DefaultStandardHeader" _label = "Standard Header" fill="true" class = "MonoDevelop.Ide.StandardHeader.StandardHeaderPolicyPanel" /> </Condition> <Condition id="ItemType" value="SolutionItem"> <Section id="CodeFormattingPolicies" _label="Code Formatting" icon="md-formatting" fill = "true" class="MonoDevelop.Ide.Projects.OptionPanels.CodeFormattingPanel" /> + <Section id="DefaultStandardHeader" _label = "Standard Header" fill="true" class = "MonoDevelop.Ide.StandardHeader.StandardHeaderPolicyPanel" /> </Condition> </Section> </Extension> |