From: Csürke Tamás <linuxlinux1@windowslive.com>
To: pike lista <pike-devel@lists.lysator.liu.se>
Sent: Tue, August 3, 2010 11:38:47 AM
Subject: RE: gtk question
Thank you, it's very useful. And runs without problem, it creates the tree. But I even couldn't create a similar ComboBox. :(
I think based on your example that I should render the rows with a cellrenderer, but I don't know how or where...
#!/usr/bin/env pike
void get_text(GTK2.ComboBox w, mixed data) {
// string text=w->get_active_text();
int index=w->get_active();
// write("You chose: %s\n",text);
object tm=w->get_property("model");
// write("tm==%O\n",tm);
object iter=tm->get_iter(GTK2.TreePath((string)index));
mixed val=tm->get_value(iter,0);
write("val==%O\n",val);
}
int main(int argc, array argv) {
GTK2.setup_gtk();
object
w=GTK2.Window(GTK2.WINDOW_TOPLEVEL);
// GTK2.ListStore ls=GTK2.ListStore(({ "string" }));
object cb=GTK2.ComboBox("string");
cb->append_text("test 1");
cb->append_text("foo");
cb->append_text("fred");
cb->append_text("scooby");
w->add(cb);
w->show_all();
cb->signal_connect("changed",get_text,0);
w->signal_connect("destroy",lambda(){ exit(0); },0);
return -1;
}
Just modify it to add specific cell renderers as per the previous example.