Re: Displaying domain objects with GtkTreeView



On Thu, Nov 24, 2011 at 04:30:25PM +0100, RafaÅ KrupiÅski wrote:
How do I display list of custom objects in GtkTreeView?
GtkTreeView takes GtkListStore as a model, but it doesn't allow custom
objects, only list of gobjects.

On the other hand, when I want to read list's selection all I get is
the GtkListStore model - list of gobjets and I have to figure out the
actual domain object the data comes from.

I thought of adding a hidden column with some id, but maybe there is a
better solution?

What are you talking about?  You can pass any GObject-derived type as
the column type (not that it matters much, the net result is the same as
passing G_TYPE_OBJECT).  You get back the objects that you stored there.

If you store objects of different classes to the same column and want to
know the precise type use RTTI: type macros such as MY_IS_FOO(),
G_TYPE_FROM_INSTANCE(), g_type_is_a(), etc.

Yeti




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