[gtkmm] How to change the label of a MenuElem?



Hello,
 
I try to implement a way to dynamicaly change the language for the entire application.
I use an awfull method: clear the menu items then recreate the whole menu with the new label.
It is working perfectly but ugly code allways have limits. In that case with ImageMenuElem: at runtime I got
a assertion failed error ("you try to realize a widget that is not in a toplevel window", or something like that). 
How can I fix it?
 
here's the code:
 
Interface::Interface()
: mImage(Gtk::Stock::QUIT, Gtk::ICONSIZEMENU)
{
........

 mMenuFile.items().pushback(
Gtk::MenuHelpers::ImageMenuElem("titi", Gtk::MenuHelpers::AccelKey("<Control>q"), mImage, slot(*this,  &Interface::onmenufilequit) ) );

......
 showallchildren();
}


void Interface::onlangchanged()
{
........
 mMenuFile.items().clear();
 mMenuFile.items().pushback( Gtk::MenuHelpers::ImageMenuElem("tata", Gtk::MenuHelpers::AccelKey("<Control>q"), mImage, slot(*this, &Interface::onmenufilequit) ) );
.......
}
Thanks


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