[gtkmm] Menu accel API review



(Note: See http://bugzilla.gnome.org/show_bug.cgi?id=87944 for reference)

Hi,

I didn't have as much time as I wanted last week for the menu API
review, so I finished it this week.

After playing around with different methods of accelerator
initialization, I think the way it is implemented right now is the
best for users of the gtkmm library. For Gtk::MenuBar and
Gtk::OptionMenu all is done automatically. The users only have to
specify the accelerator keys. Only accelerators of popup menus must be
initialized manually (reason follows).

What I've done last week:

I've cleaned up gtk/gtkmm/menu_elems.{h,cc}. It's much easier to read
and understand now.

I've fixed auto-accel-initialization for Gtk::MenuBar and
Gtk::OptionMenu. They should now initialize accelerators correctly
independently of is initialization/link order.

I've reverted Menu::popup() to its old state. You have to call
accelerate() manually for popup menus. One reason is, as someone also
mentioned, you don't always have a window pointer when calling
popup(). But most important, as the current implementation calls
accelerate in popup(), the accelerators do only work if the user
already has opened the popup with the mouse. Only then he can use the
keyboard shortcut. This would be very confusing for users.

Another API change I did was switching the accel_key and accel_mods
parameter in Gtk::Menu_Helpers::AccelKey because of consistency. All
other places in Gtk+ and Gtkmm use this order too.

The last item is accelerator paths. I can't think of a good way to
generate such a path automatically. The majority of gtk+ mailinglist
posts shows that this is a feature that is considered to be too
confusing for users. (That's why this feature is turned off in the
default settings.) With the current implementation the Gtkmm wrappers
allow to use accel paths if the developer wants to activate it. He has
to specify the accel path manually and has to use nearly the same
information that he has already used for generating the menu
itself. But a C developer using gtk+ would have to do the same if he
doesn't use gtkitemfactory. I've added a wrapper to GtkAccelMap
functionality to load and save accelerators that have been changed by 
the user.

The changelog entry is:
        * gtk/src/menu.{hg,ccg}: Revert to old popup() method.
        * gtk/src/menubar.{hg,ccg}: Connect auto acceleration init method
        to realize signal (again). This will show accelerators if
        the menubar is added to a window first, and menu items are added
        later.
        * gtk/src/optionmenu.{hg,ccg}: Use same mechanism to automatically
        initialize menu accelerators as in Gtk::MenuBar.
        * gtk/gtkmm/accelkey.{h,cc}: Switched accel_key and accel_mods
        parameter to be more consistent with the rest of the accel functions.
	* gtk/gtkmm/menu_elems.{h,cc}: Cleanup.
	* gtk/gtkmm/accelmap.{h,cc}: New wrapper for gtk+ functions.
        * demos/*, examples/*: Menu API changes.

Suggestions? Remarks? Is it OK to commit the changes?

 Andreas






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