Re: [gtk-list] Dynamic Menu Help
- From: Raph Levien <raph acm org>
- To: "Thomas S. Urban" <urban animal blarg net>
- cc: gtk-list <gtk-list redhat com>
- Subject: Re: [gtk-list] Dynamic Menu Help
- Date: Tue, 9 Dec 1997 22:00:25 -0800 (PST)
On Tue, 9 Dec 1997, Thomas S. Urban wrote:
> Hi
>
> I am writing an app that will have multiple top level windows
> each with it's own menus. Some of these menus I will want to
> change during the execution of the program. The examples
> I have seen (including the gimp) seem to have static menus -
> correct me if I am wrong here. After browsing the
> gtkmenufactory header file, I notice a couple of functions
> that might allow me to add and subtract items from the
> menu:
>
> gtk_menu_factory_remove_paths (no ..._add_paths function)
> gtk_menu_factory_remove_entries
> gtk_menu_factory_add_entries
>
> I was wondering if anyone had any experience in this that
> they could share. Do these functions do what I suspect
> they do? If not, should the whole menu_items array
> be overwritten, the old menu destroyed, and the new
> menu created with the factory everytime I wish to modify
> the window structure?
I think these functions will work. One that doesn't yet is
gtk_menu_factory_remove_subfactory.
Deleting the whole menu and starting from scratch many be expensive,
especially if the menu is actually visible at the time of the change.
I ended up using menus directly in Gzilla, rather than using the menu
factory. One problem with menu factories is that individual menu labels
cannot contain the '/' character. I also needed to deal with dynamically
creating new windows, each with its own menu. I found that menus are not
actually difficult to program. The main thing I gave up is the .menurc
capability. If I found I needed that, I'd probably add capabilities to
menufactory to escape the '/' character when needed. (now that I've got
commit privileges in Gtk, I needn't be so careful to always do things in
a way that doesn't affect Gtk itself)
> Is it better to use multiple menu_item arrays such as
> window1_menu_item[], window2_menu_items, etc. rather than
> one large array like the gimp does?
Back when Gzilla was still using menufactory, it used both - a big array
for the static menus, and an array of size 1 for dynamically adding new
menu entries.
Best of luck!
Raph
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]