Gtk & Perl




Hello folks. I've spent part of the past week writing a Perl 5 Gtk
extension module, to let Perl use Gtk (& Gdk). Much of it is operational,
and I'll probably release something to CPAN within a few days. In writing
the module, I've run across several issues with Gtk that I hope the
members of this list could either clarify, or possibly work towards
supporting in future versions of Gtk.

First, let me congratulate all of you, and the authors particularly, on
this library, which seems to bond quite well to Perl.

Anyhow, working from the 970606 release (is there a later one?):

 1. Reference counting seems to be inconsistently used in the Gdk objects
-- it seems reference counts are never incremented, and two decrements are
needed to free an object. Of course, I may well be misreading the code. 

 2. It would be useful for my Perl binding (and perhaps similar bindings
to other languages) if Gtk objects could be "destroyed", in the sense of
invoking a destroy message, without freeing themselves, on a selected
positive reference count. This would let a perl program retain a reference
to the Gtk object (and thereby let Perl automatically destroy the object
when the Perl reference is destroyed, instead of requiring manual
destruction) while letting the destroy signalling mechanism still operate.

 3. The signal mechanism has one great problem, for Perl, and for other
interpreters, I am sure: the GTK_POINTER type gives no information about
what _kind_ of types are desired. My Perl binding is quite careful to
always fully unpack Gtk's C structures into Perl native native structures
(and to prevent one type from being used where another was expected,)  but
this is unfortunately impossible when a GTK_POINTER argument is hit. My
suggestion would be to add additional values for all types used:

   GTK_PARAM_POINTER_GTK_STYLE
   GTK_PARAM_POINTER_GDK_EVENT
   GTK_PARAM_POINTER_INT
   etc.

Currently my code has to use an extremely tedious process of figuring out
exactly what signal occurred and matching that to code which knows the
appropriate pointer types. It would also be extremely useful to use a
similar approach for the various enumeration values. Instead of just
calling them GTK_PARAM_INT, call them GTK_PARAM_ENU_GtkWindowType, or
somesuch.

4. The "simple" mechanism for creating widgets and setting widget state
(accomplished by the _setv functions, among others) is quite difficult to
support cleanly from Perl, both because of the aforementioned type problem
for poitners, and because the user must use the original Gtk names even if
the rest of the library isn't exposed. It would help considerably if it
were possible to query a class for the list of args it supports, so the
Perl library could mediate access.


Well, that's my wish-list for now. 

Thanks for listening,
Ken
-- 
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)




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