Re: Using GParam in GtkTLCell.



Tim Janik <timj gtk org> writes:

> >   /* public for GTypeValueTable methods */
> >   union {
> >     gint	v_int;
> >     ...
> >     gpointer	v_pointer;
> >   } data[4];
> > };
> >          ^ an array of size 4?
> > 
> > Am I missing something here?  You only seem to use the first one.  The
> > reason I ask is that I would like to have the model fill in a GValue
> > when queried.  As a result, I was going to store the data for the model
> > as the data field of the GValue, but would rather not have it be any
> > bigger then it has to be.
> 
> the GValue structure is actually just meant to be used for
> short term value transfers, that is passing them around to
> callers and the like.
> as such, values around are mostly going to be stored on the
> stack, i.e. in automatic variables, so another 1 or 2 pointers
> shouldn't be much of an issue.
> you probably do not want to use GValue as the actuall storage
> backend for your model, model storage is usually implemented
> in pretty specific terms of what you actually want to model

_But_ we are also providing simple data-storage models - 
GtkListStore and GtkTreeStore. These needs to store per-column
data in generic form. These will be the most frequently
used models.

A full GValue is complete overkill for this because:

 a) the type is the same for every value in a column
 b) nothing that you would want to use for cell storage
    uses more than one of the 4 fields.

You don't want to use 36 bytes per model cell when you
only need to store 8!

Now, of course, Jonathan could write some code that switched
over G_TYPE_FUNDEMENTAL (G_VALUE_TYPE (value)) and dealt
with the types he knows about, but this is hard to maintain
and clumsy. It's considerably easier and more robust
simply to extract data[1] and store that.

Regards,
                                        Owen




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