the latest cellrenderer scoop



i just put Gtk2::CellRenderer::Base 0.04 on my website,
http://asofyet.org/muppet/software/gtk2-perl/Gtk2-CellRenderer-Base- 0.04.tar.gz

this version simplifies things rather a lot. The Gtk2::CellRenderer::Base class no longer actually exists. You do a normal Glib::Object::Subclass of Gtk2::CellRenderer or any of its derivatives, and then call __PACKAGE__->_install_overrides; this installs into the GObjectClass structure the perl marshallers which look for the on_get_size, on_render, on_activate, and on_start_editing subs.

you can call the parent from within your child subs by doing parent_foo instead of on_foo, like this:

  sub on_get_size {  shift->parent_get_size (@_)  }

that uses caller() to find the calling context, so it can find the parent of that package. (this hack is necessary because GObjects always show up as the bottom of the hierarchy.)


my only complaint about this version is the new syntax is ugly:

  use Glib::Object::Subclass ......;
  __PACKAGE__->_install_overrides;

it would be possible to create another pragma-like module to wrap that up for us, a la Glib::Object::Subclass, but i hesitate to do this because it most likely would entail duplicating Subclass.pm.

on the plus side, this is all self-contained -- everything is implemented in Base.xs, and could easily be dropped into Gtk2/xs/GtkCellRenderer.xs without any problems.


whatchoo think?

--
muppet <scott at asofyet dot org>




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