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
| <?php $window = new GtkWindow(); $window->set_size_request(400, 200); $window->connect_simple('destroy', array('Gtk','main_quit')); $window->add($vbox = new GtkVBox());
// displays a title
$title = new GtkLabel("Change cursor over clickable link\n". "using php-gtk pre-defined cursors"); $title->modify_font(new PangoFontDescription("Times New Roman Italic 10")); $title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff")); $title->set_size_request(-1, 40); $vbox->pack_start($title, 0, 0); $vbox->pack_start(new GtkLabel());
$link1 = create_link("manual", "http://gtk.php.net/manual/en/gtkclasses.php");
$link2 = create_link("mailing list", "http://www.nabble.com/Php---GTK---General-f171.html");
$hbox = new GtkHBox(); $hbox->pack_start(new GtkLabel("reference: php-gtk2 "), false); $hbox->pack_start($link1, false); $hbox->pack_start(new GtkLabel(" and "), false); $hbox->pack_start($link2, false); $vbox->pack_start($hbox, false); $vbox->pack_start(new GtkLabel());
$status = new GtkLabel(); $status->set_alignment(0, 0); $vbox->pack_start($status, 0, 0);
// function to setup the link
function create_link($title, $url) { $label = new GtkLabel($title); $label->set_markup('<span color="blue"><u>'.$title."</u></span>"); $eventbox = new GtkEventBox; $eventbox->add($label); $eventbox->connect('button-press-event', 'on_click', $title, $url); $eventbox->connect('enter-notify-event', 'on_enter', $title, $url); $eventbox->connect('leave-notify-event', 'on_leave', $title, $url);
return $eventbox; }
function on_click($widget, $event, $title, $url) { $shell = new COM('WScript.Shell'); // note 3
$shell->Run('cmd /c start "" "' . $url . '"', 0, FALSE); // note 3
|