1. EuGTK: menus, submenus...

Hello,

I would like to add a submenu with the menuitems "template", "script", "text file", "project", "source code file" to the menuitem "New". How can I do it? I would also like to add an icon to the right of menu item "New" (an arrow i.e) to show that it contains a submenu.

constant menu_main_ide = create(GtkMenuBar)  
	pack(panel_main_ide,menu_main_ide) 
 
constant menuitem1_main_ide = create(GtkMenuItem,"_File"), 
 filemenu = create(GtkMenu), 
	filenew	= create(GtkMenuItem,"New","Fnew"), 
	fileopen = create(GtkMenuItem,"Open","Fopen"), 
	fileclose = create(GtkMenuItem,"Close","Fclose"), 
	fileprint = create(GtkMenuItem,"Print","Fprint"), 
	filerun = create(GtkMenuItem,"Execute","Frun"), 
	fileexit = create(GtkMenuItem,"Quit","Quit") 
 
	set(fileclose,"sensitive",FALSE) 
	set(filerun,"sensitive",FALSE) 
	set(filemenu,"append",fileopen) 
	set(filemenu,"append",fileclose) 
	set(filemenu,"append",create(GtkSeparatorMenuItem)) 
	set(filemenu,"append",filerun) 
	set(filemenu,"append",create(GtkSeparatorMenuItem)) 
	set(filemenu,"append",fileexit) 
	set(menuitem1_main_ide,"submenu",filemenu) 
	set(menu_main_ide,"append",menuitem1_main_ide) 

thank you, Raúl

new topic     » topic index » view message » categorize

2. Re: EuGTK: menus, submenus...

In the next example I try the following:

constant menuitem2_main_ide = create(GtkMenuItem,"_Project"), 
 projectmenu = create(GtkMenu), 
	projectnew	= create(GtkMenuItem,"New","Pnew"), 
	projectopen = create(GtkMenuItem,"Open","Popen"), 
	projectsave = create(GtkMenuItem,"Save","Psave"), 
	projectclose = create(GtkMenuItem,"Close","Pclose"), 
	projectrun = create(GtkMenuItem,"Execute/Run EUI","Prun"), 
	projectdebug = create(GtkMenuItem,"Debug/Trace","Pdebug"), 
	projectcheck = create(GtkMenuItem,"Check","Pcheck"), 
	projectshroud = create(GtkMenuItem,"Shroud...","Pshroud"), 
	projectbind = create(GtkMenuItem,"Bind...","Pbind"), 
	projecttranslate = create(GtkMenuItem,"Translate to C","Ptranslate_to_c"), 
	--projectcompile = create(GtkMenuItem,"Compile...","Pcompile"), 
	projectconfig = create(GtkMenuItem,"Configuration","Pconfiguration") 
 
       constant submenuitem1_menu_main_ide = create(GtkMenuItem,"_Compile..."), 
 	projectcompile = create(GtkMenu), 
	projectcompileasexe = create(GtkMenuItem,"Compile as executable","Pcompileasexe"), 
	projectcompileaslib = create(GtkMenuItem,"Compile as *.so library","Pcompileaslib"), 
	projectcompileaswinexe = create(GtkMenuItem,"Cross-Compile as executable ","Pcompileaswinexe"), 
	projectcompileaswinlib = create(GtkMenuItem,"Cross-Compile as *.dll library","Pcompileaswinlib") 
 
	set(projectclose,"sensitive",FALSE) 
	set(projectrun,"sensitive",FALSE) 
	set(projectsave,"sensitive",FALSE) 
	set(projectdebug,"sensitive",FALSE) 
 
	set(projectmenu,"append",projectnew) 
	set(projectmenu,"append",projectopen) 
	set(projectmenu,"append",projectsave) 
	set(projectmenu,"append",projectclose) 
	set(projectmenu,"append",create(GtkSeparatorMenuItem)) 
	set(projectmenu,"append",projectrun) 
	set(projectmenu,"append",projectdebug) 
	set(projectmenu,"append",projectcheck) 
	set(projectmenu,"append",create(GtkSeparatorMenuItem)) 
	set(projectmenu,"append",projectshroud) 
	set(projectmenu,"append",projectbind) 
	set(projectmenu,"append",projecttranslate) 
	set(projectmenu,"append",projectcompile) 
	set(projectmenu,"append",create(GtkSeparatorMenuItem)) 
	set(projectmenu,"append",projectconfig) 
	set(menuitem2_main_ide,"submenu",projectmenu) 
	set(menu_main_ide,"append",menuitem2_main_ide) 
 
	set(projectcompile, "append", projectcompileasexe) 
	set(projectcompile, "append", projectcompileaslib) 
	set(projectcompile,"append",create(GtkSeparatorMenuItem)) 
	set(projectcompile, "append", projectcompileaswinexe) 
	set(projectcompile, "append", projectcompileaswinlib) 
	set(projectmenu,"submenu", projectcompile) 
	set(menuitem2_main_ide,"append", submenuitem1_menu_main_ide) 

but I get an error message:

Error. Can't find method set_submenu for GtkMenu. Open property browser?

new topic     » goto parent     » topic index » view message » categorize

3. Re: EuGTK: menus, submenus...

The following error appears in the console:

GtkEngine.e:204 in function lookup_method() subscript value 0 is out of bounds, reading from a sequence of length 11

new topic     » goto parent     » topic index » view message » categorize

4. Re: EuGTK: menus, submenus...

 constant submenu1 = create(GtkMenu) 
	set(fileopen,"submenu",submenu1) 
	 
	constant  
		sub1 = create(GtkMenuItem,"Template","do_template"), 
		sub2 = create(GtkMenuItem,"Script","do_script") 
		set(submenu1,"append",sub1) 
		set(submenu1,"append",sub2)	 

When you attach a new menu to a menu item (in this case, to the fileopen item), it adds a right arrow to the menu caption. Then you populate the new menu with items, same as for the main menu.

BTW: I've updated EuGTK with the Aug.1 version: https://sites.google.com/site/euphoriagtk/Home

new topic     » goto parent     » topic index » view message » categorize

5. Re: EuGTK: menus, submenus...

I am doing something wrong and I don't see it.

I get the following error message: Gtk-CRITICAL : gtk_menu_shell_insert: assertion `GTK_IS_MENU_ITEM (child)' failed.

new topic     » goto parent     » topic index » view message » categorize

6. Re: EuGTK: menus, submenus...

Solved!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu