function __create_completion_model() { $store = new GtkListStore(GObject::TYPE_STRING); $iter = $store->append(); $store->set($iter, 0, 'GNOME'); $iter = $store->append(); $store->set($iter, 0, 'total'); $iter = $store->append(); $store->set($iter, 0, 'totally'); $iter = $store->append(); $store->set($iter, 0, 'PHP'); $iter = $store->append(); $store->set($iter, 0, 'PHP-Gtk2'); return $store; }
function __create_treeview() { $this->load_demos(); $model = new GtkListStore(GObject::TYPE_PHP_VALUE, GObject::TYPE_STRING); // $model->append(array("asd", "aswdasd"));//??????? foreach ($this->demos as $demo) { $iter = $model->append(); $model->set($iter, 0, $demo); } $treeview = new GtkTreeView($model); $cell_renderer = new GtkCellRendererText(); $treeview->insert_column_with_data_func(-1, 'Demos', $cell_renderer, array(&$this, 'label_setter')); $selection = $treeview->get_selection(); $selection->set_mode(Gtk::SELECTION_SINGLE); $selection->connect('changed', array($this, 'demo_selected')); //crashes as gboxed can't be instantiated // $treeview->connect('row-activated', array($this, 'demo_activate')); // $column = new GtkTreeViewColumn(); // $column->set_title('Demos'); // $treeview->append_column($column); return $treeview; }
<?php //Create new store with two columns $store = new GtkListStore(Gobject::TYPE_STRING, Gobject::TYPE_LONG); //insert the rows at different positions $store->insert(1, array('Tokio', 34100000)); $store->insert(0, array('Mexico city', 22650000)); //use the iterator to set the data after insertion $iter = $store->insert(1); $store->set($iter, 0, 'Seoul', 1, 22250000);
private function create_model() { $store = new GtkListStore(GObject::TYPE_PHP_VALUE, GObject::TYPE_STRING); $ids = Gtk::stock_list_ids(); sort($ids); foreach ($ids as $id) { $info = new StockItemInfo($id); $stock_item = Gtk::stock_lookup($id); if ($stock_item) { $info->stock_item = $stock_item; } else { $info->stock_item = array('', '', 0, 0, ''); } $icon_set = GtkIconFactory::lookup_default($id); if ($icon_set) { $sizes = $icon_set->get_sizes(); $size = $sizes[0]; for ($i = 0; $i < count($sizes); $i++) { if ($sizes[$i] == Gtk::ICON_SIZE_MENU) { $size = Gtk::ICON_SIZE_MENU; break; } } $info->small_icon = $this->render_icon($info->stock_id, $size); if ($size != Gtk::ICON_SIZE_MENU) { list($width, $height) = Gtk::icon_size_lookup(Gtk::ICON_SIZE_MENU); $info->small_icon = $info->small_icon->scale_simple($width, $height, 'bilinear'); } } else { $info->small_icon = null; } if ($info->stock_item[3] == 0) { $info->accel_str = ''; } else { $info->accel_str = '<' . Gtk::accelerator_get_label($info->stock_item[3], $info->stock_item[2]) . '>'; } $iter = $store->append(); $store->set($iter, 0, $info, 1, $id); } return $store; }
function __create_completion_model() { $this->inputHTTP = $store = new GtkListStore(Gtk::TYPE_STRING); $iter = $store->append(); $store->set($iter, 0, 'GNOME'); return $store; }
<?php //Create new list store with string and number columns $store = new GtkListStore(Gobject::TYPE_STRING, Gobject::TYPE_LONG); //at first, get an iterator for a new row $iterator = $store->append(); //now use that to set the name at that row (column 0) $store->set($iterator, 0, 'Tokio'); //same row: set the inhabitants into column 1 $store->set($iterator, 1, 34100000); //You can set a whole row at once: $iterator = $store->append(); //we add the data "Mexico city" at column 0 and // "22 million" at column 1 at the row $iterator $store->set($iterator, 0, 'Mexico city', 1, 22650000); //Even faster: don't even create an iterator variable $store->set($store->append(), 0, 'Seoul', 1, 22250000);