Generic Menu - HELP!!



Data
~~~~
WinXP
MinGW (latest version)
Gtkmm (latest install)

I would like to create a generic Menu class which will display a Menubar with the well known choices; 'File', 'Edit', 'View', etc., etc., items as well as a Toolbar full of icons from 'Gtk::Stock'. This class will appear in every windows that my program will display through the use of subclasses.

However, going through the chapter 11 of the tutorial I have come to a problem, the Example class in the tutorial derives from Gtk::Window and later on packs everything into a Gtk::VBox, since I am creating just the Menu, to later add it to a Gtk::Window, I intent to derive the Menu class directly from Gtk::VBox. This is all good and dandy, however, in the tutorial the developer calls 'add_accel_group(m_refUIManager->get_accel_group());' from within the constructor of the Example class, this is ok for a class that derives from Gtk::Window like this one, but in my case it is imposible to call this method, since the parent classes of Gtk::VBox do not derive from Gtk::Window.
In an attempt to circumvent this problem I have written this method
const Glib::RefPtr<Gtk::AccelGroup>& Menu::getAccelGroup(){
   return this->RefUIManager->get_accel_group();
}
but this gives me a segmentation fault.

Ok, now that I have explain my intention and predicament I would like to ask the experts here to help me resolve this issue. Any body?!

Here is snip copy of my Menu class
Menu.hpp
~~~~~~~
class Menu :  public Gtk::VBox{
public:
       Menu(); //!Constructor
       virtual ~Menu() {} //! Destructor
       const Glib::RefPtr<Gtk::AccelGroup>& getAccelGroup();

protected:
       //Child widgets:
       Glib::RefPtr<Gtk::ActionGroup> RefActionGroup;
       Glib::RefPtr<Gtk::UIManager>   RefUIManager;
       Glib::RefPtr<Gtk::RadioAction> ChoiceOne, ChoiceTwo;
       virtual void onActionActivated();
}; //class

Menu.cpp

Menu::Menu(){
   //Create actions for menus and toolbars
   RefActionGroup = Gtk::ActionGroup::create();
   RefActionGroup->add( Gtk::Action::create("MenuFile", "_File") );
   RefActionGroup->add( Gtk::Action::create("New",  Gtk::Stock::NEW,
   "_New",
   "Create a new fle"),
   sigc::mem_fun(*this, &Menu::onActionActivated));

   RefUIManager = Gtk::UIManager::create();
   RefUIManager->insert_action_group(RefActionGroup);
}
void Menu::onActionActivated(){
 //some code
}
const Glib::RefPtr<Gtk::AccelGroup>& Menu::getAccelGroup(){
   return this->RefUIManager->get_accel_group();
}


--
___ _____ _____ _____ _ _____ __ _ _____ / | | _ \ | _ \ / _ \ | | / _ \ | \ | | | ____| / /| | | |_| | | |_| | | | | | | | | | | | | \| | | |__ / / | | | _ / | _ { | | | | | | | | | | | |\ | | __| / / | | | | \ \ | |_| | | |_| | | |___ | |_| | | | \ | | |___ /_/ |_| |_| \_\ |_____/ \_____/ |_____| \_____/ |_| \_| |_____|

ArbolOne.org specializes in Custom Web Site Design, Web Site Re Design, Web Site Template Modifications, Web Site Maintenance, Integration of Payment Gateways (API's), Database Applications, Custom Applications and much more.
Happiness has many doors, and when one of them closes another opens, yet we spent so much time looking at the one that is shut that we don't see the one that just opened.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]