RE: [gtkmm] Newbie questions about changing menus and RefPtr
- From: Murray Cumming Comneon com
- To: pmazoy free fr, gtkmm-list gnome org
- Subject: RE: [gtkmm] Newbie questions about changing menus and RefPtr
- Date: Thu, 17 Apr 2003 15:09:47 +0200
> From: Pierre Mazoyer [mailto:pmazoy free fr]
> I would like to replace a menu item by another one.
Of course that is generally considering poor UI design. It's probably best
to have 2 menu items, one of which is disabled. It certainly looks like that
in this case.
> To achieve this result, I thought deleting the menu item and
> then create the
> new one at the same place.
> But I have some problems with the delete task.
>
> I found two ways to do it:
>
> (My menu is menu_Game, it contains "New Game Ctrl+N", a
> separator, "Quit
> Ctrl+Q"; I want to change "New Game Ctrl+N" to "Stop Game",
> with a new handler)
>
> Gtk::Menu_Helpers::MenuList::type_base::iterator i =
You shouldn't need the type_base there. In fact,
Gtk::Menu::MenuList::iterator should work too.
> menu_Game.items().begin();
> i = menu_Game.items().erase(i);
> menu_Game.items().insert(i,
> Gtk::Menu_Helpers::MenuElem("_Stop Game", SigC::slot
> (*this, &GameWindow::stopGame)));
>
> OR
>
> menu_Game.items().remove(menu_Game.items()[0]);
> menu_Game.items().push_front(Gtk::Menu_Helpers::MenuElem("_Sto
> p Game",
> SigC::slot(*this, &GameWindow::stopGame)));
>
> (The first way seems better to me because it could work even
> if the item was in
> the middle of the menu)
>
> In both cases, the menu is changed and I can select the new
> item (Stop Game)
> but if I press Ctrl+N, I can still execute the previous one
> (New Game)!
That sounds like a bug. I think you should add a bugzilla bug. Bugs are
dealt with more quickly if you _attach_ a simple-as-possible test case in
bugzilla too.
> I have a quick question about RefPtr
Please do keep it to one question per email thread.
> which is unrelated with
> the previous one.
> If I create a RefPtr, assign an gtkmm object to it and then
> reassign another
> object, will the first object be deleted?
RefPtr doesn't delete anything. It just unreferences things. GTK+ might
delete it if that was the last reference.
> I am a newbie with gtkmm, sorry in advance if my questions
> sound silly to you.
Not at all.
Murray Cumming
murrayc usa net
www.murrayc.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]