예제 #1
0
        static void InitApp(CommandManager commandManager)
        {
            if (initedApp)
            {
                return;
            }

            OSXMenu.AddCommandIDMappings(new Dictionary <object, CarbonCommandID> ()
            {
                { CommandManager.ToCommandId(EditCommands.Copy), CarbonCommandID.Copy },
                { CommandManager.ToCommandId(EditCommands.Cut), CarbonCommandID.Cut },
                //FIXME: for some reason mapping this causes two menu items to be created
                // { EditCommands.MonodevelopPreferences, CarbonCommandID.Preferences },
                { CommandManager.ToCommandId(EditCommands.Redo), CarbonCommandID.Redo },
                { CommandManager.ToCommandId(EditCommands.Undo), CarbonCommandID.Undo },
                { CommandManager.ToCommandId(EditCommands.SelectAll), CarbonCommandID.SelectAll },
                { CommandManager.ToCommandId(FileCommands.NewFile), CarbonCommandID.New },
                { CommandManager.ToCommandId(FileCommands.OpenFile), CarbonCommandID.Open },
                { CommandManager.ToCommandId(FileCommands.Save), CarbonCommandID.Save },
                { CommandManager.ToCommandId(FileCommands.SaveAs), CarbonCommandID.SaveAs },
                { CommandManager.ToCommandId(FileCommands.CloseFile), CarbonCommandID.Close },
                { CommandManager.ToCommandId(FileCommands.Exit), CarbonCommandID.Quit },
                { CommandManager.ToCommandId(FileCommands.ReloadFile), CarbonCommandID.Revert },
                { CommandManager.ToCommandId(HelpCommands.About), CarbonCommandID.About },
                { CommandManager.ToCommandId(HelpCommands.Help), CarbonCommandID.AppHelp },
            });

            //mac-ify these command names
            commandManager.GetCommand(EditCommands.MonodevelopPreferences).Text = GettextCatalog.GetString("Preferences...");
            commandManager.GetCommand(EditCommands.DefaultPolicies).Text        = GettextCatalog.GetString("Custom Policies...");
            commandManager.GetCommand(HelpCommands.About).Text        = GettextCatalog.GetString("About MonoDevelop");
            commandManager.GetCommand(ToolCommands.AddinManager).Text = GettextCatalog.GetString("Add-in Manager...");

            initedApp = true;
            OSXMenu.SetAppQuitCommand(CommandManager.ToCommandId(FileCommands.Exit));
            OSXMenu.AddAppMenuItems(
                commandManager,
                CommandManager.ToCommandId(HelpCommands.About),
                CommandManager.ToCommandId(Command.Separator),
                CommandManager.ToCommandId(EditCommands.MonodevelopPreferences),
                CommandManager.ToCommandId(EditCommands.DefaultPolicies),
                CommandManager.ToCommandId(ToolCommands.AddinManager));

            IdeApp.Workbench.RootWindow.DeleteEvent += HandleDeleteEvent;
        }
예제 #2
0
        public override bool SetGlobalMenu(CommandManager commandManager, string commandMenuAddinPath)
        {
            if (setupFail)
            {
                return(false);
            }

            try {
                InitApp(commandManager);
                CommandEntrySet ces = commandManager.CreateCommandEntrySet(commandMenuAddinPath);
                OSXMenu.Recreate(commandManager, ces, ignoreCommands);
            } catch (Exception ex) {
                try {
                    OSXMenu.Destroy(true);
                } catch {}
                MonoDevelop.Core.LoggingService.LogError("Could not install global menu", ex);
                setupFail = true;
                return(false);
            }

            return(true);
        }