What's New in GTK-Perl 2.12
Contents
Glib
The new stable release of the Glib module features the presence of two new modules: Glib::CodeGen and Glib::KeyFile. Also, the test suite has been improved, as well as the documentation.
Glib::CodeGen
Now the CodeGen code generation module is part of the Glib module instead of the Gtk2 one. You can use Glib::CodeGen module to create much of the boilerplate code needed for wrapping GObject-based libraries in Perl (like Gtk).
use Glib::CodeGen; Glib::CodeGen->parse_maps (’mylib’); Glib::CodeGen->write_boot;
Glib::KeyFile
Added bindings for Glib::KeyFile, the parser object used for the desktop entry files.
use Glib; $f = Glib::KeyFile->new; $f->load_from_file($filename); print "file[" . $f->get_start_group . "]['Answer'] = " . $f->get_integer($f->get_start_group, 'Answer') . "\n";
API
Add Glib::Markup::escape_text.
- Add API that allows binding developers to specify conversion functions when registering wrappers for custom fundamental types.
Add Glib::Object::signal_add_emission_hook and Glib::Object::signal_remove_emission_hook.
Other Fixes
- Fix Glib::IO::add_watch on win32
Gtk2
This release adds a lot of new API and fixes many bugs.
API
- Add lots of new API in
Gtk2::Gdk::Pixbuf,
Gtk2::Gdk::PixbufLoader,
Gtk2::Gdk::Cursor,
Gtk2::Gdk::Display,
Gtk2::Gdk::Screen,
Gtk2::Gdk::Window,
Gtk2::Gdk::X11,
Gtk2::Dialog,
Gtk2::Dnd,
Gtk2::EntryCompletion,
Gtk2::FileChooser,
Gtk2::IconView,
Gtk2::Image,
Gtk2::MenuBar,
Gtk2::MenuShell,
Gtk2::ScrolledWindow,
Gtk2::SizeGroup,
Gtk2::Stock,
Gtk2::TextIter,
Gtk2::ToolButton,
Gtk2::TreeModel,
Gtk2::TreeView,
Gtk2::TreeViewColumn,
Gtk2::Window.
- Add support for the grab-broken event.
Add support for implementing the GtkTreeSortable, GtkTreeDragSource and GtkTreeDragDest interfaces.
Other Fixes
- Many test suite fixes.
- Documentation additions.
Turn Gtk2::Widget::window into a mutator.
Make it possible to change a Gtk2::SimpleList's model.
Fix Gtk2::show_about_dialog to actually cache the dialog instance.
Make Gtk2::Dialog::set_alternative_button_order accept string constants.
Gtk2::GladeXML
Gnome2
Just fixes in the test suite.
Gnome2::VFS
The new Gnome2::VFS release adds new MIME related API and lets you export some constants.
API
- Export some constants on demand.
Add API in Gnome2::VFS::Mime::Type, Gnome2::VFS::Mime::Application.
Add Gnome2::VFS::Handle::forget_cache and Gnome2::VFS::make_uri_from_input_with_trailing_ws.
Gnome2::GConf
Error Handling
The Gnome2::GConf module now supports a much finer-grained error handling, instead of just croaking on errors, reflecting the underlying library error system.
Up until now, the only way to catch an error was to use eval around each fallible function, and then check the returned Glib::Error object:
use Gnome2::GConf; my $client = Gnome2::GConf::Client->get_default; # usual error trap using eval{}; eval { $client->get_string($some_key); }; if (Glib::Error::matches($@, ’Gnome2::GConf::Error’, ’bad-key’)) { my $dialog = Gtk2::MessageDialog->new(undef, 'destroy-with-parent', 'error', 'close', 'Invalid key'); $dialog->format_secondary_text("The key '$some_key' is not valid"); $dialog->run; $dialog->destroy; }
Now, you can catch the error asynchronously, trapping it using the unreturned-error signal:
# this signal callback will catch only unreturned errors, that is errors happaning in calls # to functions with the "check_error" parameter set to FALSE. $client->signal_connect('unreturned-error', sub { my ($client, $error) = @_; my $dialog = Gtk2::MessageDialog->new(undef, 'destroy-with-parent', 'error', 'close', 'GConf Error'); $dialog->format_secondary_text(sprintf("%s", $error)); $dialog->run; $dialog->destroy; }); # key check_error $client->get_string($some_key, FALSE);
Backward compatibility is assured by defaulting the check_error parameter to TRUE.
Gnome2::GConf::Engine
The basic engine object for handling low-level GConf data is finally wrapped. You normally wouldn't need it, and be better off using the Gnome2::GConf::Client class, but by using the Gnome2::GConf::Engine object you could even implement your own client class in Perl.