1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
|
package Gtk;
=pod
=head1 NAME
Gtk - Perl module for the Gimp Toolkit library
=head1 SYNOPSIS
use Gtk '-init';
my $window = new Gtk::Window;
my $button = new Gtk::Button("Quit");
$button->signal_connect("clicked", sub {Gtk->main_quit});
$window->add($button);
$window->show_all;
Gtk->main;
=head1 DESCRIPTION
The Gtk module allows Perl access to the Gtk+ graphical user interface
library. You can find more information about Gtk+ on http://www.gtk.org.
The Perl binding tries to follow the C interface as much as possible,
providing at the same time a fully object oriented interface and
Perl-style calling conventions.
You will find the reference documentation for the Gtk module in the
C<Gtk::reference> manpage. There is also a cookbook style manual in
C<Gtk::cookbook>. The C<Gtk::objects> manpage contains a list of
the arguments and signals for each of the classes available in the
Gtk, Gnome and related modules. There is also a list of the flags
and enumerations along with their possible values.
More information can be found on http://www.gtkperl.org.
=head1 AUTHOR
Kenneth Albanowski, Paolo Molaro
=head1 SEE ALSO
perl(1), Gtk::reference(3pm)
=cut
require Exporter;
require DynaLoader;
require AutoLoader;
require Carp;
$VERSION = '0.7009';
@ISA = qw(Exporter DynaLoader);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT = qw(
);
# Other items we are prepared to export if requested
@EXPORT_OK = qw(
);
sub import {
my $self = shift;
foreach (@_) {
$self->init(), next if /^-init$/;
Gtk->set_locale(), next if /^-locale$/;
}
}
# use RTLD_GLOBAL
# unfortunately there is no way to know what platforms don't support this from
# within perl...
sub dl_load_flags {$^O =~ /hp/i ? 0: 0x01}
bootstrap Gtk;
# Preloaded methods go here.
@Gtk::Gdk::Bitmap::ISA = qw(Gtk::Gdk::Pixmap);
@Gtk::Gdk::Window::ISA = qw(Gtk::Gdk::Pixmap);
$Gtk::_init_package = "Gtk" if not defined $Gtk::_init_package;
package Gtk::_LazyLoader;
sub isa {
my($object, $type) = @_;
my($class);
no strict;
$class = ref($object) || $object;
#return 1 if $class eq $type;
foreach (@{$class . "::_ISA"}, @{$class . "::ISA"}) {
return 1 if $_ eq $type or $_->isa($type);
}
return 0;
}
sub _boot_package {
my $class = shift;
no strict;
if (! @{$class . "::_ISA"} ) {
foreach my $parent (@{$class . "::ISA"}) {
_boot_package ($parent);
}
return;
}
foreach my $parent (@{$class . "::_ISA"}) {
_boot_package ($parent);
}
@{$class . "::ISA"} = @{$class . "::_ISA"};
undef @{$class . "::_ISA"};
# warn "Booting $class\n";
$class =~ tr/:/_/;
my $sym = DynaLoader::dl_find_symbol_anywhere("boot_$class");
if ($sym) {
Gtk::_bootstrap($sym);
} else {
# should never happen
warn "Cannot find boot_$class anywhere\n";
}
}
sub AUTOLOAD {
my($method,$class);
# warn "Autoloading $AUTOLOAD\n";
$method = $AUTOLOAD;
$method =~ s/.*:://;
$class = ref($_[0]) || $_[0];
#print "1. Method=$method, object=$object, class=$class\n";
_boot_package ($class);
# need to use shift here to avoid creating a new reference to the
# object when DESTROY happens to be autoloaded
shift->$method(@_);
}
package Gtk::Object;
sub AUTOLOAD {
# This AUTOLOAD is used to automatically perform accessor/mutator functions
# for Gtk object data members, in lieu of defined functions.
my($result);
my ($realname) = $AUTOLOAD;
$realname =~ s/^.*:://;
eval {
my ($argn, $classn, $flags) = $_[0]->_get_arg_info($realname);
my $is_readable = $flags->{readable} || $flags->{readwrite};
my $is_writable = $flags->{writable} || $flags->{readwrite};
#print STDERR "GOT ARG: $AUTOLOAD -> $argn ($classn) ", join(' ', keys %{$flags}), " - ", join(' ', values %{$flags}),"\n";
if (@_ == 2 && $is_writable) {
$_[0]->set($argn, $_[1]);
} elsif (@_ == 1 && $is_readable) {
$result = $_[0]->get($argn);
} else {
die;
}
# Set up real method, to speed subsequent access
eval <<"EOT";
sub ${classn}::$realname {
if (\@_ == 2 && $is_writable) {
\$_[0]->set('$argn', \$_[1]);
} elsif (\@_ == 1 && $is_readable) {
\$_[0]->get('$argn');
} else {
die "Usage: ${classn}::$realname (Object [, new_value])";
}
}
EOT
};
if ($@) {
if (ref $_[0]) {
$AUTOLOAD =~ s/^.*:://;
Carp::croak ("Can't locate object method \"$AUTOLOAD\" via package \"" . ref($_[0]) . "\"");
} else {
Carp::croak ("Undefined subroutine \&$AUTOLOAD called");
}
}
$result;
}
# Note: $handler and $slot_object are swapped!
sub signal_connect_object {
my ($obj, $signal, $slot_object, $handler, @data) = @_;
$obj->signal_connect($signal, sub {
# throw away the object
shift;
$slot_object->$handler(@_);
}, @data);
}
sub signal_connect_object_after {
my ($obj, $signal, $slot_object, $handler, @data) = @_;
$obj->signal_connect_after($signal, sub {
# throw away the object
shift;
$slot_object->$handler(@_);
}, @data);
}
package Gtk::Widget;
sub new {
my ($class, @args) = @_;
my ($obj) = Gtk::Object::new(@args);
$class->add($obj) if ref($class);
return $obj;
}
sub new_child {return new @_}
package Gtk::CTree;
sub insert_node_defaults {
my ($ctree, %values) = @_;
$values{spacing} = 5 unless defined $values{spacing};
$values{is_leaf} = 1 unless defined $values{is_leaf};
$values{expanded} = 0 unless defined $values{expanded};
$values{titles} = $values{text} unless defined $values{titles};
return $ctree->insert_node(@values{qw/parent sibling titles spacing pixmap_closed mask_closed pixmap_opened mask_opened is_leaf expanded/});
}
package Gtk;
if ($Gtk::lazy) {
require Gtk::TypesLazy;
Gtk::_bootstrap(DynaLoader::dl_find_symbol_anywhere("boot_Gtk__Object"));
#Gtk::_LazyLoader::_boot_package('Gtk::Widget');
} else {
require Gtk::Types;
&Gtk::_boot_all();
}
sub getopt_options {
my $dummy;
return (
"gdk-debug=s" => \$dummy,
"gdk-no-debug=s" => \$dummy,
"display=s" => \$dummy,
"sync" => \$dummy,
"no-xshm" => \$dummy,
"name=s" => \$dummy,
"class=s" => \$dummy,
"gxid_host=s" => \$dummy,
"gxid_port=s" => \$dummy,
"xim-preedit=s" => \$dummy,
"xim-status=s" => \$dummy,
"gtk-debug=s" => \$dummy,
"gtk-no-debug=s" => \$dummy,
"g-fatal-warnings" => \$dummy,
"gtk-module=s" => \$dummy,
);
}
# Autoload methods go after __END__, and are processed by the autosplit program.
1;
__END__
|