function construir_dialogo($id_proyecto = null) { $archivo = dirname(__FILE__) . '/toba.glade'; $glade = new GladeXML($archivo, 'vbox'); foreach (self::$comp_req as $comp) { $this->comp[$comp] = $glade->get_widget($comp); } $glade->signal_autoconnect_instance($this); //--- Arbol $columna = new GtkTreeViewColumn('Comandos'); $renderer = new GtkCellRendererPixbuf(); $columna->pack_start($renderer, false); $columna->set_attributes($renderer, 'pixbuf', 1); $renderer = new GtkCellRendererText(); $columna->pack_start($renderer, true); $columna->set_attributes($renderer, 'text', 0); $this->comp['arbol_comandos']->append_column($columna); $seleccionado = $this->cargar_comandos($id_proyecto); $selection = $this->comp['arbol_comandos']->get_selection(); $selection->set_mode(Gtk::SELECTION_SINGLE); $selection->connect('changed', array($this, 'evt__seleccionar_comando')); if (isset($seleccionado)) { $selection->select_iter($seleccionado); } //$this->connect('button-release-event', array($this, 'evt__popup')); return $this->comp['vbox']; }
function __construct($parent = null) { parent::__construct(); if ($parent) { $this->set_screen($parent->get_screen()); } else { $this->connect_simple('destroy', array('gtk', 'main_quit')); } $this->set_title(__CLASS__); $this->set_position(Gtk::WIN_POS_CENTER); $this->set_default_size(-1, 500); $this->set_border_width(8); $hbox = new GtkHBox(false, 8); $this->add($hbox); $scrolled = new GtkScrolledWindow(); $scrolled->set_shadow_type(Gtk::SHADOW_ETCHED_IN); $scrolled->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); $hbox->pack_start($scrolled, false, false, 0); $model = $this->create_model(); $treeview = new GtkTreeView($model); $scrolled->add($treeview); $column = new GtkTreeViewColumn(); $column->set_title('Icon and Constant'); $cell_renderer = new GtkCellRendererPixbuf(); $column->pack_start($cell_renderer, false); $column->set_attributes($cell_renderer, 'stock-id', 1); $cell_renderer = new GtkCellRendererText(); $column->pack_start($cell_renderer, true); $column->set_cell_data_func($cell_renderer, 'constant_setter'); $treeview->append_column($column); $cell_renderer = new GtkCellRendererText(); $treeview->insert_column_with_data_func(-1, 'Label', $cell_renderer, 'label_setter'); $cell_renderer = new GtkCellRendererText(); $treeview->insert_column_with_data_func(-1, 'Accelerator', $cell_renderer, 'accel_setter'); $cell_renderer = new GtkCellRendererText(); $treeview->insert_column_with_data_func(-1, 'ID', $cell_renderer, 'id_setter'); $align = new GtkAlignment(0.5, 0, 0, 0); $hbox->pack_end($align, true, true, 0); $frame = new GtkFrame('Selection Info'); $align->add($frame); $vbox = new GtkVBox(false, 8); $vbox->set_border_width(4); $frame->add($vbox); $display = new StockItemDisplay(); $treeview->set_data('stock-display', $display); $display->type_label = new GtkLabel(); $display->constant_label = new GtkLabel(); $display->id_label = new GtkLabel(); $display->accel_label = new GtkLabel(); $display->icon_image = new GtkImage(); $vbox->pack_start($display->type_label, false, false, 0); $vbox->pack_start($display->icon_image, false, false, 0); $vbox->pack_start($display->accel_label, false, false, 0); $vbox->pack_start($display->constant_label, false, false, 0); $vbox->pack_start($display->id_label, false, false, 0); $selection = $treeview->get_selection(); $selection->set_mode(Gtk::SELECTION_SINGLE); $selection->connect('changed', array($this, 'on_selection_changed')); $this->show_all(); }
/** * Construct treeview */ function __construct() { parent::__construct(); parent::set_headers_visible(FALSE); $this->model = new GtkTreeStore(GObject::TYPE_OBJECT, GObject::TYPE_STRING, GObject::TYPE_PHP_VALUE, GObject::TYPE_STRING); parent::set_model($this->model); parent::connect('row-activated', array($this, 'onClick')); $column1 = new GtkTreeViewColumn(); $cell_renderer1 = new GtkCellRendererPixbuf(); $cell_renderer2 = new GtkCellRendererText(); $column1->pack_start($cell_renderer1, false); $column1->pack_start($cell_renderer2, false); $column1->set_attributes($cell_renderer1, 'pixbuf', 0); $column1->set_attributes($cell_renderer2, 'text', 1); parent::append_column($column1); }
function __create_box() { $box = new GtkVBox(); $box->pack_start(new GtkLabel('Double click with the mouse on a file, or select by key and press return'), false); $paned = new GtkHPaned(); $paned->set_position(200); //filename, markup-filename, fullpath, is_dir, preview image $mFile = new GtkListStore(GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_BOOLEAN, GdkPixbuf::gtype); $mFile->set_sort_column_id(0, Gtk::SORT_ASCENDING); $vFile = new GtkTreeView($mFile); $col = new GtkTreeViewColumn('Image', new GtkCellRendererPixbuf(), 'pixbuf', 4); $text = new GtkCellRendererText(); $col->pack_start($text); $col->add_attribute($text, 'markup', 1); $vFile->append_column($col); $vFile->set_headers_visible(false); $vFile->connect('key-press-event', array($this, 'onPressFile')); $vFile->connect('button-press-event', array($this, 'onPressFile')); /* GtkIconView has some problems with text that are too long and missing icons $vFile = new GtkIconView(); $vFile->set_model($mFile); $vFile->set_columns(1); $vFile->set_pixbuf_column(3); $vFile->set_text_column(0); $vFile->set_item_width(100); */ $this->loadFiles($mFile, getcwd()); $scrwndFiles = new GtkScrolledWindow(); $scrwndFiles->add($vFile); $scrwndFiles->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); $vboxFile = new GtkVBox(); $vboxFile->pack_start($scrwndFiles); $chkImg = new GtkCheckbutton('Load preview images'); $chkImg->set_active(true); $chkImg->connect('toggled', array($this, 'onCheckPreview')); $vboxFile->pack_start($chkImg, false); $paned->add1($vboxFile); $this->img = new GtkImage(); $scrwndImg = new GtkScrolledWindow(); $scrwndImg->add_with_viewport($this->img); $scrwndImg->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); $paned->add2($scrwndImg); $box->pack_end($paned); return $box; }
/** * Class Constructor * @param $name = Name of the column in the database * @param $label = Text label that will be shown in the header * @param $align = Column align (left, center, right) * @param $width = Column Width (pixels) */ public function __construct($name, $label, $align, $width = NULL) { $this->name = $name; $this->label = $label; $this->align = $align; $this->width = (int) $width; if ($align == 'left') { $alignment = 0.0; } else { if ($align == 'center') { $alignment = 0.5; } else { if ($align == 'right') { $alignment = 1.0; } } } parent::__construct(); $this->renderer = new GtkCellRendererText(); if ($width) { $this->renderer->set_property('width', $width); parent::set_fixed_width($width); } $this->renderer->set_property('xalign', $alignment); parent::pack_start($this->renderer, true); parent::set_alignment($alignment); parent::set_title($label); $header_hbox = new GtkHBox(); $header_label = new GtkLabel($this->label); $header_hbox->pack_start($header_label); $this->sort_up = GtkImage::new_from_stock(GTK::STOCK_GO_UP, Gtk::ICON_SIZE_MENU); $this->sort_down = GtkImage::new_from_stock(GTK::STOCK_GO_DOWN, Gtk::ICON_SIZE_MENU); $header_hbox->pack_start($this->sort_up); $header_hbox->pack_start($this->sort_down); $header_hbox->show_all(); // hide the ordering images $this->sort_up->hide(); $this->sort_down->hide(); parent::set_widget($header_hbox); }
/** * Class Constructor * @param $name widget's name */ function __construct($name) { parent::__construct($name); $this->widget = new GtkScrolledWindow(); $this->widget->set_policy(GTK::POLICY_AUTOMATIC, GTK::POLICY_ALWAYS); parent::add($this->widget); $this->tree = new GtkTreeView(); $this->tree->connect_simple('select-cursor-row', array($this, 'onPreExecuteExitAction')); $this->tree->connect_simple('button-press-event', array($this, 'onPreExecuteExitAction')); $this->model = new GtkListStore(GObject::TYPE_STRING, GObject::TYPE_STRING); $this->tree->set_model($this->model); $this->tree->set_headers_visible(FALSE); $this->tree->set_rubber_banding(TRUE); $this->tree->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); $column = new GtkTreeViewColumn(); $cell_renderer = new GtkCellRendererText(); $column->pack_start($cell_renderer, true); $column->add_attribute($cell_renderer, 'text', 1); $this->tree->append_column($column); $this->widget->add($this->tree); parent::show_all(); }
/** * Add a field to the MultiField * @param $name Widget's name * @param $text Widget's label * @param $object Widget * @param $size Widget's size * @param $inform Show the Widget in the form */ public function addField($name, $text, GtkObject $object, $size, $mandatory = FALSE) { if ($this->orientation == 'horizontal') { if (count($this->fields) == 0) { $this->row_label = $this->table_fields->addRow(); $this->row_field = $this->table_fields->addRow(); } } else { $row = $this->table_fields->addRow(); $this->row_label = $row; $this->row_field = $row; } $label = new TLabel("<i>{$text}</i>"); if ($mandatory) { $label->setFontColor('#FF0000'); } $n = $this->count; $object->setName("{$this->name}_text{$n}"); $this->row_label->addCell($label); $this->row_field->addCell($object); $this->fields[$name] = array($text, $object, $size, FALSE, $mandatory); $this->allfields[$name] = array($text, $object, $size, FALSE, $mandatory); if (get_class($object) == 'TComboCombined') { $column = new GtkTreeViewColumn('ID'); } else { $column = new GtkTreeViewColumn($text); } $cell_renderer = new GtkCellRendererText(); $cell_renderer->set_property('width', $size); $column->set_fixed_width($size); $column->pack_start($cell_renderer, true); $column->add_attribute($cell_renderer, 'text', $this->count); $this->types[] = GObject::TYPE_STRING; $this->view->append_column($column); $this->columns[$name] = $this->count; $this->count++; // combocombined, need to add one more column and treat different if (get_class($object) == 'TComboCombined') { $cell_renderer->set_property('width', 20); $column->set_fixed_width(20); $tname = $object->getTextName(); $this->fields[$tname] = array($text, $object, $size, TRUE, $mandatory); $this->fields[$name][2] = 20; $this->allfields[$name][2] = 20; $column = new GtkTreeViewColumn($text); $cell_renderer = new GtkCellRendererText(); $cell_renderer->set_property('width', $size); $column->set_fixed_width($size); $column->pack_start($cell_renderer, true); $column->add_attribute($cell_renderer, 'text', $this->count); $this->types[] = GObject::TYPE_STRING; $this->view->append_column($column); $this->allfields[$tname] = array($text, $object, $size, TRUE, $mandatory); $this->columns[$tname] = $this->count; $this->count++; } }
/** * Add a field to the MultiField * @param $name Widget's name * @param $text Widget's label * @param $object Widget * @param $size Widget's size * @param $inform Show the Widget in the form */ public function addField($name, $text, GtkObject $object, $size, $inform = TRUE) { if ($inform) { $row = $this->table_fields->addRow(); $label = new TLabel("<i>{$text}</i>"); $n = $this->count; $object->setName("{$this->name}_text{$n}"); $row->addCell($label); $row->addCell($object); $this->fields[$name] = array($text, $object, $size, FALSE); } $this->allfields[$name] = array($text, $object, $size, FALSE); if (get_class($object) == 'TComboCombined') { $column = new GtkTreeViewColumn('ID'); } else { $column = new GtkTreeViewColumn($text); } $cell_renderer = new GtkCellRendererText(); $column->pack_start($cell_renderer, true); $column->add_attribute($cell_renderer, 'text', $this->count); $this->types[] = GObject::TYPE_STRING; $this->view->append_column($column); $this->columns[$name] = $this->count; $this->count++; // combocombined, need to add one more column and treat different if (get_class($object) == 'TComboCombined') { $tname = $object->getTextName(); $this->fields[$tname] = array($text, $object, $size, TRUE); $column = new GtkTreeViewColumn($text); $cell_renderer = new GtkCellRendererText(); $column->pack_start($cell_renderer, true); $column->add_attribute($cell_renderer, 'text', $this->count); $this->types[] = GObject::TYPE_STRING; $this->view->append_column($column); $this->allfields[$tname] = array($text, $object, $size, TRUE); $this->columns[$tname] = $this->count; $this->count++; } }