On Apr 9, 2007, at 10:42 AM, bulia byak wrote:

This needs to be solved not only for these two commands but for ALL

commands (verbs). Each verb must have a way to find out if this verb

is currently available, and the menus/buttons must display that status

by graying out unavailable commands. The person to contact about that

is Ted Gould; he started some work in that direction but it's not yet

finished. Ted, can you give an update on what's needed to make this

possible?


This actually touches on some of the changes I've been doing, and carrying on of what Ted started.

And interestingly enough, it also is key to getting the stock toolbars and dynamic UI going.


What we want to do is abstract the business logic of the program and decouple it from the UI directly. This is the general approach of the Model View Controller design pattern.

In this case, we have 'verbs' as one Model/business object, and the UI widgets as the Controls and Views. Ted had done a fair bit of work getting to SPAction under src/helper/action.h

To make the things work for dynamic UI and stock toolbars I'd been shifting things to use stock GtkActions and their subclasses. In fact, as soon as I commit src/widgets/select-toolbar.cpp you'll get an example of how to grab a SPAction and hook up a proper GtkAction to it.

First pass will get the proper icon, label, tootip, etc. and create the action with those. Also it will chain the triggering of the GtkAction to the proper SPAction.

Next pass will be to reflect state changes of the given SPAction and pass those onto the GtkAction(s). One thing to check now, however, would be if the SPAction for "Save" currently gets updated. If not, then that would be the place to hook the functional changes in.

One note on views, though. A given SPAction is bound to a single view, whereas a verb is global. If you have some UI that might apply to more than a single view, you'll need to track changes to active view and not hold an SPAction directly. The layers dialog code does this, and can be looked to for help.