protected override void ApplyChanges() { base.ApplyChanges(); ApplyPolicyChanges(); HashSet <PolicySet> usets = new HashSet <PolicySet> (PolicyService.GetUserPolicySets()); foreach (PolicySet ps in sets) { PolicySet orig; if (originalSets.TryGetValue(ps, out orig)) { orig.CopyFrom(ps); usets.Remove(orig); } else { orig = ps.Clone(); PolicyService.AddUserPolicySet(orig); originalSets [ps] = orig; } } foreach (PolicySet ps in usets) { PolicyService.RemoveUserPolicySet(ps); } PolicyService.SavePolicies(); }
protected void OnButtonOkClicked(object sender, EventArgs e) { if (radioCustom.Active) { if (entryName.Text.Length == 0) { MessageService.ShowError(GettextCatalog.GetString("Policy name not specified")); return; } PolicySet pset = CreatePolicySet(); pset.Name = entryName.Text; PolicyService.AddUserPolicySet(pset); PolicyService.SavePolicies(); } else { if (fileEntry.Path == null || fileEntry.Path.Length == 0) { MessageService.ShowError(GettextCatalog.GetString("File name not specified")); return; } FilePath file = fileEntry.Path; if (file.Extension != ".mdpolicy") { file = file + ".mdpolicy"; } DefaultFileDialogPolicyDir = file.ParentDirectory; if (System.IO.File.Exists(file) && !MessageService.Confirm(GettextCatalog.GetString("The file {0} already exists. Do you want to replace it?", file), AlertButton.Replace)) { return; } PolicySet pset = CreatePolicySet(); pset.Name = file.FileName; try { pset.SaveToFile(file); } catch (Exception ex) { MessageService.ShowError(GettextCatalog.GetString("The policy file could not be saved"), ex); return; } } Respond(Gtk.ResponseType.Ok); }