Index: Gtk2.pm =================================================================== RCS file: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/Gtk2.pm,v retrieving revision 1.116 diff -u -d -p -r1.116 Gtk2.pm --- Gtk2.pm 9 Jan 2008 21:55:05 -0000 1.116 +++ Gtk2.pm 16 Jan 2008 19:39:46 -0000 @@ -34,11 +34,26 @@ use Glib; # gtk+ and pango. eval "use Cairo;"; +use Exporter; require DynaLoader; our $VERSION = '1.172'; -our @ISA = qw(DynaLoader); +our @ISA = qw(DynaLoader Exporter); + +use constant { + GDK_PRIORITY_EVENTS => Glib::G_PRIORITY_DEFAULT, + GDK_PRIORITY_REDRAW => Glib::G_PRIORITY_HIGH_IDLE + 20, + GTK_PRIORITY_RESIZE => Glib::G_PRIORITY_HIGH_IDLE + 10 +}; + +our %EXPORT_TAGS = ( + constants => [qw/GDK_PRIORITY_EVENTS + GDK_PRIORITY_REDRAW + GTK_PRIORITY_RESIZE/], +); +our @EXPORT_OK = map { @$_ } values %EXPORT_TAGS; +$EXPORT_TAGS{all} = \ EXPORT_OK; sub import { my $class = shift; @@ -50,18 +65,23 @@ sub import { my $init = 0; my $threads_init = 0; + my @unknown_args = ($class); foreach (@_) { if (/^-?init$/) { $init = 1; } elsif (/-?threads-init$/) { $threads_init = 1; } else { - $class->VERSION ($_); + push @unknown_args, $_; } } Gtk2::Gdk::Threads->init if ($threads_init); Gtk2->init if ($init); + + # call into Exporter for the unrecognized arguments; handles exporting + # and version checking + Gtk2->export_to_level (1, @unknown_args); } # this is critical -- tell dynaloader to load the module so that its @@ -270,6 +290,22 @@ called, if done by "use Gtk2 -init -thre =back +=head1 EXPORTS + +Gtk2 exports nothing by default, but some constants are available upon request. + +=over + +=item Tag: constants + + GTK_PRIORITY_RESIZE + GDK_PRIORITY_EVENTS + GDK_PRIORITY_REDRAW + +=back + +See L for other standard priority levels. + =head1 SEE ALSO L(1), L(3pm). Index: t/00.Gtk2.t =================================================================== RCS file: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/t/00.Gtk2.t,v retrieving revision 1.21 diff -u -d -p -r1.21 00.Gtk2.t --- t/00.Gtk2.t 14 May 2006 10:57:07 -0000 1.21 +++ t/00.Gtk2.t 16 Jan 2008 19:39:46 -0000 @@ -14,8 +14,8 @@ use warnings; # NOTE: this is the bootstrap test -- no Gtk2::TestHelper here! -use Test::More tests => 35; -BEGIN { use_ok('Gtk2') }; +use Test::More tests => 41; +BEGIN { use_ok('Gtk2', ':constants') }; ######################### @@ -43,6 +43,14 @@ is (@version, 3, 'version info is three ok (Gtk2::Pango->CHECK_VERSION(0,0,0), 'CHECK_VERSION pass'); ok (!Gtk2::Pango->CHECK_VERSION(50,0,0), 'CHECK_VERSION fail'); +my $number = qr/^\d+$/; +like (Gtk2::GTK_PRIORITY_RESIZE, $number); +like (Gtk2::GDK_PRIORITY_EVENTS, $number); +like (Gtk2::GDK_PRIORITY_REDRAW, $number); +like (GTK_PRIORITY_RESIZE, $number); +like (GDK_PRIORITY_EVENTS, $number); +like (GDK_PRIORITY_REDRAW, $number); + SKIP: { Gtk2->disable_setlocale; Index: t/version-checks.t =================================================================== RCS file: t/version-checks.t diff -N t/version-checks.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ t/version-checks.t 16 Jan 2008 19:39:46 -0000 @@ -0,0 +1,15 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Test::More tests => 2; + +eval "use Gtk2 ':constants', 1.00;"; +is ($@, ''); + +eval "use Gtk2 -init, 10.00;"; +like ($@, qr/this is only version/); + +__END__ + +Copyright (C) 2008 by the gtk2-perl team (see the file AUTHORS for the +full list). See LICENSE for more information.