Ejemplo n.º 1
0
 /**
  * Retorna un modelo de comandos administrativos disponibles
  */
 function cargar_comandos($seleccionar_proyecto = null)
 {
     $instalacion = $this->toba_instalador->get_instalacion();
     //---El formato es Nombre,Imagen,Clave, Label
     $modelo = new GtkTreeStore(Gtk::TYPE_STRING, Gtk::TYPE_OBJECT, Gtk::TYPE_STRING, Gtk::TYPE_STRING);
     $path = toba_nucleo::toba_dir() . '/www/img/instalacion.png';
     $img = GdkPixbuf::new_from_file($path);
     $raiz = null;
     $path_inst = $instalacion->get_dir();
     $nodo_instal = $modelo->append($raiz, array('Instalación', $img, 'instalacion', "Instalación"));
     $seleccion = null;
     if ($instalacion->existe_info_basica()) {
         //---Agrega las instancias
         foreach ($instalacion->get_lista_instancias() as $id_instancia) {
             $instancia = $instalacion->get_instancia($id_instancia);
             $path = toba_nucleo::toba_dir() . '/www/img/instancia.gif';
             $img = GdkPixbuf::new_from_file($path);
             $nodo_inst = $modelo->append($nodo_instal, array($id_instancia, $img, 'instalacion/' . $id_instancia, "Instancia {$id_instancia}"));
             //---Agrega los proyectos
             $path = toba_nucleo::toba_dir() . '/www/img/nucleo/proyecto.gif';
             $img = GdkPixbuf::new_from_file($path);
             foreach ($instancia->get_lista_proyectos_vinculados() as $id_proyecto) {
                 $nodo_pro = $modelo->append($nodo_inst, array($id_proyecto, $img, 'instalacion/' . $id_instancia . '/' . $id_proyecto, "Proyecto {$id_proyecto}"));
                 if ($id_proyecto == $seleccionar_proyecto) {
                     $seleccion = $nodo_pro;
                 }
             }
         }
         //---BASES
         $path = toba_nucleo::toba_dir() . '/www/img/fuente.png';
         $img = GdkPixbuf::new_from_file($path);
         $nodo_bases = $modelo->append($raiz, array('Bases', $img, 'base', 'Bases de Toba'));
         foreach ($instalacion->get_lista_bases() as $db) {
             $modelo->append($nodo_bases, array($db, $img, 'base_' . $db, "Base '{$db}'"));
         }
     }
     //--- Comandos extra
     $path = toba_nucleo::toba_dir() . '/www/img/cpu.png';
     $img = GdkPixbuf::new_from_file($path);
     $modelo->append($raiz, array('Núcleo', $img, 'nucleo', 'Núcleo de Toba'));
     $path = toba_nucleo::toba_dir() . '/www/img/ayuda.png';
     $img = GdkPixbuf::new_from_file($path);
     $modelo->append($raiz, array('Documentación', $img, 'doc', 'Documentación'));
     $path = toba_nucleo::toba_dir() . '/www/img/objetos/item.gif';
     $img = GdkPixbuf::new_from_file($path);
     $modelo->append($raiz, array('Items', $img, 'item', 'Items'));
     $path = toba_nucleo::toba_dir() . '/www/img/testing.gif';
     $img = GdkPixbuf::new_from_file($path);
     $modelo->append($raiz, array('Testing', $img, 'test', 'Testing'));
     //--- Expansion
     $this->comp['arbol_comandos']->set_model($modelo);
     $this->comp['arbol_comandos']->expand_row(0, true);
     if (isset($seleccion)) {
         return $seleccion;
     }
 }
 /**
  * @todo Implement testPrepend().
  */
 public function testPrepend()
 {
     $ts = new GtkTreeStore(Gtk::TYPE_STRING);
     $this->assertEquals(0, $ts->iter_n_children(null));
     $one = $ts->prepend(null, array('one'));
     $this->assertEquals(1, $ts->iter_n_children(null));
     $this->assertEquals($one, $ts->get_iter_first());
     $two = $ts->prepend(null, array('two'));
     $this->assertEquals(2, $ts->iter_n_children(null));
     $this->assertEquals($two, $ts->get_iter_first());
     $three = $ts->prepend($one, array('three'));
     $this->assertEquals(2, $ts->iter_n_children(null));
     $this->assertEquals(1, $ts->iter_n_children($one));
     $this->assertEquals($two, $ts->get_iter_first());
     $this->assertEquals($three, $ts->iter_next($two));
 }
 public function treeviewLoadXML($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
     $treeviewName = (string) $xml['name'];
     $obj['treeview'] = new GtkTreeView();
     $scrolled = new GtkScrolledWindow();
     $scrolled->add($obj['treeview']);
     $obj['object'] = new GtkFrame();
     $obj['object']->add($scrolled);
     // Verifica o modo do scroll horizontal
     // @since rev 1
     switch (strtoupper((string) $xml['hscroll'])) {
         case "TRUE":
             $hscroll = Gtk::POLICY_ALWAYS;
             break;
         case "FALSE":
             $hscroll = Gtk::POLICY_NEVER;
             break;
         case "AUTO":
         default:
             $hscroll = Gtk::POLICY_AUTOMATIC;
             break;
     }
     // Verifica o modo do scroll vertical
     // @since rev 1
     switch (strtoupper((string) $xml['vscroll'])) {
         case "TRUE":
             $vscroll = Gtk::POLICY_ALWAYS;
             break;
         case "FALSE":
             $vscroll = Gtk::POLICY_NEVER;
             break;
         case "AUTO":
         default:
             $vscroll = Gtk::POLICY_AUTOMATIC;
             break;
     }
     // Configura os scrolls
     // @since rev 1
     $scrolled->set_policy($hscroll, $vscroll);
     // Configura o tamanho
     // @since rev 1
     $width = isset($xml['width']) ? (int) $xml['width'] : FALSE;
     $height = isset($xml['height']) ? (int) $xml['height'] : FALSE;
     $scrolled->set_size_request($width, $height);
     // Seta a coluna para a busca
     // @since rev 1
     $searchcolumn = isset($xml['searchcolumn']) ? (int) $xml['searchcolumn'] : 0;
     $obj['treeview']->set_search_column($searchcolumn);
     // Configura a visibilidade do header da coluna
     // @since rev 1
     switch (strtoupper((string) $xml['hvisible'])) {
         case "FALSE":
             $hvisible = FALSE;
             break;
         case "TRUE":
         default:
             $hvisible = TRUE;
             break;
     }
     $obj['treeview']->set_headers_visible($hvisible);
     // Verifica se existe evento button-press-event
     // @since rev 1
     $buttonpressevent = (string) $xml['buttonpressevent'];
     if (strlen($buttonpressevent) > 0) {
         // Verifica se é orientado à objeto
         // @since rev 1
         if ($mainObject != NULL) {
             $function = array($mainObject, $buttonpressevent);
         } else {
             $function = $buttonpressevent;
         }
         $obj['treeview']->connect("button-press-event", $function);
     }
     // Verifica se existe evento cursor-changed
     // @since rev 1
     $cursorchanged = (string) $xml['cursorchanged'];
     if (strlen($cursorchanged) > 0) {
         // Verifica se é orientado à objeto
         // @since rev 1
         if ($mainObject != NULL) {
             $function = array($mainObject, $cursorchanged);
         } else {
             $function = $cursorchanged;
         }
         $obj['treeview']->connect("cursor-changed", $function);
     }
     // Percorre as configurações
     // @since rev 1
     foreach ($xml as $configs) {
         // Verifica o tipo de configuração
         // @since rev 1
         if ($configs->getName() == "columns") {
             // Percorre as colunas
             // @since rev 1
             $counter = 0;
             $columnModel = array();
             foreach ($configs as $column) {
                 // Busca as configurações
                 $title = (string) $column['title'];
                 $visible = (string) $column['visible'];
                 // Cria a coluna
                 // @since rev 1
                 $modelType = Gobject::TYPE_STRING;
                 if (strtoupper($visible) != "FALSE") {
                     // Verifica o tipo e o render
                     // @since rev 1
                     switch (strtoupper((string) $column['type'])) {
                         // Toggle
                         // @since rev 1
                         case "TOGGLE":
                             // Cria o render
                             // @since rev 1
                             $render = new GtkCellRendererToggle();
                             $render->set_property("activatable", TRUE);
                             // Verifica se deve usar o autocheck
                             // @since rev 1
                             switch (strtoupper((string) $column['autocheck'])) {
                                 case "FALSE":
                                     break;
                                 case "TRUE":
                                 default:
                                     $render->connect("toggled", array("FTreeViews", "on_toggle"), $obj['treeview'], $counter);
                                     break;
                             }
                             // Verifica se existe evento onclick da coluna
                             // @since rev 1
                             $onclick = (string) $column['onclick'];
                             if (strlen($onclick) > 0) {
                                 // Verifica se é orientado à objeto
                                 // @since rev 1
                                 if ($mainObject != NULL) {
                                     $function = array($mainObject, $onclick);
                                 } else {
                                     $function = $onclick;
                                 }
                                 $render->connect("toggled", $function, $obj['treeview'], $counter);
                             }
                             // Armazena o atributo e o model
                             // @since rev 1
                             $attribute = "active";
                             $modelType = Gobject::TYPE_BOOLEAN;
                             break;
                             // Texto
                             // @since rev 1
                         // Texto
                         // @since rev 1
                         case "TEXT":
                         default:
                             $render = new GtkCellRendererText();
                             // Verifica se a coluna é editavel
                             // @since rev 1
                             switch (strtoupper((string) $column['editable'])) {
                                 case "TRUE":
                                     $render->set_property("editable", TRUE);
                                     break;
                                 case "FALSE":
                                 default:
                                     break;
                             }
                             // Verifica se existe sinal para edição
                             // @since rev 1
                             $onedited = (string) $column['onedited'];
                             if (strlen($onedited) > 0) {
                                 // Verifica se é orientado à objeto
                                 // @since rev 1
                                 if ($mainObject != NULL) {
                                     $function = array($mainObject, $onedited);
                                 } else {
                                     $function = $onedited;
                                 }
                                 $render->connect("edited", $function, $obj['treeview'], $counter);
                             }
                             $attribute = "text";
                             $modelType = Gobject::TYPE_STRING;
                     }
                     // Cria a coluna
                     // @since rev 1
                     $trvColumn = new GtkTreeViewColumn($title, $render, $attribute, $counter);
                     $obj['treeview']->append_column($trvColumn);
                     // Verifica se existe parametrização do tamanho
                     // @since rev 1
                     if (isset($column['width'])) {
                         $trvColumn->set_fixed_width((int) $column['width']);
                         $trvColumn->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED);
                     }
                     // Verifica se existe parametrização da formatação
                     if (isset($column['onformat'])) {
                         $onformat = (string) $column['onformat'];
                         // Verifica se é orientado à objeto
                         if ($mainObject != NULL) {
                             $function = array($mainObject, $onformat);
                         } else {
                             $function = $onformat;
                         }
                         $trvColumn->set_cell_data_func($render, $function, $counter);
                     }
                 }
                 // Armazena o model
                 // @since rev 1
                 $columnModel[$counter++] = $modelType;
             }
             // Seta o model
             // @since rev 1
             $model = new GtkTreeStore();
             $model->set_column_types($columnModel);
             $obj['treeview']->set_model($model);
         }
     }
     return $obj;
 }
