T GetInheritedPolicy(IEnumerable <string> scopes) { foreach (string scope in scopes) { PolicyContainer currentBag = scope == mimeType ? policyContainer.ParentPolicies : policyContainer; while (currentBag != null) { if (currentBag.DirectHas <T> (scope)) { T pol = currentBag.DirectGet <T> (scope); if (pol != null) { return(pol); } // Default settings requested for this scope. Start looking from the original // bag now using the next scope in the chain break; } else { currentBag = currentBag.ParentPolicies; } } } return(PolicyService.GetDefaultPolicy <T>(scopes)); }
Widget IOptionsPanel.CreatePanelWidget() { HBox hbox = new HBox(false, 6); Label label = new Label(); string displayName = polSet != null?GettextCatalog.GetString("_Policy") : PolicyTitleWithMnemonic; label.MarkupWithMnemonic = "<b>" + displayName + ":</b>"; hbox.PackStart(label, false, false, 0); store = new ListStore(typeof(string), typeof(PolicySet)); policyCombo = new ComboBox(store); CellRenderer renderer = new CellRendererText(); policyCombo.PackStart(renderer, true); policyCombo.AddAttribute(renderer, "text", 0); label.MnemonicWidget = policyCombo; policyCombo.RowSeparatorFunc = (TreeModel model, TreeIter iter) => ((string)model.GetValue(iter, 0)) == "--"; hbox.PackStart(policyCombo, false, false, 0); VBox vbox = new VBox(false, 6); vbox.PackStart(hbox, false, false, 0); vbox.ShowAll(); FillPolicies(); policyCombo.Active = 0; Widget child = CreatePanelWidget(); //HACK: work around bug 469427 - broken themes match on widget names if (child.Name.IndexOf("Panel") > 0) { child.Name = child.Name.Replace("Panel", "_"); } vbox.PackEnd(child, true, true, 0); LoadFrom(GetCurrentValue()); loading = false; if (!IsRoot && !policyContainer.DirectHas <T> ()) { //in this case "parent" is always first in the list policyCombo.Active = 0; } else { UpdateSelectedNamedPolicy(); } policyCombo.Changed += HandlePolicyComboChanged; return(vbox); }
T GetDirectInherited(PolicyContainer initialContainer) { if (initialContainer == policyContainer && !loaded && hasCachedPolicy) { return((T)cachedPolicy); } PolicyContainer pc = initialContainer; while (pc != null) { if (pc.DirectHas <T> (mimeType)) { return(pc.DirectGet <T> (mimeType)); } pc = pc.ParentPolicies; } return(PolicyService.GetUserDefaultPolicySet().Get <T> (mimeType)); }
Control IOptionsPanel.CreatePanelWidget() { HBox hbox = new HBox(false, 6); Label label = new Label(); string displayName = polSet != null?GettextCatalog.GetString("_Policy") : PolicyTitleWithMnemonic; label.MarkupWithMnemonic = "<b>" + displayName + ":</b>"; hbox.PackStart(label, false, false, 0); store = new ListStore(typeof(string), typeof(PolicySet)); policyCombo = new ComboBox(store); CellRenderer renderer = new CellRendererText(); policyCombo.PackStart(renderer, true); policyCombo.AddAttribute(renderer, "text", 0); label.MnemonicWidget = policyCombo; policyCombo.RowSeparatorFunc = (TreeModel model, TreeIter iter) => ((string)model.GetValue(iter, 0)) == "--"; hbox.PackStart(policyCombo, false, false, 0); VBox vbox = new VBox(false, 6); vbox.PackStart(hbox, false, false, 0); vbox.ShowAll(); FillPolicies(); policyCombo.Active = 0; // Message to be shown when the user changes default policies warningMessage = new HBox(); warningMessage.Spacing = 6; var img = new ImageView(Stock.Warning, IconSize.LargeToolbar); warningMessage.PackStart(img, false, false, 0); Label wl = new Label(GettextCatalog.GetString("Changes done in this section will only be applied to new projects. " + "Settings for existing projects can be modified in the project (or solution) options dialog.")); wl.Xalign = 0; wl.Wrap = true; wl.WidthRequest = 450; warningMessage.PackStart(wl, true, true, 0); warningMessage.ShowAll(); warningMessage.Visible = false; vbox.PackEnd(warningMessage, false, false, 0); policyPanel = CreatePanelWidget(); //HACK: work around bug 469427 - broken themes match on widget names if (policyPanel.Name.IndexOf("Panel") > 0) { policyPanel.Name = policyPanel.Name.Replace("Panel", "_"); } vbox.PackEnd(policyPanel, true, true, 0); InitializePolicy(); loading = false; if (!IsRoot && !policyContainer.DirectHas <T> ()) { //in this case "parent" is always first in the list policyCombo.Active = 0; } else { UpdateSelectedNamedPolicy(); } policyCombo.Changed += HandlePolicyComboChanged; return(vbox); }