Re: Writing a class extension

From: Date: Mon, 27 May 2002 14:20:07 +0000
Subject: Re: Writing a class extension
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-2057@lists.php.net to get a copy of this message
fwd-ing to general list - this isn't a dev question. > I am trying to extend the GtkMenuBar object so that I can add an array of > values to a menu. > > For example. > > ====== CLASS CODE ====== > > <?php > class GtkMenuBarExt extends GtkMenuBar{ > function fill_from_array($items){ > if (!is_array($items)){ > return false; > } > > foreach ($items as $menu_name => $menu_array){ > $menu =& new GtkMenu(); > foreach ($menu_array as $item_name => $item_label){ > $item =& new GtkMenuItem($item_label); > $item->show(); > $menu->append($item); > } > $menu->show(); > parent::add($menu); > } > } > } > ?> > > > ====== MAIN SCRIPT ======== > > $menubar =& new GtkMenuBarExt(); > $menu_items = Array("file" => Array("new" => "New", > "save" => "Save"), > "help" => Array("help_contents" => "Help", > "about" => "About...")); > $menubar->fill_from_array($menu_items); > $menubar->show(); > > //// pack this into the window etc > > ========================== > > I have tried everything, but the menu doesn't seem to have the array items > added. Am I losing a reference somewhere, or is this something php-gtk > can't do? > > Mike > > > -- > PHP-GTK Development Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.gtk.general (#2057) next »