Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs62
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandEntry.cs14
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs9
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingManager.cs52
4 files changed, 114 insertions, 23 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs
index 5bac1ff279..9a0a69b78d 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs
@@ -95,10 +95,39 @@ namespace MonoDevelop.Components.Commands
KeyBindingChanged (this, new KeyBindingChangedEventArgs (this, oldKeyBinding));
}
}
-
+
+ string[] alternateAccelKeys;
+ KeyBinding[] alternateKeyBindings;
+ static readonly KeyBinding[] emptyBindings = new KeyBinding[0];
+
+ public string[] AlternateAccelKeys {
+ get { return alternateAccelKeys; }
+ set {
+ var oldKeybindings = alternateKeyBindings;
+ if (value == null || value.Length == 0) {
+ alternateKeyBindings = null;
+ } else {
+ alternateKeyBindings = new KeyBinding[value.Length];
+ for (int i = 0; i < value.Length; i++) {
+ KeyBinding b;
+ KeyBinding.TryParse (value[i], out b);
+ alternateKeyBindings [i] = b;
+ }
+ }
+ alternateAccelKeys = value;
+ if (AlternateKeyBindingChanged != null)
+ AlternateKeyBindingChanged (this, new AlternateKeyBindingChangedEventArgs (this, oldKeybindings));
+ }
+ }
+
public KeyBinding KeyBinding {
get { return binding; }
}
+
+ public KeyBinding[] AlternateKeyBindings {
+ get { return alternateKeyBindings ?? emptyBindings; }
+ }
+
public bool DisabledVisible {
get { return disabledVisible; }
@@ -116,26 +145,49 @@ namespace MonoDevelop.Components.Commands
}
public event KeyBindingChangedEventHandler KeyBindingChanged;
+ public event EventHandler<AlternateKeyBindingChangedEventArgs> AlternateKeyBindingChanged;
}
- public class KeyBindingChangedEventArgs {
+ public class KeyBindingChangedEventArgs : EventArgs
+ {
public KeyBindingChangedEventArgs (Command command, KeyBinding oldKeyBinding)
{
OldKeyBinding = oldKeyBinding;
Command = command;
}
-
+
public Command Command {
get; private set;
}
-
+
public KeyBinding OldKeyBinding {
get; private set;
}
-
+
public KeyBinding NewKeyBinding {
get { return Command.KeyBinding; }
}
}
+
+ public class AlternateKeyBindingChangedEventArgs : EventArgs
+ {
+ public AlternateKeyBindingChangedEventArgs (Command command, KeyBinding[] oldKeyBinding)
+ {
+ OldKeyBinding = oldKeyBinding;
+ Command = command;
+ }
+
+ public Command Command {
+ get; private set;
+ }
+
+ public KeyBinding[] OldKeyBinding {
+ get; private set;
+ }
+
+ public KeyBinding[] NewKeyBinding {
+ get { return Command.AlternateKeyBindings; }
+ }
+ }
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandEntry.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandEntry.cs
index 47aea630e4..00d9cb82ef 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandEntry.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandEntry.cs
@@ -30,6 +30,15 @@ using System;
namespace MonoDevelop.Components.Commands
{
+ public enum CommandEntryDisplayType
+ {
+ Default,
+ TextOnly,
+ IconOnly,
+ IconHasPriority,
+ IconAndText
+ }
+
public class CommandEntry
{
object cmdId;
@@ -66,6 +75,11 @@ namespace MonoDevelop.Components.Commands
get { return disabledVisible; }
set { disabledVisible = value; }
}
+
+ public CommandEntryDisplayType DispayType {
+ get;
+ set;
+ }
public virtual Command GetCommand (CommandManager manager)
{
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs
index 4d4df70d59..490c249e07 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs
@@ -455,19 +455,21 @@ namespace MonoDevelop.Components.Commands
/// <summary>
/// Disables all commands
/// </summary>
- public void LockAll ()
+ public bool LockAll ()
{
guiLock++;
if (guiLock == 1) {
foreach (ICommandBar toolbar in toolbars)
toolbar.SetEnabled (false);
- }
+ return true;
+ } else
+ return false;
}
/// <summary>
/// Unlocks the command manager
/// </summary>
- public void UnlockAll ()
+ public bool UnlockAll ()
{
if (guiLock == 1) {
foreach (ICommandBar toolbar in toolbars)
@@ -476,6 +478,7 @@ namespace MonoDevelop.Components.Commands
if (guiLock > 0)
guiLock--;
+ return guiLock == 0;
}
/// <summary>
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingManager.cs
index ced8041eb8..b4a590202b 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingManager.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingManager.cs
@@ -644,7 +644,17 @@ namespace MonoDevelop.Components.Commands
{
SetBinding (args.Command, args.OldKeyBinding, args.NewKeyBinding);
}
-
+
+ void OnAlternateKeyBindingChanged (object sender, AlternateKeyBindingChangedEventArgs args)
+ {
+ var upperBound = Math.Max (args.NewKeyBinding != null ? args.NewKeyBinding.Length : 0, args.OldKeyBinding != null ? args.OldKeyBinding.Length : 0);
+ for (int i = 0; i < upperBound; i++) {
+ SetBinding (args.Command,
+ args.OldKeyBinding != null && i < args.OldKeyBinding.Length ? args.OldKeyBinding[i] : null,
+ args.NewKeyBinding != null && i < args.NewKeyBinding.Length ? args.NewKeyBinding[i] : null );
+ }
+ }
+
public bool CommandIsRegistered (Command command)
{
return commands.Contains (command);
@@ -658,36 +668,48 @@ namespace MonoDevelop.Components.Commands
}
SetBinding (command, null, command.KeyBinding);
+ foreach (var binding in command.AlternateKeyBindings) {
+ SetBinding (command, null, binding);
+ }
+
command.KeyBindingChanged += OnKeyBindingChanged;
+ command.AlternateKeyBindingChanged += OnAlternateKeyBindingChanged;
commands.Add (command);
}
-
+
+
public void UnregisterCommand (Command command)
{
- List<Command> list;
- int refs;
-
if (!commands.Contains (command)) {
Console.WriteLine ("WARNING: trying to unregister unknown command {0}", command);
return;
}
command.KeyBindingChanged -= OnKeyBindingChanged;
+ command.AlternateKeyBindingChanged -= OnAlternateKeyBindingChanged;
commands.Remove (command);
-
- if (command.KeyBinding == null)
- return;
- list = bindings[command.KeyBinding];
+ RemoveKeyBinding (command, command.KeyBinding);
+ foreach (var altBinding in command.AlternateKeyBindings) {
+ RemoveKeyBinding (command, altBinding);
+ }
+ }
+
+ void RemoveKeyBinding (Command command, KeyBinding bindingToRemove)
+ {
+ if (bindingToRemove == null)
+ return;
+ var list = bindings [bindingToRemove];
+ int refs;
list.Remove (command);
if (list.Count == 0)
- bindings.Remove (command.KeyBinding);
-
- if (!command.KeyBinding.Chord.IsEmpty && chords.ContainsKey (command.KeyBinding.Chord)) {
- if ((refs = chords[command.KeyBinding.Chord] - 1) == 0)
- chords.Remove (command.KeyBinding.Chord);
+ bindings.Remove (bindingToRemove);
+
+ if (!bindingToRemove.Chord.IsEmpty && chords.ContainsKey (bindingToRemove.Chord)) {
+ if ((refs = chords [bindingToRemove.Chord] - 1) == 0)
+ chords.Remove (bindingToRemove.Chord);
else
- chords[command.KeyBinding.Chord] = refs;
+ chords [bindingToRemove.Chord] = refs;
}
}