Re: converting from gtk2-perl to gtk2-perl-xs (work in progress)
- From: "muppet" <scott asofyet org>
- To: <gtk-perl-list gnome org>
- Subject: Re: converting from gtk2-perl to gtk2-perl-xs (work in progress)
- Date: Mon, 7 Jul 2003 11:14:58 -0400 (EDT)
Thierry Vignaud said:
s/Gtk2->exit/Gtk2::exit/g;
gtk_exit is deprecated, and even worse, doesn't let perl clean up. don't use
it.
s/Gtk2->init(\/Gtk2->init(/g;
in 95% of cases you'll want to do
use Gtk2 -init;
a la old gtk-perl, because it's a small portion of the time that you want to
make sure things are okay before initializing Gtk. (not "never", just not so
often.)
the inline-based gtk2-perl required you to pass argv, as Gtk2->init(\ ARGV);
--- gtk2-perl-xs doesn't need to you pass anything, as it looks automatically
at @main::ARGV.
s/Gtk2::Menu->get_type/"Gtk2::Menu"/g;
s/Gtk2::MenuBar->get_type/"Gtk2::MenuBar"/g;
s/Gtk2::GType->OBJECT/"Gtk2::Gdk::Pixbuf"/g;
s/Gtk2::GType->STRING/"Glib::String"/g;
s/Gtk2::GType->INT/"Glib::Int"/g;
said more succinctly, the GType concept is completely hidden from the perl
developer by the bindings, replaced completely by the perl package name. in
practice, GTypes are needed only in two places: as the parent type when
registering a new GObject subclass, and more commonly for specifying the
column types of a GtkTreeModel.
s/Gtk2::Pango->PANGO_PIXELS/Gtk2::Pango->pixels/g;
# Pango constants are pain in the ass to get
just 'use Gtk2::Pango' -- this will export to you the rest of the pango
constants which cannot be used in the normal nickname manner.
# maybe indirect calls:
# s/->free//g;
# s/->unref//g;
you should never see ->ref, either.
# ItemFactory creation from hash is bogus: switch to arrays
# this way, you won't miss <type> anyway ...
the current implementation supports both array and hash forms, like gtk-perl
did. personally, i found the hash form nicely self-documenting, if verbose;
the array form is more concise.
# TextBuffer->set_text lost its last arg
this has been done in quite a few places, as it makes the interface more
perlish; perl already knows the lengths of strings.
--
muppet <scott at asofyet dot org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]