예제 #1
0
 /**
  * Class Constructor
  * @param $label  The menu label
  * @param $action The menu action
  * @param $image  The menu image
  */
 public function __construct($label, $action, $image = NULL)
 {
     parent::__construct(utf8_decode($label));
     // converts into ISO
     parent::set_image(null);
     if (OS == 'WIN') {
         parent::set_border_width(3);
     }
     $this->label = $label;
     $this->action = $action;
     $this->image = $image;
     if (file_exists($image)) {
         parent::set_image(GtkImage::new_from_file($image));
     }
     $inst = TApplication::getInstance();
     if ($inst instanceof TApplication) {
         parent::connect_simple('activate', array($inst, 'run'), $action);
     }
 }
 /**
  * Cria um novo item
  * 
  * @name append_item($title, $callback=NULL)
  * @param string $title Texto do item
  * @param mixed $callback Função de callback
  * @param GtkStockItem StockID do icone para aparecer
  * @return GtkMenuItem
  */
 public function append_item($title, $callback = NULL, $stock = NULL)
 {
     // Verifica o stock
     if ($stock == NULL) {
         // Cria o item
         $menuitem = Fabula::GtkMenuItem($title);
     } else {
         // Cria o item com imagem
         $menuitem = new GtkImageMenuItem($title);
         $image = GtkImage::new_from_stock($stock, Gtk::ICON_SIZE_MENU);
         $menuitem->set_image($image);
     }
     // Adiciona o item ao menu
     $this->append($menuitem);
     // Atualiza o widget
     $this->show_all();
     // Verifica o callback
     if ($callback !== NULL) {
         $menuitem->connect("activate", $callback);
     }
     // Retorna o menuitem
     return $menuitem;
 }