| 1 |
root |
1.1 |
=head1 NAME |
| 2 |
|
|
|
| 3 |
|
|
Mozilla::Plugin - embed perl into mozilla/netscape. |
| 4 |
|
|
|
| 5 |
|
|
=head1 SYNOPSIS |
| 6 |
|
|
|
| 7 |
|
|
<embed type="application/x-mperl-tk" /> |
| 8 |
|
|
|
| 9 |
|
|
=head1 DESCRIPTION |
| 10 |
|
|
|
| 11 |
|
|
sorry... |
| 12 |
|
|
|
| 13 |
|
|
=over 4 |
| 14 |
|
|
|
| 15 |
|
|
=cut |
| 16 |
|
|
|
| 17 |
|
|
package Mozilla::Plugin::Tk; |
| 18 |
|
|
|
| 19 |
|
|
use base Mozilla::Plugin; |
| 20 |
|
|
|
| 21 |
|
|
use Tk (); |
| 22 |
|
|
|
| 23 |
|
|
$VERSION = 0.01; |
| 24 |
|
|
|
| 25 |
|
|
sub mainloop { |
| 26 |
|
|
my $self = shift; |
| 27 |
|
|
|
| 28 |
|
|
for(;;) { |
| 29 |
|
|
if (Tk::MainWindow->Count) { |
| 30 |
|
|
Tk::MainLoop; |
| 31 |
|
|
} else { |
| 32 |
|
|
$self->server_event; |
| 33 |
|
|
} |
| 34 |
|
|
} |
| 35 |
|
|
} |
| 36 |
|
|
|
| 37 |
|
|
sub new { |
| 38 |
|
|
my $class = shift; |
| 39 |
|
|
my $self = $class->SUPER::new(@_); |
| 40 |
|
|
|
| 41 |
|
|
$self; |
| 42 |
|
|
} |
| 43 |
|
|
|
| 44 |
|
|
sub window_new { |
| 45 |
|
|
my $self = shift; |
| 46 |
|
|
$self->SUPER::window_new(@_); |
| 47 |
root |
1.2 |
print "@_\n"; |
| 48 |
root |
1.1 |
|
| 49 |
root |
1.3 |
my $w = eval { |
| 50 |
|
|
$self->{win} = new Tk::MainWindow ( |
| 51 |
|
|
-use => (sprintf "%x", $_[0]), |
| 52 |
|
|
-borderwidth => 0, |
| 53 |
|
|
-relief =>'sunken', |
| 54 |
|
|
-width => $_[1], |
| 55 |
|
|
-height => $_[2], |
| 56 |
|
|
); |
| 57 |
|
|
}; |
| 58 |
root |
1.1 |
|
| 59 |
root |
1.3 |
if ($w) { |
| 60 |
|
|
print "@_\n"; |
| 61 |
|
|
$w->fileevent($self->server_fh, 'readable', [$self, 'server_event']); |
| 62 |
|
|
print "@_\n"; |
| 63 |
|
|
|
| 64 |
|
|
$w->Label(-text => "Test")->pack; |
| 65 |
|
|
print "mainwindow now is $w\n"; |
| 66 |
|
|
} |
| 67 |
|
|
|
| 68 |
|
|
return $w; |
| 69 |
root |
1.1 |
} |
| 70 |
|
|
|
| 71 |
|
|
sub window_delete { |
| 72 |
|
|
my $self = shift; |
| 73 |
|
|
$self->SUPER::window_delete(@_); |
| 74 |
|
|
|
| 75 |
|
|
delete $self->{win}; |
| 76 |
|
|
} |
| 77 |
|
|
|
| 78 |
|
|
sub DESTROY { |
| 79 |
|
|
warn "DESTROY"; |
| 80 |
|
|
} |
| 81 |
|
|
|
| 82 |
|
|
1; |
| 83 |
|
|
|
| 84 |
|
|
=back |
| 85 |
|
|
|
| 86 |
|
|
=head1 BUGS |
| 87 |
|
|
|
| 88 |
|
|
=head1 SEE ALSO |
| 89 |
|
|
|
| 90 |
|
|
L<PApp>. |
| 91 |
|
|
|
| 92 |
|
|
=head1 AUTHOR |
| 93 |
|
|
|
| 94 |
|
|
Marc Lehmann <pcg@goof.com> |
| 95 |
|
|
http://www.goof.com/pcg/marc/ |
| 96 |
|
|
|
| 97 |
|
|
=cut |
| 98 |
|
|
|