| 1 |
root |
1.1 |
=head1 NAME |
| 2 |
|
|
|
| 3 |
root |
1.7 |
Browser::Plugin - embed perl into a webbrowser using gtk. |
| 4 |
root |
1.1 |
|
| 5 |
|
|
=head1 SYNOPSIS |
| 6 |
|
|
|
| 7 |
root |
1.3 |
<embed type="application/x-mperl-gtk" /> |
| 8 |
root |
1.1 |
|
| 9 |
|
|
=head1 DESCRIPTION |
| 10 |
|
|
|
| 11 |
|
|
sorry... |
| 12 |
|
|
|
| 13 |
|
|
=over 4 |
| 14 |
|
|
|
| 15 |
|
|
=cut |
| 16 |
|
|
|
| 17 |
root |
1.7 |
package Browser::Plugin::Gtk; |
| 18 |
root |
1.1 |
|
| 19 |
root |
1.7 |
use base Browser::Plugin; |
| 20 |
root |
1.1 |
|
| 21 |
|
|
use Gtk; |
| 22 |
|
|
|
| 23 |
|
|
$VERSION = 0.01; |
| 24 |
|
|
|
| 25 |
root |
1.2 |
sub mainloop { |
| 26 |
root |
1.3 |
my $self = shift; |
| 27 |
root |
1.1 |
|
| 28 |
root |
1.3 |
init Gtk; |
| 29 |
|
|
input_add Gtk::Gdk (fileno($self->server_fh), 'read', sub { |
| 30 |
|
|
$self->server_event; |
| 31 |
|
|
}); |
| 32 |
|
|
main Gtk; |
| 33 |
root |
1.1 |
} |
| 34 |
|
|
|
| 35 |
|
|
sub window_new { |
| 36 |
|
|
my $self = shift; |
| 37 |
root |
1.7 |
my $wi = $_[0]; |
| 38 |
root |
1.1 |
$self->SUPER::window_new(@_); |
| 39 |
|
|
|
| 40 |
root |
1.6 |
my $w = new Gtk::Plug $wi->{id}; |
| 41 |
root |
1.4 |
if ($w->socket_window) { |
| 42 |
root |
1.6 |
$w->add(my $W = new Gtk::HandleBox); |
| 43 |
|
|
$W->add(my $v = new Gtk::VBox 5,5); |
| 44 |
|
|
$v->add(my $e = new Gtk::Entry); |
| 45 |
|
|
$e->set_text("http://www.plan9.de/"); |
| 46 |
|
|
$v->add(my $b = new Gtk::Button "get_url"); |
| 47 |
|
|
signal_connect $b clicked => sub { |
| 48 |
|
|
print "entry changed to ".($e->get_text)."\n";#d# |
| 49 |
|
|
}; |
| 50 |
root |
1.4 |
$w->show_all; |
| 51 |
root |
1.7 |
$w->socket_window->set_events([qw(leave_notify_mask structure_mask enter_notify_mask exposure_mask focus_change_mask key_press_mask)]); |
| 52 |
|
|
signal_connect $e key_press_event => sub { |
| 53 |
|
|
warn Dumper ({key_press => \@_}); |
| 54 |
|
|
1; |
| 55 |
|
|
}; |
| 56 |
|
|
use Data::Dumper; |
| 57 |
|
|
warn Dumper $w->socket_window->get_events; |
| 58 |
|
|
warn Dumper $w->window->get_events; |
| 59 |
root |
1.3 |
|
| 60 |
root |
1.4 |
return $w; |
| 61 |
|
|
} else { |
| 62 |
|
|
return (); |
| 63 |
|
|
} |
| 64 |
root |
1.1 |
} |
| 65 |
|
|
|
| 66 |
|
|
sub DESTROY { |
| 67 |
|
|
warn "DESTROY"; |
| 68 |
|
|
} |
| 69 |
|
|
|
| 70 |
|
|
1; |
| 71 |
|
|
|
| 72 |
|
|
=back |
| 73 |
|
|
|
| 74 |
|
|
=head1 BUGS |
| 75 |
|
|
|
| 76 |
|
|
=head1 SEE ALSO |
| 77 |
|
|
|
| 78 |
|
|
L<PApp>. |
| 79 |
|
|
|
| 80 |
|
|
=head1 AUTHOR |
| 81 |
|
|
|
| 82 |
|
|
Marc Lehmann <pcg@goof.com> |
| 83 |
|
|
http://www.goof.com/pcg/marc/ |
| 84 |
|
|
|
| 85 |
|
|
=cut |
| 86 |
|
|
|