This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

What's New in GTK-Perl 2.12

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

Other Fixes

Gtk2

This release adds a lot of new API and fixes many bugs.

API

Other Fixes

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

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.


2024-10-23 11:36