Ejemplo n.º 4
0
 public function onFullTextSearchClick()
 {
     if (!$this->manual) {
         // TODO: One might think aobut using an external browser or the online docs...
         $dialog = new \GtkMessageDialog($this->glade->get_widget('mainwindow'), 0, \Gtk::MESSAGE_ERROR, \Gtk::BUTTONS_OK, 'GtkHTML needed');
         $dialog->set_markup('For doing full text searches GtkHTML support is required in your PHP configuration.');
         $dialog->run();
         $dialog->destroy();
         return;
     }
     $input = trim($this->glade->get_widget('searchentry')->get_text());
     if (strlen($input) == 0) {
         $dialog = new \GtkMessageDialog($this->glade->get_widget('mainwindow'), 0, \Gtk::MESSAGE_ERROR, \Gtk::BUTTONS_OK, 'No input');
         $dialog->set_markup('No search term entered');
         $dialog->run();
         $dialog->destroy();
         return;
     }
     $results = $this->manual->searchFulltext($input);
     $store = new \GtkTreeStore(\GObject::TYPE_STRING, \GObject::TYPE_PHP_VALUE);
     foreach ($results as $title => $found) {
         $man_container = $store->append(null, array($title, null));
         $basenamelen = strlen('phar://' . $found->getArchiveFileName());
         echo 'phar://' . $found->getArchiveFileName(), "\n";
         foreach ($found as $item) {
             /** @var $item \SplFileObject */
             $doc = \DomDocument::loadHTMLFile($item->getPathname());
             $caption = $doc->getElementsByTagName('title')->item(0)->firstChild->wholeText;
             $store->append($man_container, array($caption, $item));
         }
     }
     $tree = $this->glade->get_widget('searchtreeview');
     $tree->set_model($store);
     $tree->get_selection()->connect('changed', array($this->mainWindow, 'onSearchResultClick'));
     /* TODO: Move to view  */
     $cell_renderer = new \GtkCellRendererText();
     $colExt = new \GtkTreeViewColumn('', $cell_renderer, 'text', 0);
     $tree->append_column($colExt);
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     parent::__construct(\GObject::TYPE_STRING, \GObject::TYPE_PHP_VALUE);
 }
 /**
  * Cria o treeview apartir de um XML
  * 
  * @name treeviewLoadXML
  * @param string $file Caminho do arquivo XML com as definições do treeview
  * @param object $mainObject Objeto onde está os métodos callback do treeview 
  */
 public function treeviewLoadXML($file, $mainObject = NULL)
 {
     // Lê o XML
     $xml = new SimpleXMLElement(file_get_contents($file));
     // Seta a coluna para a busca
     $searchcolumn = isset($xml['searchcolumn']) ? (int) $xml['searchcolumn'] : 0;
     parent::set_search_column($searchcolumn);
     // Configura a visibilidade do header da coluna
     switch (strtoupper((string) $xml['hvisible'])) {
         case "FALSE":
             $hvisible = FALSE;
             break;
         case "TRUE":
         default:
             $hvisible = TRUE;
             break;
     }
     parent::set_headers_visible($hvisible);
     // Verifica se existe evento button-press-event
     $buttonpressevent = (string) $xml['buttonpressevent'];
     if (strlen($buttonpressevent) > 0) {
         // Verifica se é orientado à objeto
         if ($mainObject != NULL) {
             // Cria o método callback
             $function = array($mainObject, $buttonpressevent);
         } else {
             // Cria a função callback
             $function = $buttonpressevent;
         }
         parent::connect("button-press-event", $function);
     }
     // Verifica se existe evento cursor-changed
     $cursorchanged = (string) $xml['cursorchanged'];
     if (strlen($cursorchanged) > 0) {
         // Verifica se é orientado à objeto
         if ($mainObject != NULL) {
             // Cria o método callback
             $function = array($mainObject, $cursorchanged);
         } else {
             // Cria a função callback
             $function = $cursorchanged;
         }
         parent::connect("cursor-changed", $function);
     }
     // Percorre as configurações
     foreach ($xml as $configs) {
         // Verifica se são as configurações das colunas
         if ($configs->getName() == "columns") {
             // Percorre as colunas
             $counter = 0;
             $columnModel = array();
             foreach ($configs as $column) {
                 // Busca as configurações
                 $title = (string) $column['title'];
                 $visible = (string) $column['visible'];
                 // Cria a coluna
                 $modelType = Gobject::TYPE_STRING;
                 if (strtoupper($visible) != "FALSE") {
                     // Verifica o tipo e o render
                     switch (strtoupper((string) $column['type'])) {
                         // Toggle
                         case "TOGGLE":
                             // Cria o render
                             $render = new GtkCellRendererToggle();
                             $render->set_property("activatable", TRUE);
                             // Verifica se deve usar o autocheck
                             switch (strtoupper((string) $column['autocheck'])) {
                                 case "FALSE":
                                     break;
                                 case "TRUE":
                                 default:
                                     $render->connect("toggled", array($this, "__onToggle"), $counter);
                                     break;
                             }
                             // Verifica se existe evento onclick da coluna
                             $onclick = (string) $column['onclick'];
                             if (strlen($onclick) > 0) {
                                 // Verifica se é orientado à objeto
                                 if ($mainObject != NULL) {
                                     // Cria o método callback
                                     $function = array($mainObject, $onclick);
                                 } else {
                                     // Cria a função callback
                                     $function = $onclick;
                                 }
                                 // Conecta o callback de check
                                 $render->connect("toggled", $function, $counter);
                             }
                             // Armazena o atributo e o model
                             $attribute = "active";
                             $modelType = Gobject::TYPE_BOOLEAN;
                             break;
                             // Texto
                         // Texto
                         case "TEXT":
                         default:
                             $render = new GtkCellRendererText();
                             // Verifica se a coluna é editavel
                             switch (strtoupper((string) $column['editable'])) {
                                 case "TRUE":
                                     $render->set_property("editable", TRUE);
                                     break;
                                 case "FALSE":
                                 default:
                                     break;
                             }
                             // Verifica se existe sinal para edição
                             $onedited = (string) $column['onedited'];
                             if (strlen($onedited) > 0) {
                                 // Verifica se é orientado à objeto
                                 if ($mainObject != NULL) {
                                     // Cria o método callback
                                     $function = array($mainObject, $onedited);
                                 } else {
                                     // Cria a função callback
                                     $function = $onedited;
                                 }
                                 // Conecta a coluna ao callback
                                 $render->connect("edited", $function, $this, $counter);
                             }
                             // Armazena os atributos
                             $attribute = "text";
                             $modelType = Gobject::TYPE_STRING;
                     }
                     // Cria a coluna com as configurações
                     $trvColumn = new GtkTreeViewColumn($title, $render, $attribute, $counter);
                     parent::append_column($trvColumn);
                     // Verifica se existe parametrização do tamanho da coluna
                     if (isset($column['width'])) {
                         $trvColumn->set_fixed_width((int) $column['width']);
                         $trvColumn->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED);
                     }
                     // Verifica se existe parametrização da formatação
                     if (isset($column['onformat'])) {
                         $onformat = (string) $column['onformat'];
                         // Verifica se é orientado à objeto
                         if ($mainObject != NULL) {
                             // Cria o método callback
                             $function = array($mainObject, $onformat);
                         } else {
                             // Cria a função callback
                             $function = $onformat;
                         }
                         // Conecta o callback de renderização
                         $trvColumn->set_cell_data_func($render, $function, $counter);
                     }
                 }
                 // Armazena o model
                 $columnModel[$counter++] = $modelType;
             }
             // Seta o model
             $model = new GtkTreeStore();
             $model->set_column_types($columnModel);
             parent::set_model($model);
         }
     }
 }