/** * @name __construct() * @return Demo */ public function __construct() { // Cria a janela $this->widgets['frmDemo'] = new GtkWindow(); $this->widgets['frmDemo']->set_size_request(600, 300); $this->widgets['frmDemo']->set_position(Gtk::WIN_POS_CENTER_ALWAYS); $this->widgets['frmDemo']->connect("destroy", array($this, "frmDemo_unload")); $box = new GtkVBox(); // Adiciona o textview do resultado $this->widgets['txtResult'] = Fabula::GtkTextView(); $box->pack_start(Fabula::GtkViewPort($this->widgets['txtResult']), TRUE, TRUE); // Adiciona o textview dos comandos $this->widgets['txtCommands'] = Fabula::GtkEntry(); $box->pack_start($this->widgets['txtCommands'], FALSE, FALSE); $this->widgets['txtCommands']->grab_focus(); // Connecta o entry de comandos para capturar o botão enter $this->widgets['txtCommands']->connect("key-press-event", array($this, "txtCommands_onkeypress")); // Inicia o pipe $this->pipe = Fabula::PipeIO("/bin/sh", array()); $this->pipe->set_callback("stdout", array($this, "on_pipe_io_stdout")); $this->pipe->run(); // Inicia a aplicação $this->widgets['frmDemo']->add($box); $this->frmDemo_onload(); }
/** * @name __construct() * @return Demo */ public function __construct() { // Cria a janela $this->widgets['frmDemo'] = new GtkWindow(); $this->widgets['frmDemo']->set_size_request(800, 350); $this->widgets['frmDemo']->set_position(Gtk::WIN_POS_CENTER_ALWAYS); $this->widgets['frmDemo']->connect("destroy", array($this, "frmDemo_unload")); // Cria o editor $source = Fabula::GtkSourceEditor(); // Carrega o arquivo $source->load_file(__FILE__); // Risco para marcar a coluna $source->set_margin(80); $source->set_show_margin(TRUE); // Mostra o numero da linha $source->set_show_line_numbers(TRUE); // Habilita o uso de marcadores $source->set_show_line_markers(TRUE); // Tamanho do tab $source->set_tabs_width(8); // Ao quebrar a linha, manter posição ou voltar ao inicio da linha $source->set_auto_indent(TRUE); // Marcar a linha selecionada $source->set_highlight_current_line(TRUE); // Inicia a aplicação $this->widgets['frmDemo']->add(Fabula::GtkViewPort($source)); $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); //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(); }