php-gtk2 using GtkTreeView
| From: | Sander Knopper | Date: | Wed, 04 May 2005 16:32:44 +0000 |
| Subject: | php-gtk2 using GtkTreeView | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-5825@lists.php.net to get a copy of this message | ||
Hi all,
I'm trying to understand the stockbrowser a bit, especially the part about the
creation of objects which are then inserted into the GtkListStore.
I hope you could clarify what you're doing a bit for me.
From my point of view you are doing something like this, which I'm trying to
do as well. (a bit pseudo code):
<?php
class human {
public $firstname;
public $lastname;
function __construct ($_firstname, $_lastname) {
$this->firstname = $_firstname;
$this->lastname = $_lastname;
}
}
function set_firstname ($column, $cell, $model, $iter) {
$human_obj = $model->get_value($iter, 0);
$cell->set_property('text', $human_obj->firstname);
// With this last step I'm getting an error about a non-existent property
of "human_obj".
}
$model = new GtkListStore (Gtk::TYPE_STRING, Gtk::TYPE_STRING);
$human = new human ("Foo", "Bar");
$iter = $model->append ();
$model->set ($iter, 0, $human); // You ARE inserting an object (as in
stockbrowser) here right?
I'm getting an error about object to
string conversion, which seems logical
to me of course.
$tree = new GtkTreeView ($model);
$cell_renderer = new GtkCellRendererText ();
$tree->insert_column_with_data_function (-1, "Firstname", $cell_renderer,
"set_firstname");
/* Some code to add tree to window and show_all () ...... */