/** * Append an item to the menu */ public function append($item, $submenu) { $button = new GtkToggleButton(); $button->set_label($item->getLabel()); $handler = $button->connect('clicked', array($this, 'onExecute'), $item, $submenu); $button->set_data('handler', $handler); $this->pack_start($button, FALSE, FALSE); }
/** * Append an item to the menu */ public function append($item, $submenu) { $button = new GtkToggleButton(); if (OS == 'WIN') { $hbox = new GtkHBox(); $hbox->set_border_width(4); $hbox->pack_start(new GtkLabel($item->getLabel())); $button->add($hbox); } else { $button->set_label($item->getLabel()); } $handler = $button->connect('clicked', array($this, 'onExecute'), $item, $submenu); $button->set_data('handler', $handler); $this->pack_start($button, FALSE, FALSE); }
function createToggleButton($basewidget, $basefunction, $text_on, $text_off, $bCallGetter) { $tb = new GtkToggleButton(); $tb->set_label($tb->get_active() ? $text_on : $text_off); if ($bCallGetter) { $tb->set_active($basewidget->{'get_' . $basefunction}()); } $tb->connect('toggled', array($this, 'set_toggled'), $basewidget, $basefunction, $text_on, $text_off, $bCallGetter); return $tb; }