diff options
author | Lluis Sanchez <slluis.devel@gmail.com> | 2014-06-19 22:25:12 +0400 |
---|---|---|
committer | Lluis Sanchez <slluis.devel@gmail.com> | 2014-06-19 22:25:12 +0400 |
commit | 3341e4ccaee4a1118bd726aaedf26159325c662b (patch) | |
tree | d5e9b76ad93608c340725b137bbe1995faeabbda | |
parent | 61787ffe7669a5eb087b28afa81d2fc849ebbf45 (diff) | |
parent | a0ec6f6add3e3f5c73b76a19a363458f28e3090d (diff) |
Merge pull request #601 from mono/fix_20683
Fix 20683
7 files changed, 21 insertions, 17 deletions
diff --git a/main/src/addins/MacPlatform/MacMenu/MDMenu.cs b/main/src/addins/MacPlatform/MacMenu/MDMenu.cs index c181434c06..6a10f51b51 100644 --- a/main/src/addins/MacPlatform/MacMenu/MDMenu.cs +++ b/main/src/addins/MacPlatform/MacMenu/MDMenu.cs @@ -38,7 +38,7 @@ namespace MonoDevelop.MacIntegration.MacMenu { static readonly string servicesID = (string) CommandManager.ToCommandId (MacIntegrationCommands.Services); - public MDMenu (CommandManager manager, CommandEntrySet ces) + public MDMenu (CommandManager manager, CommandEntrySet ces, CommandSource commandSource, object initialCommandTarget) { this.WeakDelegate = this; @@ -59,7 +59,7 @@ namespace MonoDevelop.MacIntegration.MacMenu var subset = ce as CommandEntrySet; if (subset != null) { - AddItem (new MDSubMenuItem (manager, subset)); + AddItem (new MDSubMenuItem (manager, subset, commandSource, initialCommandTarget)); continue; } @@ -86,7 +86,7 @@ namespace MonoDevelop.MacIntegration.MacMenu continue; } - AddItem (new MDMenuItem (manager, ce, acmd)); + AddItem (new MDMenuItem (manager, ce, acmd, commandSource, initialCommandTarget)); } } diff --git a/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs b/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs index 2ab9ed4e5e..94a8289bda 100644 --- a/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs +++ b/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs @@ -45,11 +45,15 @@ namespace MonoDevelop.MacIntegration.MacMenu CommandManager manager; bool isArrayItem; + object initialCommandTarget; + CommandSource commandSource; - public MDMenuItem (CommandManager manager, CommandEntry ce, ActionCommand command) + public MDMenuItem (CommandManager manager, CommandEntry ce, ActionCommand command, CommandSource commandSource, object initialCommandTarget) { this.ce = ce; this.manager = manager; + this.initialCommandTarget = initialCommandTarget; + this.commandSource = commandSource; isArrayItem = command.CommandArray; @@ -66,9 +70,9 @@ namespace MonoDevelop.MacIntegration.MacMenu //if the command opens a modal subloop, give cocoa a chance to unhighlight the menu item GLib.Timeout.Add (1, () => { if (a != null) { - manager.DispatchCommand (ce.CommandId, a.Info.DataItem, CommandSource.MainMenu); + manager.DispatchCommand (ce.CommandId, a.Info.DataItem, initialCommandTarget, commandSource); } else { - manager.DispatchCommand (ce.CommandId, CommandSource.MainMenu); + manager.DispatchCommand (ce.CommandId, null, initialCommandTarget, commandSource); } return false; }); @@ -84,7 +88,7 @@ namespace MonoDevelop.MacIntegration.MacMenu public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index) { - var info = manager.GetCommandInfo (ce.CommandId); + var info = manager.GetCommandInfo (ce.CommandId, new CommandTargetRoute (initialCommandTarget)); if (!isArrayItem) { SetItemValues (this, info); @@ -148,10 +152,10 @@ namespace MonoDevelop.MacIntegration.MacMenu public CommandInfo Info; } - static void SetItemValues (NSMenuItem item, CommandInfo info) + void SetItemValues (NSMenuItem item, CommandInfo info) { item.SetTitleWithMnemonic (GetCleanCommandText (info)); - item.Enabled = !IsGloballyDisabled && info.Enabled; + item.Enabled = info.Enabled && (!IsGloballyDisabled || commandSource == CommandSource.ContextMenu); item.Hidden = !info.Visible; SetAccel (item, info.AccelKey); diff --git a/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs b/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs index 84de750319..547d788ec5 100644 --- a/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs +++ b/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs @@ -34,11 +34,11 @@ namespace MonoDevelop.MacIntegration.MacMenu { CommandEntrySet ces; - public MDSubMenuItem (CommandManager manager, CommandEntrySet ces) + public MDSubMenuItem (CommandManager manager, CommandEntrySet ces, CommandSource commandSource = CommandSource.MainMenu, object initialCommandTarget = null) { this.ces = ces; - this.Submenu = new MDMenu (manager, ces); + this.Submenu = new MDMenu (manager, ces, commandSource, initialCommandTarget); this.Title = this.Submenu.Title; } diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs index 47f89932f9..8800f13819 100644 --- a/main/src/addins/MacPlatform/MacPlatform.cs +++ b/main/src/addins/MacPlatform/MacPlatform.cs @@ -203,12 +203,12 @@ namespace MonoDevelop.MacIntegration return map; } - public override bool ShowContextMenu (CommandManager commandManager, Gtk.Widget widget, double x, double y, CommandEntrySet entrySet) + public override bool ShowContextMenu (CommandManager commandManager, Gtk.Widget widget, double x, double y, CommandEntrySet entrySet, object initialCommandTarget = null) { Gtk.Application.Invoke (delegate { // Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event Gdk.Pointer.Ungrab (Gtk.Global.CurrentEventTime); - var menu = new MDMenu (commandManager, entrySet); + var menu = new MDMenu (commandManager, entrySet, CommandSource.ContextMenu, initialCommandTarget); var nsview = MacInterop.GtkQuartz.GetView (widget); var toplevel = widget.Toplevel as Gtk.Window; int trans_x, trans_y; 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 3421602a1a..d83f3a6e54 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs @@ -709,7 +709,7 @@ namespace MonoDevelop.Components.Commands { if (Platform.IsMac) { parent.GrabFocus (); - return DesktopService.ShowContextMenu (this, parent, evt.X, evt.Y, entrySet); + return DesktopService.ShowContextMenu (this, parent, evt.X, evt.Y, entrySet, initialCommandTarget); } else { var menu = CreateMenu (entrySet); if (menu != null) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs index 5b8f3462c1..42b5deb2e8 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs @@ -329,7 +329,7 @@ namespace MonoDevelop.Ide.Desktop } public virtual bool ShowContextMenu (MonoDevelop.Components.Commands.CommandManager commandManager, - Gtk.Widget widget, double x, double y, MonoDevelop.Components.Commands.CommandEntrySet entrySet) + Gtk.Widget widget, double x, double y, MonoDevelop.Components.Commands.CommandEntrySet entrySet, object initialCommandTarget = null) { return false; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs index a5cdbf6fc8..86a1e89470 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs @@ -200,9 +200,9 @@ namespace MonoDevelop.Ide } public static bool ShowContextMenu (MonoDevelop.Components.Commands.CommandManager commandManager, - Gtk.Widget widget, double x, double y, MonoDevelop.Components.Commands.CommandEntrySet entrySet) + Gtk.Widget widget, double x, double y, MonoDevelop.Components.Commands.CommandEntrySet entrySet, object initialCommandTarget = null) { - return PlatformService.ShowContextMenu (commandManager, widget, x, y, entrySet); + return PlatformService.ShowContextMenu (commandManager, widget, x, y, entrySet, initialCommandTarget); } public static bool SetGlobalMenu (MonoDevelop.Components.Commands.CommandManager commandManager, |