Menu

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

Download this file

66 lines (51 with data), 1.9 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
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/php -nq
# To run the following example gtk-sharp ver. 2.10, (key# 35e10195dab3c99f)
# must be installed.
<?php
require_once ("mono/Mono.inc");
ini_set("max_execution_time", 0);
class GtkFileSelectorDemo {
var $filew;
function GtkFileSelectorDemo () {
// mono_require("gtk-sharp", "2.0.0.0", "35e10195dab3c99f");
// The following is equivalent to the above mono_require
// statement. It shows how to load a library from the GAC.
$Assembly= mono("System.Reflection.Assembly");
$assemblyName = new Mono("System.Reflection.AssemblyName");
// Name is a property of AssemblyName, set_Name(...) calls the
// setter, get_Name() calls the getter
$assemblyName->set_Name("gtk-sharp");
$assemblyName->set_Version(new Mono("System.Version", "2.10"));
// pack converts the hex string into a byte array
$assemblyName->setPublicKeyToken(pack("H16", "35e10195dab3c99f"));
// load gtk-sharp 2.0.0.0 (35e10195dab3c99f)
$Assembly->Load($assemblyName);
}
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 = mono("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();
?>