public function __construct() { $this->frame = new GtkFrame(); $frameBox = new GtkVBox(false, 10); $frameBox->set_border_width(10); $titleBox = new GtkHBox(false, 10); $titleLabel = new GtkLabel("User Roles"); $titleLabel->set_markup("<span weight='bold'>User Roles</span>"); $titleLabel->set_alignment(0, 0.5); $this->statusLabel = new GtkLabel(""); $this->statusLabel->set_alignment(1, 0.5); $titleBox->pack_start($titleLabel, true, true, 0); $titleBox->pack_end($this->statusLabel, true, true, 0); $frameBox->pack_start($titleBox, false, false, 0); $this->frame->add($frameBox); $this->roleListStore = new GtkRefListStore(Gobject::TYPE_STRING); $this->roleListTree = new GtkRefTreeView($this->roleListStore); $this->roleListTree->set_headers_visible(false); $roleListSelection = $this->roleListTree->get_selection(); $roleListSelection->set_mode(Gtk::SELECTION_SINGLE); $roleListSelection->connect('changed', array($this, 'selectRoleToRemove')); $rolesWindow = new GtkScrolledWindow(); $rolesWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); $rolesWindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN); $rolesWindow->add($this->roleListTree); $frameBox->pack_start($rolesWindow, true, true, 0); $renderer = new GtkCellRendererText(); $renderer->set_property("editable", false); $column = new GtkTreeViewColumn('Role', $renderer, "text", 0); $column->set_expand(true); $column->set_resizable(false); $this->roleListTree->append_column($column); $this->roleComboStore = new GtkRefListStore(Gobject::TYPE_STRING); $this->roleComboStore->refInsert(RoleEnum::getList()); $this->roleCombo = new GtkRefComboBox($this->roleComboStore); $roleCell = new GtkCellRendererText(); $roleCell->set_property('ellipsize', Pango::ELLIPSIZE_END); $this->roleCombo->pack_start($roleCell); $this->roleCombo->set_attributes($roleCell, 'text', 0); $this->roleCombo->connect('changed', array($this, 'selectRoleToAdd')); $this->addButton = new GtkButton("Add"); $this->addButton->set_sensitive(false); $this->removeButton = new GtkButton("Remove"); $this->removeButton->set_sensitive(false); $this->enableForm(false); $buttonBox = new GtkHBox(false, 8); $buttonBox->pack_end($this->removeButton, false, false, 0); $buttonBox->pack_end($this->addButton, false, false, 0); $buttonBox->pack_end($this->roleCombo, true, true, 0); $frameBox->pack_end($buttonBox, false, false, 0); }
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; }
public function __construct() { $this->frame = new GtkFrame(); $frameBox = new GtkVBox(false, 10); $frameBox->set_border_width(10); $titleBox = new GtkHBox(false, 10); $titleLabel = new GtkLabel("Users"); $titleLabel->set_markup("<span weight='bold'>Users</span>"); $titleLabel->set_alignment(0, 0.5); $this->statusLabel = new GtkLabel(""); $this->statusLabel->set_alignment(1, 0.5); $titleBox->pack_start($titleLabel, true, true, 0); $titleBox->pack_end($this->statusLabel, true, true, 0); $frameBox->pack_start($titleBox, false, false, 0); $this->frame->add($frameBox); $this->userListStore = new GtkRefListStore(Gobject::TYPE_STRING, Gobject::TYPE_STRING, Gobject::TYPE_STRING, Gobject::TYPE_STRING, Gobject::TYPE_STRING); $this->userListTree = new GtkRefTreeView($this->userListStore); $this->userListTree->set_rules_hint(true); $usersWindow = new GtkScrolledWindow(); $usersWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); $usersWindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN); $usersWindow->add($this->userListTree); $frameBox->pack_start($usersWindow, true, true, 0); $cols = array('Username', 'First Name', 'Last Name', 'Email', 'Department'); foreach ($cols as $num => $item) { $renderer = new GtkCellRendererText(); $renderer->set_property("editable", false); $column = new GtkTreeViewColumn($item, $renderer, "text", $num); $column->set_sort_column_id($num); $column->set_expand(true); $column->set_resizable(true); $this->userListTree->append_column($column); } $userSelection = $this->userListTree->get_selection(); $userSelection->set_mode(Gtk::SELECTION_SINGLE); $userSelection->connect('changed', array($this, 'isSelected')); $this->newButton = new GtkButton("New"); $this->newButton->connect('clicked', array($this, 'deSelect')); $this->delButton = new GtkButton("Delete"); $this->delButton->set_sensitive(false); $this->delButton->connect('clicked', array($this, 'confirmDeletion')); $buttonBox = new GtkHBox(false, 8); $buttonBox->pack_end($this->newButton, false, false, 0); $buttonBox->pack_end($this->delButton, false, false, 0); $frameBox->pack_end($buttonBox, false, false, 0); }
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(); }
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']; }
/** * 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(); }
function new_column($label, $cell_type, $index) { //check cell type if ($cell_type == 'text') { $this->celulas[$index] = new GtkCellRendererText(); } elseif ($cell_type == 'active') { $this->celulas[$index] = new GtkCellRendererToggle(); $this->celulas[$index]->connect('toggled', array($this, 'sel_toggled')); } elseif ($cell_type == 'pixbuf') { $this->celulas[$index] = new GtkCellRendererPixbuf(); } $column = new GtkTreeViewColumn($label, $this->celulas[$index], $cell_type, $index); $column->set_reorderable(true); $column->set_sort_column_id($index); $column->set_resizable(true); $column->connect('clicked', array($this, 'column_clicked')); $this->treeview->append_column($column); return $column; }
/** * 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); }
/** * 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); }
/** * 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 column (or more columns if you give it an array instead of a string) to a GtkTreeView(). Saves code. * @param GtkTreeView $treeview The treeview which the function should add columns to. * @param mixed $arrcolumn As a string, this would be the title of the one column added. As an array, this should be all the titles which should be added to the treeview as strings in the array. */ function treeview_addColumn(GtkTreeView $treeview, $arrcolumn){ if (is_array($arrcolumn) && !$arrcolumn["type"] && !$arrcolumn["title"]){ //Adding a liststore to the treeview. $eval = "\$ls = new GtkListStore("; $first = true; foreach($arrcolumn AS $column){ if ($first == true){ $first = false; }else{ $eval .= ", "; } if (!is_array($column)){ $type = "text"; }else{ $type = $column["type"]; } if ($type == "text"){ $eval .= "_TYPE_STRING"; }elseif($type == "active"){ $eval .= "_TYPE_BOOLEAN"; }elseif($type == "int"){ $eval .= "_TYPE_LONG"; }else{ throw new Exception("Invalid type: " . $type); } $count++; } $eval .= ");"; eval($eval); $treeview->set_model($ls); $treeview->set_enable_search(true); //Add columns to the treeview. foreach($arrcolumn AS $value){ treeview_addColumn($treeview, $value); } }else{ $number = count($treeview->get_columns()); if (is_array($arrcolumn)){ $type = $arrcolumn["type"]; $title = $arrcolumn["title"]; }else{ $title = $arrcolumn; $type = "text"; } if ($type == "text" || $type == "int"){ $render = new GtkCellRendererText(); $type = "text"; }elseif($type == "active"){ $render = new GtkCellRendererToggle(); $render->set_property("activatable", true); }else{ throw new Exception("Invalid type: " . $type); } if (is_array($arrcolumn["connect"])){ foreach($arrcolumn["connect"] AS $key => $value){ $render->connect_after($key, $value); } } $column = new GtkTreeViewColumn($title, $render, $type, $number); $column->set_reorderable(true); $column->set_resizable(true); $column->set_clickable(true); $column->set_sort_column_id($number); $treeview->append_column($column); if (is_array($arrcolumn)){ if ($arrcolumn["hidden"] == true){ $column->set_visible(false); } if ($arrcolumn["searchcol"] == true){ $treeview->set_search_column($number); } if ($arrcolumn["sortcol"] == true){ if ($arrcolumn["sort"] == "desc"){ $treeview->get_model()->set_sort_column_id($number, Gtk::SORT_DESCENDING); }else{ $treeview->get_model()->set_sort_column_id($number, Gtk::SORT_ASCENDING); } } } } }
/** * 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++; } }
$column->set_title('Product Name'); $view->insert_column($column, 0); // Create a renderer for the column. $cell_renderer = new GtkCellRendererText(); $column->pack_start($cell_renderer, true); $column->set_attributes($cell_renderer, 'text', 0); // Create columns for each type of data. $column = new GtkTreeViewColumn(); $column->set_title('Inventory'); $view->insert_column($column, 1); // Create a renderer for the column. $cell_renderer = new GtkCellRendererText(); $column->pack_start($cell_renderer, true); $column->set_attributes($cell_renderer, 'text', 1); // Create columns for each type of data. $column = new GtkTreeViewColumn(); $column->set_title('Price'); $view->insert_column($column, 2); // Create a renderer for the column. $cell_renderer = new GtkCellRendererText(); $column->pack_start($cell_renderer, true); $column->set_attributes($cell_renderer, 'text', 2); // Create a window and show everything. $window = new GtkWindow(); $window->add($view); $window->show_all(); $window->connect_simple('destroy', array('gtk', 'main_quit')); gtk::main(); /* * Local variables: * tab-width: 4