Re: [gtk-list] guile-gtk and glib questions

On Tue, 4 Aug 1998, Peter C. Norton wrote:

> I'm trying to go through most of the gtk+ tutorial using guile-gtk, and
> there are some issues which are puzzling me:

You asked this about guile-gtk, but I'll answer for Perl/Gtk, as I think
it might be of interest.

> 1) I presume that a lot of the glib functions, like functions to
> manipulate lists, lists of lists, double-linked lists, etc. are directly
> translated to regular lists.  Is this right?

In Gtk/Perl, none of glib is exposed, in any real sense. While the glib
functions could be "translated" to work on Perl arrays, hashes, etc.,
there is little reason to do so, as Perl already has its own mechanisms
and habits.

As for Gtk functions that use glib data structures, they have all been
recoded to use standard Perl interface approaches -- I differ a bit from
the guile binding here, in that I've felt free to modify the interface to
Gtk functions to suit the binding.

> 2) What syntax should be used to access a memeber of a structure, i.e. 
> owner = GTK_TREE(tree)->tree_owner; 
> becomes ???

In Gtk/Perl, members of objects are not exposed using any standard member
syntax. Instead, accessor functions are supplied where Gtk itself supplies
them, and if it is evident that direct member access is needed, a custom
accessor function is added, so you would say:

	$tree->tree_owner; # to get the value


	$tree->tree_owner($foo); # to set the value

But this is done strictly on an ad hoc, as needed basis.

> 3) What are the equivelant of the gtk_object_* methods?

Well, Gtk::Object is the ancestory of all of the Perl/Gtk types, so many
of the methods are accessible in direct translations. set, get, and new
work essentially unchanged, just recoded to better meet Perl interface
standards. ref, and unref are supported (if I remember correctly) but only
to allow hacking, not out of need -- like Guile, Perl completely manages
memory allocation, including sink. 

Kenneth Albanowski (, CIS: 70705,126)

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