Commit | Line | Data |
---|---|---|
21c4e167 H |
1 | #!/usr/bin/php -c/etc/php/php-gtk.ini |
2 | <?php | |
3 | //GTK Hello world! by Harvie 2oo9 | |
4 | ||
5 | $app = new HelloWorld(); | |
6 | Gtk::main(); | |
7 | ||
8 | class HelloWorld { | |
9 | ||
10 | public $widgets; | |
11 | public $builder; | |
12 | ||
13 | function __construct() { | |
14 | $this->builder = $builder = new GtkBuilder(); | |
15 | ||
16 | $builder->add_from_file('hello.ui'); | |
17 | $builder->connect_signals_instance($this); | |
18 | ||
19 | /* | |
20 | $objects = $builder->get_objects(); | |
21 | echo count($objects), " objects were created by GtkBuilder\n"; | |
22 | ||
23 | $builder->set_translation_domain('myapp'); | |
24 | echo $builder->get_translation_domain(), "\n"; | |
25 | ||
26 | var_dump($builder->get_type_from_name('GtkButton')); | |
27 | */ | |
28 | ||
29 | foreach(array('window1','entry1','button1') as $widget) { | |
30 | $this->widgets[$widget] = $builder->get_object($widget); | |
31 | } | |
32 | $this->widgets['window1']->show_all(); | |
33 | ||
34 | } | |
35 | ||
36 | function on_button1_clicked() { | |
37 | $this->widgets['button1']->set_label($this->widgets['entry1']->get_text()); | |
38 | echo( $this->widgets['entry1']->get_text()."\n" ); | |
39 | } | |
40 | ||
41 | function on_window1_destroy(){ | |
42 | Gtk::main_quit(); | |
43 | exit(); | |
44 | } | |
45 | ||
46 | ||
47 | } | |
48 | ?> |