public KeyBindingSet Clone() { KeyBindingSet kset = new KeyBindingSet(parent); kset.bindings = new Dictionary <string, string> (bindings); return(kset); }
public bool Equals(KeyBindingSet other) { // TODO: full IEquatable<KeyBindingSet> implementation // the current solutions is just enough to detect whether a custom set equals a predefined one // and is not a real equality check. See KeyBindingsPanel.SelectCurrentScheme(). if (other == null) { return(false); } var otherSet = other.GetAllBindings(); var allBindings = GetAllBindings(); if (otherSet.Count != allBindings.Count) { return(false); } foreach (var binding in allBindings) { string accel; if (!otherSet.TryGetValue(binding.Key, out accel) || accel != binding.Value) { return(false); } } return(true); }
static KeyBindingService() { schemes = new SortedDictionary <string, KeyBindingScheme> (); // Initialize the default scheme defaultSchemeBindings = new KeyBindingSet(); defaultScheme = new DefaultScheme(defaultSchemeBindings); schemes.Add(defaultScheme.Id, defaultScheme); // Initialize the current bindings current = new KeyBindingSet(defaultSchemeBindings); }
static KeyBindingService () { schemes = new SortedDictionary<string,KeyBindingScheme> (); // Initialize the default scheme defaultSchemeBindings = new KeyBindingSet (); defaultScheme = new DefaultScheme (defaultSchemeBindings); schemes.Add (defaultScheme.Id, defaultScheme); // Initialize the current bindings current = new KeyBindingSet (defaultSchemeBindings); }
public static void ResetCurrent(string schemeId) { if (schemeId != null) { KeyBindingScheme scheme = GetScheme(schemeId); if (scheme != null) { current = scheme.GetKeyBindingSet().Clone(); return; } } current.ClearBindings(); }
public bool Equals(KeyBindingSet other) { if (bindings.Count != other.bindings.Count) { return(false); } foreach (KeyValuePair <string, string> binding in bindings) { string accel; if (!other.bindings.TryGetValue(binding.Key, out accel) || accel != binding.Value) { return(false); } } return(true); }
public bool Equals(KeyBindingSet other) { // TODO: full IEquatable<KeyBindingSet> implementation // the current solutions is just enough to detect whether a custom set equals a predefined one // and is not a real equality check. See KeyBindingsPanel.SelectCurrentScheme(). if (other == null) { return(false); } if (parent != null && parent != other && !parent.Equals(other.parent)) { return(false); } foreach (KeyValuePair <string, string> binding in bindings) { string accel; if (!other.bindings.TryGetValue(binding.Key, out accel) || accel != binding.Value) { return(false); } } return(true); }
public KeyBindingSet(KeyBindingSet parent) { this.parent = parent; }
public DefaultScheme(KeyBindingSet bindings) { this.bindings = bindings; }
public DefaultScheme (KeyBindingSet bindings) { this.bindings = bindings; }
public static void ResetCurrent (string schemeId) { if (schemeId != null) { KeyBindingScheme scheme = GetScheme (schemeId); if (scheme != null) { current = scheme.GetKeyBindingSet ().Clone (); return; } } current.ClearBindings (); }
public static void ResetCurrent (KeyBindingSet kbset) { current = kbset.Clone (); }
public KeyBindingSet Clone () { KeyBindingSet kset = new KeyBindingSet (parent); kset.bindings = new Dictionary<string, string> (bindings); return kset; }
public KeyBindingSet (KeyBindingSet parent) { this.parent = parent; }
public bool Equals (KeyBindingSet other) { if (bindings.Count != other.bindings.Count) return false; foreach (KeyValuePair<string, string> binding in bindings) { string accel; if (!other.bindings.TryGetValue (binding.Key, out accel) || accel != binding.Value) return false; } return true; }
void OnKeyBindingSchemeChanged (object sender, EventArgs e) { if (internalUpdate) return; if (schemeCombo.Active == 0) return; Command command; string binding; TreeIter iter; if (!keyStore.GetIterFirst (out iter)) return; // Load a key binding template KeyBindingScheme scheme = KeyBindingService.GetSchemeByName (schemeCombo.ActiveText); currentBindings = scheme.GetKeyBindingSet ().Clone (); do { TreeIter citer; keyStore.IterChildren (out citer, iter); do { command = (Command) keyStore.GetValue (citer, commandCol); binding = currentBindings.GetBinding (command); keyStore.SetValue (citer, bindingCol, binding); } while (keyStore.IterNext (ref citer)); } while (keyStore.IterNext (ref iter)); UpdateGlobalWarningLabel (); }
public KeyBindingsPanel () { this.Build (); keyStore = new TreeStore (typeof (Command), typeof (string), typeof (string), typeof (string), typeof (int), typeof(string), typeof(bool), typeof (bool)); keyTreeView.Model = filterModel = new TreeModelFilter (keyStore, null); filterModel.VisibleColumn = visibleCol; TreeViewColumn col = new TreeViewColumn (); col.Title = GettextCatalog.GetString ("Command"); col.Spacing = 4; CellRendererImage crp = new CellRendererImage (); col.PackStart (crp, false); col.AddAttribute (crp, "stock-id", iconCol); col.AddAttribute (crp, "visible", iconVisibleCol); CellRendererText crt = new CellRendererText (); col.PackStart (crt, true); col.AddAttribute (crt, "text", labelCol); col.AddAttribute (crt, "weight", boldCol); keyTreeView.AppendColumn (col); TreeViewColumn bindingTVCol = new TreeViewColumn (); bindingTVCol.Title = GettextCatalog.GetString ("Key Binding"); CellRendererText bindingRenderer = new CellRendererText (); bindingTVCol.PackStart (bindingRenderer, false); bindingTVCol.SetCellDataFunc (bindingRenderer, delegate (TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { string binding = (model.GetValue (iter, bindingCol) as string) ?? ""; ((CellRendererText)cell).Text = binding.Length > 0 ? KeyBindingManager.BindingToDisplayLabel (binding, false) : binding; }); keyTreeView.AppendColumn (bindingTVCol); keyTreeView.AppendColumn (GettextCatalog.GetString ("Description"), new CellRendererText (), "text", descCol); keyTreeView.Selection.Changed += OnKeysTreeViewSelectionChange; accelEntry.KeyPressEvent += OnAccelEntryKeyPress; accelEntry.KeyReleaseEvent += OnAccelEntryKeyRelease; accelEntry.Changed += delegate { UpdateWarningLabel (); }; updateButton.Clicked += OnUpdateButtonClick; currentBindings = KeyBindingService.CurrentKeyBindingSet.Clone (); schemes = new List<KeyBindingScheme> (KeyBindingService.Schemes); schemeCombo.AppendText (GettextCatalog.GetString ("Custom")); foreach (KeyBindingScheme s in schemes) schemeCombo.AppendText (s.Name); SelectCurrentScheme (); schemeCombo.Changed += OnKeyBindingSchemeChanged; searchEntry.Ready = true; searchEntry.Visible = true; searchEntry.Changed += delegate { processedFilterTerms = searchEntry.Entry.Text.Split (new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Select (s => s.ToLower ()).ToArray ();; filterChanged = true; if (!filterTimeoutRunning) { filterTimeoutRunning = true; GLib.Timeout.Add (50, delegate { if (!filterChanged) { if (filterTimeoutRunning) Refilter (); filterTimeoutRunning = false; return false; } filterChanged = false; return true; }); }; }; //HACK: workaround for MD Bug 608021: Stetic loses values assigned to "new" properties of custom widget conflicButton.Label = GettextCatalog.GetString ("_View Conflicts"); conflicButton.UseUnderline = true; }
public static void ResetCurrent(KeyBindingSet kbset) { current = kbset.Clone(); }