[RFC] rework of Gtk2::CellRenderer derivation



the attached patches to Glib-1.033 and Gtk2-1.033 rework the derivation
handling for Gtk2::CellRenderers.

specifically, they propose a new approach to virtual functions on
GObjects, to make them more perlish.

in my honest opinion, the current method is a broken prototype, and this
new method is how it should've been in the first place.  part of the
motivation here is to get the syntax and methodology to be correct and
universal, as there will be more and more places in gtk+ which require
us to override virtual functions not accompanied by signals.  i'd like
your comments on this, as we have very little time to ratify, but i
think this is finally Right.


currently, you must call __PACKAGE__->_install_overrides after
registering your new class, and then you provide implementations for
on_get_size, on_render, etc; chaining up to parent classes is achieved
by calling parent_get_size, parent_render_etc.

with the attached patches, Glib::Type::register_object (the workhorse
behind Glib::Object::Subclass) looks for and calls if available a method
named _INSTALL_OVERRIDES after registering and creating the new type. 
this method may be inherited from parent classes just like
_install_overrides; its purpose is to provide a fully automatic
mechanism for any other objects which need to install vfunc overrides. 
(there will be more of these in the future of gtk+ and gtk2-perl.)
        the vfuncs installed by _INSTALL_OVERRIDES marshal to GET_SIZE, RENDER,
ACTIVATE, and START_EDITING, which are inheritable.  the perl code in a
derived class may simply call SUPER::foo to get to the parent class'
foo, just like normal perl.


thus, the differences are:
- installation of overrides is automatic
- use inheritable ALL_CAPS_NAMES instead of freaky and bizarre 
  non-inheritable on_foo and parent_foo.


these patches bend around backwards to preserve compatibility with code
using the old methodology, so code written for 1.03x will still work
with 1.04x (albeit with warnings about deprecation as, currently
written).


note that only the t-dir test and cellrenderer_popup example have been
modernized in the patch.  when applied, all the code will be adjusted,
and references to the old stuff will be wiped properly.

Attachment: glib-installoverrides.patch
Description: Text Data

Attachment: gtk2-cellrenderer.patch
Description: Text Data



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