From: <aur...@wa...> - 2003-02-08 00:07:20
|
Le jeu 06/02/2003 =E0 10:49, arj...@he... a =E9crit : > The only special thing is the metaclass. I would like to hear (read) yo= ur opinion. First I have to state a few things : I'm quite new to - python, - C (as in not C++) - the whole Gnome Mess^H^H^H^H Framework So I may lack some of the required basics to understand what's really goi= ng on, and have to do some wild guesses... Also the fact that I work on MOPs the= se days will help a little wrt the metaclass stuff... About the metaclass : seems like a neat trick to automagically set up som= e=20 relations between any hand-made class definition of a compound graphical = thing and the underlying machinery. So : - gobject.type_register (new_class) helps declare a new hand-made class to the real C cruft under the hood I would like to know better, but the sources are vast... where to look = exactly ? DiaCanvas ? Glib ? I'll see that later. - dia.set_callbacks (new_class) - dia.set_groupable (new_class) depending on what superclass our class extends, so to speak In the case of MyBox, it's both. The exact semantics of 'set_callbacks' escapes me. Does it mean that the = instance is to handle callbacks ? (if so 'set_has_callbacks' would be better...) So I can't say it's real good or just plain ugly. _Seems_ working. Note about the garbage collection : Bad things happen (segfault in fact) when invoking the gc via the menu. Note that if you remove all the "del box, del my_box, etc..." from demo.p= y,=20 gcing won't do any harm anymore. This may be due to the=20 canvas.root.add(my_box2) not correctly reference-incrementing the instanc= e=20 first associated with my_box2... some C code not doing the Right Thing ? About selections : When I select object, I would like to rotate/transform the selection the = same=20 way I move it. Selecting objects really is a strange thing here. Maybe my anticipations are misplaced :-) ahhhhh, I just understood : being selected is not the same as being focus= ed. Seems quite unnatural to me.=20 So when I select 'my_box', it can happen that the text blurb has the focu= s. Then, "deleting the focused" sends the whole program to segfaultland - si= nce it shouldn't be possible to delete it but through the whole MyBox stuff. Synchronizing MyBox elements : I just added to the MyBox class : def on_rotate (self, x, y): self.text.request_update() self.ellipse.request_update () return dia.CanvasBox.on_rotate (self, x, y); it doesn't crash, it does nothing, not even update the small circle grouped with the box. Except for moves, the circle winds up being=20 updated AFTER the transformation in all cases. What I don't grok is why the text blurb rotates with the box, and not the circle.=20 Various iterator methods : def on_shape_next (self, iter): if iter is self.ellipse: return None iter =3D dia.CanvasBox.on_shape_next(self, iter) if iter is None: iter =3D self.ellipse return iter This boggles me down... really :-) It would be nice if we could write : self.add_construction(self.ellipse) then add=20 self.update_child(self.ellipse, affine) to def on_update (self, affine): dia.CanvasBox.on_update (self, affine) self.update_child(self.text, affine) But an ellipse appears not to be a CanvasItem. Is this really a good thin= g ? More broadly, I fail to see the connection between methods and their C couterparts (staring at dia-canvas-element.c doesn't help much). That will be all for today. Regards, Aur=E9lien. |