/** * This returns the selected items for a GtkTreeView() (if it is possible to select more items). Saves code. * @param GtkTreeView $treeview The treeview for which the function should return values. */ function treeview_getAll(GtkTreeView $treeview){ $columns = $treeview->get_columns(); $model = $treeview->get_model(); $return = array(); $first = true; while(true){ if ($first == true){ $iter = @$model->get_iter_first(); $first = false; }else{ $iter = $model->iter_next($iter); } if (!$iter){ break; } foreach($columns AS $key => $column){ $value = $model->get_value($iter, $key); $return_new[$key] = $value; } $return[] = array("values" => $return_new, "iter" => $iter); } return $return; }
/** * Cria o estilo zebra * * @name set_highlight * @param string $colorA Cor das linhas impares em hexadecimal * @param string $colorB Cor das linhas pares em hexadecimal */ public function set_highlight($colorA, $colorB) { // Percorre as colunas do treeview $columns = parent::get_columns(); foreach ($columns as $column) { // Recupera o render $renders = $column->get_cell_renderers(); // Adiciona o callback com as cores $column->set_cell_data_func($renders[0], array($this, "__highlight_onRender"), $colorA, $colorB); } }