Re: Problem with ToolBar in PHP-GTK2

From: Date: Wed, 08 Jun 2005 18:45:43 +0000
Subject: Re: Problem with ToolBar in PHP-GTK2
References: 1 2 3  Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-1374@lists.php.net to get a copy of this message
Hi I have the same problem but i solved with <?php class ToolBar extends GtkToolBar { protected $buttons_id = array('gtk-new', 'gtk-media-pause','gtk-refresh', 'gtk-quit'); protected $buttons = array(); function __construct() { parent::__construct(); } function load_buttons() { for($i = 0; $i < sizeof($this->buttons_id); $i++) { parent::add(GtkToolButton::new_from_stock($this->buttons_id[$i])); } } static function get_toolbar() { $tool = new ToolBar(); $tool->load_buttons(); return $tool; } } $window = new GtkWindow(); $window->connect_object('destroy', array('gtk','main_quit')); $toolbar = ToolBar::get_toolbar(); $window->add($toolbar); $window->show_all(); Gtk::main(); ?> On 6/8/05, Daniel Braga <daniel@comentar.com.br> wrote: > /* translated from portuguese by Google */ > > I am trying to create a ToolBar in the Php-gtk2. Until I obtain, but > instead of 4 buttons alone he appears 3. I place stock_ids of the > buttons that I need in an Array and later I cover the Array generating > the buttons and placing them in another Array. The problem is that the > first button never is placed in the Array. I do not know if I am making > some wrong thing. > > Somebody can give one help? > > [ ]'s > Daniel Braga > > <?php > class ToolBar extends GtkToolBar > { > var $buttons_id = array('gtk-new', 'gtk-media-pause', > 'gtk-refresh', 'gtk-quit'); > var $buttons = array(); > > function __construct() > { > parent::__construct(); > } > > function load_buttons() > { > foreach ($this->buttons_id as $stock_id) { > $this->buttons[$stock_id] = > GtkToolButton::new_from_stock($stock_id); > } > } > > function add_buttons() > { > foreach ($this->buttons as $button) { > parent::add($button); > } > } > > static function get_toolbar() > { > $tool = &new ToolBar(); > $tool->load_buttons(); > $tool->add_buttons(); > return $tool; > } > } > $window = new GtkWindow(); > $window->connect_object('destroy', array('gtk','main_quit')); > > $toolbar = ToolBar::get_toolbar(); > > $window->add($toolbar); > $window->show_all(); > Gtk::main(); > ?> > > -- > PHP-GTK Development Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.gtk.dev (#1374) next »