Hi all,
is there a function returning the widget by name from a non-GLADE setup as done by GladeXML::get_widget()?
Reason is that I created a GtkVBox that will be filled later by dynamic software modules' GtkButtons (expense types in a car cost overview software, like refuel or washing): Window_Main::addModuleButtons in kfz.php (see below). The widget is currently being fetched from the GLADE-setup via get_widget(), but I am reprogramming that to dynamically create windows from the defined data structure, because
1. the PHP-GTK2 package obviously lacks GladeXML support
2. the software creates dialogs according to its internal setup itself.
So what I need is the respective function for non-GLADE.
| Code: |
...
$this->_window = new GtkWindow;
...
$this->gladeXML = new GladeXML(...
...
function addModuleButton($name, $signalList)
{
if (!$name || !$signalList)
return false;
$button = new GtkButton($name, true);
$button->set_visible(true);
foreach($signalList as $signalName=>$signalAction)
$button->connect_simple($signalName, $signalAction);
if ($this->gladeXML) {
$vboxModules = $this->gladeXML->get_widget('vboxModules');
$vboxModules->set_visible(true);
$vboxModules->pack_end($button);
}
if ($this->_window) {
$vBoxModulesWin = $this->getWidget($this->_window, 'vboxModules');
#from here does not work:
$vboxModulesWin->set_visible(true);
$vboxModulesWin->pack_end($button);
}
}
|
I tried to program that myself, without success with recursive calls to dive into the widget tree, later foreach() and array_search() instead (yes: beccoming more and more desperate). To see the source code for the full conxtext see SVN version on
http://sourceforge.net/projects/kfz/ .
Thx
Silverio