On Sat, 23 Jan 1999, Alexander Larsson verbalised:

> On 22 Jan, Lars Clausen wrote:
>> 
>> For the object (middle button) menu, I'd like to always send along the
>> event, so the object can figure out e.g. a nearby handle or edge.  One
>> way to do this would be to wrap the normal callback and data up in a
>> structure that becomes data for a generic callback.  The generic
>> callback then calls the normal callback with its data and the event (in
>> fact, it might as well send the whole structure, including the callback
>> pointer, so the callback can modify itself).  Can you think of any
>> reason this would be a bad idea?  Any better implementation?
> 
> Umm, it's not *perfectly* clear what you mean. Lets try to decipher.
> First a few general comments about Dia's architecture: All control flows
> and events goes from the app to an object. An objects never
> asynchronously generates an event. (You seem to follow this, i just
> mention this.) Anoher important thing is that Objects don't know
> anything about windows. They just know about floating point
> coordinates in the diagram space.
> 
> Soo, lets see. Object menus it was. How do they get configured then.
> You press the middle button, if you hit an object you call an method
> like ObjectMenu *get_object_menu(Object *object, Point *point) which
> returns a structure describing all object-specific menu items and their
> callbacks. The app then creates a menu that combines the objects menu
> items and some (maybe) general menu items that's always there.
> A callback is registered for the menu items that proxies the callbacks
> so that they have a nicer argument list, no GtkWidget *, but instead
> something like object_callback(Object *, gpointer callback_data).
> 
> What about this? It seems quite close to what you suggested.

It is, very close.  I have made a registry, though it is based on the
ObjectType rather than Object, and allow the actual Object to give a
callback which can modify the menu (to, say, set toggles to correspond to
the settings of the object).  I guess that's all in get_object_menu().
The proxy (good name) would make the callbacks look like
object_callback(Object *, Point *clicked_point, gpointer callback_data)
where callback_data is what the Object supplied in the first place.
I was thinking of sending the event, but there isn't much other than the
point to know about, and the Object shouldn't have to transform that.

>> -Lars is beginning to understand why Gtk is well-liked.
> 
> Yeah, Dia is actually my first ever Gtk program, it's very easy to
> learn and work with.

Your first?  Have you been working much with GUIs before?  It is quite
well designed.

-Lars

-- 
Lars R. Clausen ([EMAIL PROTECTED])
A *real* smart bomb would call in sick, perhaps move to another country,
changing its name in the process, open a beach bar maybe and live out its
days in safe anonymity.                          -- Barry O'Neill in rhod

Reply via email to