[MonoDevelop] Problem extending the project/folder context menu for "Class Wizard"

Christian Hunke Chris_hunke at web.de
Sun Dec 28 06:20:22 EST 2008


Hi,

i want to help MonoDevelop an thought of just trying the sample of new functionality from the Small Tasks "Class Wizard". Just got the source from SVN, compiles fine etc. Now i tried to add my new GtkDialog into the context menu of projects and folders, so i did the following:

Added this to the "MonoDevelop.GtkCore.addin.xml" to define my new command:
		<Command id = "MonoDevelop.GtkCore.GtkCommands.AddNewClass"
				icon = "md-gtkcore-dialog"
				_label = "New Class..." />

Now i added this command to the project and folder add commands:
<Extension path = "/MonoDevelop/Ide/ContextMenu/ProjectPad/Project/Add">
		<SeparatorItem insertafter = "MonoDevelop.Ide.Commands.ProjectCommands.AddFiles" />
		<CommandItem id = "MonoDevelop.GtkCore.GtkCommands.AddNewClass" />

Of course i added the command also to the enum:
public enum GtkCommands
	{
		AddNewDialog,
		AddNewWindow,
		AddNewWidget,
		AddNewActionGroup,
		ImportGladeFile,
		EditIcons,
		GtkSettings,
		AddNewClass
	}

Then i extended the "UserInterfaceCommandHandler" class inside of "ProjectFolderNodeBuilderExtension.cs" with the following two methods to provide my context menu item functionality:
[CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewClass)]
		public void AddNewClassToProject()
		{
			DotNetProject project = CurrentNode.GetParentDataItem (typeof(Project), true) as DotNetProject;
			if (project == null)
				return;
			
			object dataItem = CurrentNode.DataItem;
			
			ProjectFolder folder = CurrentNode.GetParentDataItem (typeof(ProjectFolder), true) as ProjectFolder;
						
			string path;
			if (folder != null)
				path = folder.Path;
			else
				path = project.BaseDirectory;
			
			IdeApp.ProjectOperations.CreateClass(project, path);
		}
		
		[CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewClass)]
		public void UpdateAddNewClassToProject (CommandInfo cinfo)
		{
			cinfo.Visible = true;
		}

So I also added the "CreateClass" method that calls my dialog etc. but i think that is not interesting now.

My problem is that my "New Class..." menu item gets displayed correctly and even works fine BUT all other menu items for dialogs are gone and the order seems to be messed up :( Here is an image (sorry its German but I hope you will recognize it):
http://img156.imageshack.us/my.php?image=newclasscontextmenuie2.png

Can someone help me with that problem, please?

Regards
Christian Hunke


More information about the Monodevelop-list mailing list