Re: [Vala] gtk treeview (one column) example



oops. missing attachment O:)


On Fri, Nov 09, 2007 at 05:22:51AM +0100, pancake wrote:
On Thu, Nov 08, 2007 at 06:36:08PM +0100, J?rg Billeter wrote:
On Thu, 2007-11-08 at 14:43 +0100, pancake wrote:
Here's a one column example for using gtktreeview with Vala.

Maybe the code can be better, but it works, and imho is most ok.

the treeview is one of the most complicated things to manage with gtk, so
a good documentation for it would be good.

The example is attached.

You should be able to use

string foo;
?tv.model.get(ref iter, 0, out foo);

Oh yes, sorry. I missed that point. but what about passing:

  tv.model.get(ref iter, 0, foo.str);

does this code leaks?

to retrieve a string. Your version will lead to a memory leak as the
preallocated GString will be replaced by the string allocated by the
tree model.

I remember to had problems with this, and the only way to get no segfaults
was to allocate a statically sized string passing it as argument for the
tv.model.get, so at C level this is a "char*", and makes gcc not cry
with warnings or so. But that's not clean for my eyes.

But I have fixed that on the source. Take a look on the attachment.

What about adding this example after the simplification to the Wiki?

What's clener for you? Store ListStore twice inside tv.model and on a private
variable? or cast it everytime ((ListStore)tv.model).xxx ?



--pancake
_______________________________________________
Vala mailing list
Vala paldo org
http://www.paldo.org/mailman/listinfo/vala

Attachment: list.vala
Description: Text document



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]