Re: Gtk::Menu label not showing up after the first time displaying menu



Your constructor clearly calls Gtk::Widget::show_all_children, thereby
generating an exposure event, but what of HangarDialog::updateComponents?


/*Bob Caryl*
Fiscal Systems,Inc.
256.772.8920 Ext. 108
http://www.fis-cal.com <http://www.fis-cal.com/>/

/This email message may contain privileged or confidential information.
If you are not the intended recipient, you may not disclose, use,
disseminate, distribute, copy or rely on this message or attachment in
any way. If you received this email message in error, please return by
forwarding the message and its attachment to the sender and then delete
the message and its attachment from your computer.

Neither Fiscal Systems, Inc., nor its affiliates, accept any liability
for any errors, omissions, corruption or virus in the contents of this
message or any attachments that arise as a result of e-mail transmission./



Jim Barnes wrote:
> Hi all,
> 
> I've having problems with Gtk::Menus and popup-menus not displaying their
> labels.  The first time that the menu is displayed, all menu labels are
> displayed properly. On subsequent displays of the menu, the popup window for
> the menu is displayed, but the window is missing the menu item labels.  When
> the mouse goes over the popup window, the labels show up one by one.  Even
> the separator lines are missing.
> 
> Here is a code snippet from my class.  Any help would be appreciated.
> 
> Thanks
> Jim
> 
> HangarDialog::HangarDialog()
>   : Gtk::Window(),
> ....
> {
>   // Set the window parameters.
>   set_title("Hangar");
>   set_resizable(true);
> 
>   const int border_width = 10;
>   set_border_width(border_width);
> 
>   // Initialize the list of dialogs to add models to the simulation.
>   add_model_dialogs[MODEL]          = 0;
>   add_model_dialogs[STATIC_MODEL]   = 0;
>   add_model_dialogs[PLAYBACK_MODEL] = 0;
> 
>   const int spacing = 5; // Spacing for formatting boxes.
> 
>   // Create the vertical packing box into which all objects will be placed.
>   main_box = new Gtk::VBox(false, spacing);
>   assume(main_box);
>   main_box->show();
>   add(*main_box);
> 
>   // Create the model_list that will be needed for the menu
>   model_list = new PositionalModelList;
> 
>   // Create the Menu interface
>   // Create a reference action group
>   ref_action_group = Gtk::ActionGroup::create();
> 
>   // Define the actions
>   ref_action_group->add(Gtk::Action::create("SimMenu", "_Simulation"));
>   ref_action_group->add(
>     Gtk::Action::create("SimControl",
>                         "Sim Control",
>                         "Modify simulation configuration."),
>     sigc::mem_fun(this, &HangarDialog::showSimControlDialog));
>   ref_action_group->add(
>     Gtk::Action::create("SimEnvironment",
>                         "Environment",
>                         "Modify the simulation environment."),
>     sigc::mem_fun(this, &HangarDialog::showEnvironmentDialog));
> 
>   ref_action_group->add(
>     Gtk::Action::create("SimClose",
>                         "Close Hanger", "Close this dialog."),
>     sigc::mem_fun(this, hide));
> 
> (bunch more menus.....)
> 
>   ref_action_group->add(Gtk::Action::create("HelpMenu", Gtk::Stock::HELP,
> "Help"));
> 
>   // Create a ui_manager
>   ui_manager = Gtk::UIManager::create();
> 
>   // Insert the the ActionGroup
>   ui_manager->insert_action_group(ref_action_group);
> 
>   // Layout the actions in a menubar
>   try
>   {
>     Glib::ustring ui_info =
>       "<ui>"
>       "  <menubar name='Menubar'>"
>       "    <menu action='SimMenu'>"
>       "      <menuitem action='SimControl'/>"
>       "      <menuitem action='SimEnvironment'/>"
>       "      <separator/>"
>       "      <menuitem action='SimClose'/>"
>       "    </menu>"
>       "    <menu action='ModelsMenu'>"
>       "      <menu action='ModelsAddMenu'>"
>       "        <menuitem action='AddModel'/>"
>       "        <menuitem action='AddPlayback'/>"
>       "        <menuitem action='AddStatic'/>"
>       "        </menu>"
>       "      <menuitem action='ModelsDelete'/>"
>       "    </menu>"
>       "    <menu action='HardwareMenu'>"
>       "      <menuitem action='HardwareDrivers'/>"
>       "      <menuitem action='HardwareInterfaces'/>"
>       "      <menuitem action='HardwareChangeSelected'/>"
>       "    </menu>"
>       "    <menu action='HelpMenu'>"
>       "    </menu>"
>       "  </menubar>"
>       "</ui>";
> 
>     ui_manager->add_ui_from_string(ui_info);
>   }
>   catch ( const Glib::Error& ex)
>   {
>     string error = "Buiding Menu Bar faild: " + ex.what();
>     TerminalIO::applicationError("PlotMenuBarFactory::PlotMenuBarFactory()",
>                                  error.c_str(), false, true);
>   }
> 
>   // Add the menubar to the vbox
>   Gtk::Widget* menu_bar = ui_manager->get_widget("/Menubar");
> 
>   if (menu_bar)
>   {
>     main_box->pack_start(*menu_bar, Gtk::PACK_SHRINK);
>   }
> 
> ...
> 
>   show_all_children();
> 
>   // Every 10 ms update the components of this dialog.
>   const int update_period_in_milliseconds = 10;
>   Glib::signal_timeout().
>     connect(sigc::mem_fun(this, &HangarDialog::updateComponents),
>             update_period_in_milliseconds);
> }
> 
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 
> 



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