menu separators



Since this may be a Gtk issue, I'm writing about it here. Don't let the
references to Bonobo fool you; the key is menus that are built up by
multiple clients (main code and a shared library, container and embedded
components), not Bonobo in particular.

In Bonobo, there are menus that are built up dynamically from a number of
different sources. When this happens, you run into situations where it's
hard to manage the separators properly. Here's an example. Let's say you
have the following:

    Connect
    Disconnect
    -
    Exit

Then you want to add some a command like this:

    Connect
    Disconnect
    -
    Change Password
    Synchronize
    -
    Exit

Bonobo has the concept of a menu placeholder, so it's easy for the container
to establish the place to add new menu items, but the code that adds the
Change Password and Synchronize items doesn't have a good way to know that
it needs to add a new separator. If you put a separator both before and
after the menu placeholder, then you'll have two separators in the original
menu, with no menu items between them.

One way to address this is to create a smarter GtkMenuItem object for the
separator. This separator would be completely invisible if the item before
it is a separator. As an additional feature, it could be invisible if it is
the first item in the menu, or if all items after it are separators. That
way, you could add extra separators as desired, but they would always show
up as a single horizontal line instead of multiple ones.

It's not too difficult to make a subclass of GtkMenuItem that works this way
(only a tiny bit tricky), but I was thinking that it might also be
reasonable behavior for the default GtkMenuItem in 2.0 to work this way. Is
it ever useful to have a two separators in a row, or a separator at the top
or bottom of a menu? If not, then this change would presumably do no harm.

Any advice on the best way to deal with separators for this kind of dynamic
menu situation? If we decide it's not sensible to make a Gtk change for
this, I may look into the possibility of making a Bonobo change instead.

    -- Darin






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