[gtkmm] [beginner question] Problems with menu, menu bar
- From: Daniel Perez Alcazar <danielpa wanadoo es>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: [gtkmm] [beginner question] Problems with menu, menu bar
- Date: Sat, 13 Jul 2002 12:48:45 CEST
Hi!
I need a menu bar in my program. The thing is that I get the menu bar, but
not the submenu when I press the menu bar entry. Pardon me if it's a too
silly question... I warned you, it's a "beginner question" ;-) 
I've attached the code.
Thanks,
Dani P.
<--------------- The main function ------------------->
#include <gtk--/main.h>
#include <gtk--/window.h>
#include <gtk--/box.h>
#include "nsMenu.h"
int main (int argc, char *argv[])
{
	Gtk::Main start(argc,argv);
	
	
	/////////// Creating the menu bar...////////////
	nsMenu menu;
	menu.show_all();
	/////////////////////////////////////////////////////////////	
	
	
	/////////// Putting all together ///////////////////
	Gtk::VBox main_packing_box(FALSE,0);
	main_packing_box.pack_start(menu,false,0);
	main_packing_box.show();
	////////////////////////////////////////////////////////////
	
	
	////////////////// Main window ///////////////////
	Gtk::Window window(GTK_WINDOW_TOPLEVEL);
	window.set_title("NetScout");
	window.set_policy(false,true,false);
	window.add(main_packing_box);
	window.show();
	///////////////////////////////////////////////////////////
	
	start.run();
	return(0);
}
<------------------------------------------->
<--------------- My menu class ----------------->
<<<<<<<<The header>>>>>>>>>>
#include <gtk--/menubar.h>
#include <gtk--/menu.h>
class nsMenu : public Gtk::MenuBar
{
	public: 
	nsMenu();
};
<<<<<<The implemetantion>>>>>>
#include "nsMenu.h"
nsMenu::nsMenu()
{
	using namespace Gtk; 
		
		
	//////////////////// The "file" menu //////////////////////
	Menu file_menu;
	MenuItem *root_file;
		root_file=manage(new MenuItem("File"));
				file_menu.append(*manage(new MenuItem("_Open")));
				file_menu.append(*manage(new MenuItem("_Save")));
		root_file->set_submenu(file_menu);
	///////////////////////////////////////////////////////////////////		
		
	
	//////////////////// The menu bar, mother of all menus
//////////////////////
	append(*root_file);
	//////////////////////////////////////////////////////////////////////////////////////////////////
	
	
}
<------------------------------------------------->
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]