File: linkbutton.pl

package info (click to toggle)
libgtk2-perl 2%3A1.244-1%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,524 kB
  • sloc: perl: 21,568; ansic: 122; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 727 bytes parent folder | download | duplicates (8)
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
#!/usr/bin/perl -w

use strict;
use Gtk2 -init;

# you set one of these per app.
Gtk2::LinkButton->set_uri_hook (sub {
	my ($button, $url) = @_;
	my $message = Gtk2::MessageDialog->new
			($button->get_toplevel, [], 'info', 'ok',
			 "In a real app, you'd figure out how to handle "
			 ."opening urls, and do that here.  This is just "
			 ."an example of using the widget, so we don't "
			 ."mess around with all of that.\n\nUrl: $url");
	$message->run;
	$message->destroy;
});

my $window = Gtk2::Window->new;

my $button = Gtk2::LinkButton->new ("http://gtk2-perl.sf.net",
				    "Gtk2-Perl Homepage");

$window->add ($button);
$window->show_all;
$window->signal_connect (destroy => sub { Gtk2->main_quit });
Gtk2->main;