Re: [gtk-list] Re: Menus in GTK--




> Tero Pulkkinen wrote:
> > testgtkmm example coming with gtk-- package has example of a
> > menu. (using menufactory)
> > (you should upgrade to 0.9.2 - the 0.9.1. version is completely
> > broken - for example testgtkmm example didnt work :)

Angel Jimenez Jimenez <ajimenez@vnet.es> writes:
>  I thought menufactory were broken, so I was trying menus in "the hard
> way". I hace installed 0.9.2, and now I have my menu (part of it)
> working using menufactory. But I'm having some troubles with it.

Yes, menufactory is not as useful as it could be - and its clumsy to use,
because of need of static functions as callbacks :(

>  I want to add/remove entries dynamically to the menu. I have seen code,
> and seems easy to do, but, how do I change callback and user data
> associated to a given menu entry? Do I have to remove and insert a new
> one?

Yes. remove_entries() and add_entries().

>  I have several windows, all with the same menu. When I select some
> option in the menu, it calls the callback function associated with it. I
> want this function to make some action on the owner window. How can I do
> this? I could pass a pointer to this window in the user data, but then
> creating the menu would be much harder (I would have to set this pointer
> in each entry after creating the menu).

You probably want to put some context structure to the user_data field and
that would have information needed to access right window.

>  Is it possible to set a method callback instead of a function callback
> in the menu factory? This could make some things easier (although not
> much).
 
make static callback function, pass information to it in user data and then
call member functions from there.

This isnt the worlds easiest way to do it, but until we get it fixed, its the
easiest one..

the hard way of doing menus is there too, but maintaining the list of
menus in an application using that results to quite bad maintainance
problem. There's no examples that I know of doing it in hard way.. (maybe
digging some gtk sources/documentation might help with that tho)

>  Finally, an unrelated (and probably stupid) question: Is FileSelection
> dialog supossed to be modal, or non-modal? Why?

modal dialogs are evil. If you want application modal dialog, you can
do it with Gtk_Main::grab_add() and calling Gtk_Main::run() and then
doing Gtk_Main::grab_remove().

Of course it depends on your application. If selecting file is part of some
atomic operation, then you want to use modal, otherwise its better have it
non-modal. (modal dialogs are pain in the ass for the users - but sometimes
its easiest way to disable operations when they must not get invoked while
a dialog is in screen..) (save_as dialog while user already requested quit
from application should certainly be modal. things like layers or brush
selection dialogs in gimp should never be modal..)

-- 
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --



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