All pastes #259417 Raw Edit

Marc Quinton

public php v1 · immutable
#259417 ·published 2006-11-27 13:42 UTC
rendered paste body
<?php/** * Class for handling multipul GtkWindow objects * @author Leon Pegg <leon.pegg@gmail.com> */class MainWindow extends GtkWindow {	protected $_sub_windows;    protected $widgets = array();    public function __construct() {        parent::__construct();        parent::set_name('wnd_one');        $this->build_ui();        $this->_sub_windows = array();    }    protected function build_ui() {        $btn_show = new GtkButton("Show window two");        $btn_show->set_name('btn_show');        parent::add($btn_show);        $this->widgets['btn_show'] = $btn_show;               $btn_show->connect_simple('clicked', array($this, 'clicked_btn_show'));        parent::connect_simple('destroy', array('Gtk', 'main_quit'));    }       public function widget($widget_name) {        if ($widget_name !== '' && array_key_exists($widget_name, $this->widgets)) {            return $this->widgets[$widget_name];        }        return false;    }       public function clicked_btn_show() {		$this->_win2 = new GtkWindow_Two();		$this->_win2->set_size_request(100,50);		$this->_win2->set_position(Gtk::WIN_POS_CENTER);        $this->_win2->show_all();    }}class GtkWindow_Two extends GtkWindow {    protected $widgets = array();    public function __construct() {        parent::__construct();        parent::set_name('wnd_two');        $this->build_ui();    }    protected function build_ui() {        $btn_hide = new GtkButton("Hide window");        $btn_hide->set_name('btn_hide');        parent::add($btn_hide);        $this->widgets['btn_hide'] = $btn_hide;               $btn_hide->connect_simple('clicked', array($this, 'clicked_btn_hide'));        parent::connect_simple('delete-event', array($this, 'delete_event'));    }       public function widget($widget_name) {        if ($widget_name !== '' && array_key_exists($widget_name, $this->widgets)) {            return $this->widgets[$widget_name];        }        return false;    }       public function clicked_btn_hide() {        parent::hide_all();    }       public function delete_event() {        parent::hide_all();        return true;    }   }$main = new mainWindow();$main->set_size_request(150,100);$main->set_position(Gtk::WIN_POS_CENTER);$main->show_all();Gtk::main();?>