Esempio n. 1
0
        static Gtk.MenuItem CreateMenuItem(CommandManager manager, Command cmd, object cmdId, bool isArrayMaster, string overrideLabel, bool disabledVisible)
        {
            cmdId = CommandManager.ToCommandId(cmdId);
            if (cmdId == CommandManager.ToCommandId(Command.Separator))
            {
                return(new Gtk.SeparatorMenuItem());
            }

            if (cmd == null)
            {
                cmd = manager.GetCommand(cmdId);
            }

            if (cmd == null)
            {
                MonoDevelop.Core.LoggingService.LogWarning("Unknown command '{0}'", cmdId);
                return(new Gtk.MenuItem("<Unknown Command>"));
            }

            if (cmd is CustomCommand)
            {
                Gtk.Widget     child = (Gtk.Widget)Activator.CreateInstance(((CustomCommand)cmd).WidgetType);
                CustomMenuItem ti    = new CustomMenuItem();
                ti.Child = child;
                return(ti);
            }

            ActionCommand acmd = cmd as ActionCommand;

            if (acmd.ActionType == ActionType.Normal || (isArrayMaster && acmd.CommandArray))
            {
                return(new CommandMenuItem(cmdId, manager, overrideLabel, disabledVisible));
            }
            else
            {
                return(new CommandCheckMenuItem(cmdId, manager, overrideLabel, disabledVisible));
            }
        }
Esempio n. 2
0
		static Gtk.MenuItem CreateMenuItem (CommandManager manager, Command cmd, object cmdId, bool isArrayMaster, string overrideLabel, bool disabledVisible)
		{
			cmdId = CommandManager.ToCommandId (cmdId);
			if (cmdId == CommandManager.ToCommandId (Command.Separator))
				return new Gtk.SeparatorMenuItem ();
			
			if (cmd == null)
				cmd = manager.GetCommand (cmdId);

			if (cmd == null) {
				MonoDevelop.Core.LoggingService.LogWarning ("Unknown command '{0}'", cmdId);
				return new Gtk.MenuItem ("<Unknown Command>");
			}
			
			if (cmd is CustomCommand) {
				Gtk.Widget child = (Gtk.Widget) Activator.CreateInstance (((CustomCommand)cmd).WidgetType);
				CustomMenuItem ti = new CustomMenuItem ();
				ti.Child = child;
				return ti;
			}
			
			ActionCommand acmd = cmd as ActionCommand;
			if (acmd.ActionType == ActionType.Normal || (isArrayMaster && acmd.CommandArray))
				return new CommandMenuItem (cmdId, manager, overrideLabel, disabledVisible);
			else
				return new CommandCheckMenuItem (cmdId, manager, overrideLabel, disabledVisible);
		}