/** * @name __construct * @return Demo */ public function __construct() { // Cria a janela $this->widgets['frmDemo'] = new GtkWindow(); $this->widgets['frmDemo']->set_size_request(500, 500); $this->widgets['frmDemo']->set_position(Gtk::WIN_POS_CENTER_ALWAYS); $this->widgets['frmDemo']->connect("destroy", array($this, "frmDemo_unload")); // Cria um TreeModel $model = new GtkListStore(GObject::TYPE_STRING, GObject::TYPE_STRING); // Cria um GtkTreeView $this->widgets['trvDemo'] = Fabula::GtkTreeView($model); //now, get the selection object of that view $selection = $this->widgets['trvDemo']->get_selection(); //we want to be able to select multiple rows $selection->set_mode(Gtk::SELECTION_MULTIPLE); $this->widgets['trvDemo']->set_size_request(484, 484); // Adiciona as colunas $this->widgets['trvDemo']->add_column(new GtkCellRendererText(), "Coluna 1", "text"); $this->widgets['trvDemo']->add_column(new GtkCellRendererText(), "Coluna 2", "text"); // Adiciona o highlight $this->widgets['trvDemo']->set_highlight("#C4C4FF", "#CEFFCE"); // Popula o model $this->widgets['trvDemo']->add_row(array("1x1", "1x2")); $this->widgets['trvDemo']->add_row(array("2x1", "2x2")); $this->widgets['trvDemo']->add_row(array("3x1", "3x2")); // Adiciona o container à janela $vbox = new GtkVBox(); $this->widgets['frmDemo']->add($vbox); // Adiciona o treeview ao container $vbox->pack_start(Fabula::GtkViewPort($this->widgets['trvDemo']), TRUE, TRUE); // Adiciona o container dos botões $hbox = new GtkHBox(); $vbox->pack_start($hbox, FALSE, FALSE); // Adiciona o botão para buscar o item selecionado $this->widgets['btnSelected'] = new GtkButton("Selecionado"); $this->widgets['btnSelected']->connect_simple("clicked", array($this, "btnSelected_onClick")); $hbox->pack_start($this->widgets['btnSelected']); // Adiciona o botão para remover o item selecionado $this->widgets['btnRemove'] = new GtkButton("Remove"); $this->widgets['btnRemove']->connect_simple("clicked", array($this, "btnRemove_onClick")); $hbox->pack_start($this->widgets['btnRemove']); // Inicia a aplicação $this->frmDemo_onload(); }
/** * @name __construct() * @return Demo */ public function __construct() { // Cria a janela $this->widgets['frmDemo'] = new GtkWindow(); $this->widgets['frmDemo']->set_size_request(500, 500); $this->widgets['frmDemo']->set_position(Gtk::WIN_POS_CENTER_ALWAYS); $this->widgets['frmDemo']->connect("destroy", array($this, "frmDemo_unload")); // Cria um TreeModel $model = new GtkListStore(GObject::TYPE_STRING, GObject::TYPE_STRING); // Cria um GtkTreeView $this->widgets['trvDemo'] = Fabula::GtkTreeView($model); $this->widgets['trvDemo']->set_size_request(484, 484); // Adiciona as colunas $this->widgets['trvDemo']->add_column(new GtkCellRendererText(), "#", "text"); $this->widgets['trvDemo']->add_column(new GtkCellRendererText(), "Nome", "text"); // Adiciona o treeview à janela $this->widgets['frmDemo']->add($this->widgets['trvDemo']); // Inicia a aplicação $this->frmDemo_onload(); }