Re: Show and Hide Menu Items



>From: Bobby King <bking321 charter net>
>
>How does one show and hide menu items? At various states of an
>application, I want only a specific subset of menu items to be visible
>(accessible). Each state is entered by selecting a specific menu item.

That must be a hard problem because I have not seen a good solution to
it. Until I come up with an elegant solution, I don't waste time
for writing messy code like others.

Here is what I have come up so far:

Keep a set of active menu items (and key and mouse operations). Go that
set through and turn on/off menu items (and KMO). For each state, write
a list of allowed menu items (and KMO). You may need to keep a separate
always-active set (like "New Window" which is always on). You may need to
have different groups, each group having one active state (like
a customable spline editor in two different editors: one group for
editors, another for splines).

Then when updating, make the set of active menu items empty, go through
all active states, and re-build the set of active menu items, and update
the menus.

It is a hierarchical system (main app --> editor --> subeditor).
Active sets could be pushed to a stack, but may need a stack for
each part of the application (like multiple editors in the same
window).

In a webbrowser, the parent script may forbid menu items to appear
in the child window. It might be we also need different set operations:
union, substraction.

It is a hard problem if anyone asks me. A good solution should be
a part of GTK.

The discussion could continue in gtk-devel-list.

Regards,
Juhana



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