On 23 Jan, Lars Clausen wrote:
>> 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.
Uhm.. You mean this:
An object type when loaded creates it's own object menu. This contains
callbacks to functions that are supposed to be called when the item on
the menu is selected. When a callback is called it might change the
menu and it gets the point where the user pop:ed up the menu.
How can i in this model change the menu depending on where i click?
Like if i click near the line i get a menu-item 'add control-point'
which is otherwise not there or inactive?
>> 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.
I haven't worked much with gui programming. It doesn't really excite me.
I've done some very small gui stuff in windows and a bit more in Java
(AWT).
/ Alex