/** * @name __construct($widget, $signal, $icon_widget=null, $label=null) * @param GtkWidget $widget GtkWidget que ficará dentro do container * @param string $signal Sinal do widget que fechará o dialogo * @param GtkWidget $icon_widget GtkWidget entrará como imagem do botão * @param string $label String do label do botão * @return GtkToolButton */ public function __construct($widget, $signal, $icon_widget = null, $label = null) { // Constroi o parent parent::__construct(); // Armazena o widget $this->widget = $widget; // Verifica se possui stock_id if ($icon_widget != null) { parent::set_stock_id($icon_widget); } // Verifica se possui label if ($label != null) { parent::set_label($label); } // Cria o dialogo $this->dialog = new GtkDialog(NULL, NULL, Gtk::DIALOG_NO_SEPARATOR); $this->dialog->set_decorated(FALSE); // Adiciona o widget ao dinalog $this->dialog->vbox->pack_start($this->widget, 0, 0); $this->dialog->action_area->set_size_request(-1, 0); // Adiciona os eventos para abertura parent::connect("clicked", array($this, "__openContainer")); // Adiciona os eventos para fechamento $this->widget->connect($signal, array($this, "__onlostfocusContainer")); $this->widget->connect("focus-out-event", array($this, "__onlostfocusContainer")); }
function append_stock($stock, $index, $callback = null) { $button = GtkToolButton::new_from_stock($stock); $this->add($button); $button->set_visible_horizontal(true); $button->set_visible_vertical(true); if ($callback) { $button->connect('clicked', $callback); } return $button; }
function setup_toolbar($vbox, $toolbar_definition) { // note 1 $toolbar = new GtkToolBar(); // note 2 $vbox->pack_start($toolbar, 0, 0); foreach ($toolbar_definition as $item) { if ($item == '<hr>') { $toolbar->insert(new GtkSeparatorToolItem(), -1); } else { $stock_image_name = 'Gtk::STOCK_' . strtoupper($item); // note 3 if (defined($stock_image_name)) { $toolbar_item = GtkToolButton::new_from_stock(constant($stock_image_name)); $toolbar->insert($toolbar_item, -1); // note 5 $toolbar_item->connect('clicked', 'on_toolbar_button', $item); } } } }
function evt__mostrar_opciones() { $objeto_cmd = $this->get_objeto_comando($this->seleccion); $this->opciones = $objeto_cmd->inspeccionar_opciones(); $this->comp['label_info']->set_markup($objeto_cmd->get_info_extra()); //------ Cambia algunas cosas de lugar if ($objeto_cmd instanceof comando_base) { $opciones_a_sacar = array('listar', 'registrar'); $hay_que_sacar = $objeto_cmd->tiene_definido_base(); foreach (array_keys($this->opciones) as $id) { $existe = in_array($id, $opciones_a_sacar); if ($existe && $hay_que_sacar) { unset($this->opciones[$id]); } if (!$existe && !$hay_que_sacar) { unset($this->opciones[$id]); } } } //----------------------------------- $i = 0; foreach ($this->opciones as $opcion => $atributos) { if (!isset($atributos['tags']['gtk_no_mostrar'])) { $nombre = ucwords(str_replace('_', ' ', $opcion)); $boton = new GtkToolButton(); $boton->set_label($nombre); if (isset($atributos['tags']['gtk_icono'])) { $archivo = $atributos['tags']['gtk_icono']; $img = GtkImage::new_from_file(toba_dir() . '/www/img/' . $archivo); $boton->set_property('icon-widget', $img); } $boton->set_tooltip($this->tooltips, $atributos['ayuda']); $boton->connect('clicked', array($this, 'evt__ejecutar'), $opcion, $atributos); $this->comp['caja_opciones']->insert($boton, $i); //--- Desactivar algunos if ($objeto_cmd instanceof comando_instalacion && ($opcion == 'instalar' || $opcion == 'crear') && toba_modelo_instalacion::existe_info_basica()) { $boton->set_sensitive(false); } //---- $i++; } if (isset($atributos['tags']['gtk_separador'])) { $boton = new GtkSeparatorToolItem(); $this->comp['caja_opciones']->insert($boton, $i); $i++; } } $this->comp['caja_opciones']->show_all(); }
public function toolbarLoadXML($file, $mainObject = NULL) { // Lê o XML // @since rev 1 $xml = new SimpleXMLElement(file_get_contents($file)); // Cria o frame, o scrool e o treeview // @since rev 1 $obj['object'] = new GtkToolBar(); $toolbarName = (string) $xml['name']; $obj['object']->set_tooltips(TRUE); $clicked = (string) $xml['clicked']; // Percorre as configurações // @since rev 1 $counter = 0; foreach ($xml as $toolitems) { // Verifica o tipo de configuração // @since rev 1 if ($toolitems->getName() == "stockitem") { // Ajusta as informações // @since rev 1 $toolitems = $toolitems[0]; // Busca as configurações // @since rev 1 $title = (string) $toolitems['title']; $name = (string) $toolitems['name']; $stock = (string) $toolitems['stock']; // Cria o botao // @since rev 1 $obj[$name] = GtkToolButton::new_from_stock(constant($stock)); $obj['object']->insert($obj[$name], $counter); // Adiciona o evento se houver // @since rev 1 if (strlen($clicked) > 0) { // Verifica se é orientado à objeto // @since rev 1 if ($mainObject != NULL) { $function = array($mainObject, $clicked); } else { $function = $clicked; } $obj[$name]->connect("clicked", $function, $name); } // Verifica se esta desabilitado // @since rev 1 switch (strtoupper((string) $toolitems['enabled'])) { case "FALSE": $enabled = FALSE; break; case "TRUE": default: $enabled = TRUE; break; } $obj[$name]->set_sensitive($enabled); // Verifica se possui tooltip // @since rev if (isset($toolitems['tooltip'])) { $tt = new GtkTooltips(); $tt->set_tip($obj[$name], (string) $toolitems['tooltip']); unset($tt); } } else { if ($toolitems->getName() == "separator") { $obj['object']->insert(new GtkSeparatorToolItem(), $counter); } else { if ($toolitems->getName() == "toolitem") { // Busca o nome do item $name = (string) $toolitems['name']; // Cria o item $obj[$name] = new GtkToolItem(); // Adiciona o item ao toolbar $obj['object']->insert($obj[$name], $counter); } } } // Soma o contador // @since rev 1 $counter++; } // Retorna o toolbar // @since rev 1 return $obj; }
/** * Adiciona um botão no final do toolbar apartir de um arquivo de imagem * * @name append_button_from_image($imageFile, $label=NULL, $tip=NULL) * @param string $imageFile Caminho do arquivo da imagem * @param string $label Label do botão caso for usar um * @param string $tip String para mostrar como tooltip * @return GtkToolButton */ public function append_button_from_image($imageFile, $label = NULL, $tip = NULL) { // Cria o botão $toolbutton = new GtkToolButton(); // Cria a imagem $imagebutton = GtkImage::new_from_file($imageFile); // Troca o icone pela imagem $iconWidget = $toolbutton->set_icon_widget($imagebutton); // Verifica se existe label if ($label != NULL) { $toolbutton->set_label($label); } // Verifica se existe tooltip if ($tip != NULL) { // Adiciona o tooltip $toolbutton->set_tooltip_text($tip); } // Adiciona o callback do click $toolbutton->connect_simple("clicked", array($this, "__onclick"), ++$this->__counter); // Armazena o botão $this->__buttons[$this->__counter] = $toolbutton; // Adiciona o botão ao toolbar parent::insert($toolbutton, -1); // Retorna o botão return $toolbutton; }