Re: how to detect if gtk2 module is available
- From: Brett Kosinski <brettk frodo dyn gno org>
- To: brian <bmcandrews gmail com>
- Cc: gtk-perl <gtk-perl-list gnome org>
- Subject: Re: how to detect if gtk2 module is available
- Date: Fri, 11 Mar 2005 14:38:53 -0700 (MST)
I have a separate perl module that sets a Tk::fileevent watch if the
user passes in a Tk window. Now I want the client to be able to set
hook up their own events to Gtk2 via Gtk2::Helper->add_watch. This
is simple enough, but the problem I have is that the Gtk2 module is
not installed everywhere, since a lot of our stuff is still on
perl-5.6.1. However, clients do have access to 5.8.0. How can I
conditionally test for the availability of Gtk2 inside a module? I
still want the 5.6.1 users to have access to this module, but I want
our 5.8.0 to be able use Gtk2 with this module.
Well, I tend to use a recipe like the following:
BEGIN {
eval { require Gtk2; import Gtk2 };
if ($@) {
print "You don't have Gtk2!";
$HAVE_GTK2 = 0;
} else {
$HAVE_GTK2 = 1;
}
}
Brett.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]