예제 #1
0
        public KeyBindingSet Clone()
        {
            KeyBindingSet kset = new KeyBindingSet(parent);

            kset.bindings = new Dictionary <string, string> (bindings);
            return(kset);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
		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);
		}
예제 #5
0
        public static void ResetCurrent(string schemeId)
        {
            if (schemeId != null)
            {
                KeyBindingScheme scheme = GetScheme(schemeId);
                if (scheme != null)
                {
                    current = scheme.GetKeyBindingSet().Clone();
                    return;
                }
            }

            current.ClearBindings();
        }
예제 #6
0
 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);
 }
예제 #7
0
 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);
 }
예제 #8
0
 public KeyBindingSet(KeyBindingSet parent)
 {
     this.parent = parent;
 }
예제 #9
0
 public DefaultScheme(KeyBindingSet bindings)
 {
     this.bindings = bindings;
 }
예제 #10
0
		public DefaultScheme (KeyBindingSet bindings)
		{
			this.bindings = bindings;
		}
예제 #11
0
		public static void ResetCurrent (string schemeId)
		{
			if (schemeId != null) {
				KeyBindingScheme scheme = GetScheme (schemeId);
				if (scheme != null) {
					current = scheme.GetKeyBindingSet ().Clone ();
					return;
				}
			}

			current.ClearBindings ();
		}
예제 #12
0
		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;
		}
예제 #16
0
		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 ();
		}
예제 #17
0
		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;
		}
예제 #18
0
 public static void ResetCurrent(KeyBindingSet kbset)
 {
     current = kbset.Clone();
 }