예제 #1
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;
 }
예제 #2
0
 /**
  * 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();
 }
예제 #3
0
 /**
  * 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++;
     }
 }
예제 #4
0
 /**
  * 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++;
     }
 }