GtkUIManager, GtkActionGroup and GtkAction

From: Date: Wed, 31 May 2006 17:22:51 +0000
Subject: GtkUIManager, GtkActionGroup and GtkAction
Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-2921@lists.php.net to get a copy of this message
Hello all, I finally found out how GtkUIManager, GtkActionGroup and GtkAction work together and found some inconvenient things. First, let's explain how they interact: GtkUIManager creates Menu and Toolbar widgets out of a XML definition, be it in a file or a string. Every of this items in the XML have both a name (by which they are referenced) and an action attribute. The action attribute refers to an action object defined in an GtkActionGroup object that is attached to the uimanager. Now you have to provide an action for every item in the xml definition, or it will not be shown. You can define the actions by a) creating an GtkAction object for every single action, connecting a callback to the "activate" signal and adding it to the action group via ->add_action($action). The drawback is that you cannot just do > $group->add_action(new GtkAction("Name", "_Title", > "Tooltip", Gtk::STOCK_NEW)); because you need to add the callback, too. Therefore I vote for adding a fifth, optional parameter that represents a callback and is connected if passed to the constructor. b) by using the currently not implemented $group->add_actions(array of GtkActionEntries). A GtkActionEntry is a struct that just contains the same information as a GtkAction, just the plain text version - so it can be represented by an array in php: >$group->add_actions( array( > array($name, $stock_id, $label, $accelerator, $tooltip), > array($name2, $stock_id2, $label2, $accelerator2, $tooltip2) >); I am wondering now if we should allow passing an array of GtkActions to the method, not only arrays? I personally think it is useful in some special cases only, but if you really want to customize your actions it is useful. And the name also implies that you can add actions, not arrays only. -- Regards/MfG, Christian Weiske

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.gtk.dev (#2921) next »