Menu

[r321]: / trunk / php-java-bridge / examples / gui / gtk-fileselector.php  Maximize  Restore  History

Download this file

53 lines (42 with data), 1.3 kB

 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
#!/usr/bin/php -nq
<?php
if (!extension_loaded('mono')) {
if (!(PHP_SHLIB_SUFFIX=="so" && dl('mono.so'))&&!(PHP_SHLIB_SUFFIX=="dll" && dl('php_mono.dll'))) {
echo "mono extension not installed.";
exit(2);
}
}
ini_set("max_execution_time", 0);
class GtkFileSelectorDemo {
var $filew;
function GtkFileSelectorDemo () {
mono_require("gtk-sharp");
}
function ok($obj, $args) {
echo "ok called\n";
echo $this->filew->get_Filename() . "\n";
}
function quit($obj, $args) {
echo "quit called\n";
$this->Application->Quit();
}
function init() {
$Application = $this->Application = new MonoClass("Gtk.Application");
$Application->Init();
$filew = $this->filew = new Mono("Gtk.FileSelection", "Open a file ...");
$filew->add_DeleteEvent (new Mono("Gtk.DeleteEventHandler", mono_closure($this, "quit")));
$b=$filew->get_OkButton();
$b->add_Clicked (new Mono("System.EventHandler", mono_closure($this, "ok")));
$b=$filew->get_CancelButton();
$b->add_Clicked (new Mono("System.EventHandler", mono_closure($this, "quit")));
$filew->set_Filename ("penguin.png");
$filew->Show();
}
function run() {
$this->init();
$this->Application->Run();
}
}
$demo=new GtkFileSelectorDemo();
$demo->run();
?>