Re: Do I _need_ a custom CellRenderer?



Am Samstag, den 06.06.2009, 08:35 +0000 schrieb Nathan Schulte:

> Now, I realize I could write a custom CellRenderer, or setup the
> set_cell_data_func callback, but I'm wondering if this is absolutely necessary
> (I'm thinking it is, but didn't want to whip it up if it wasn't).  The boost
> library has a method to convert the ptime object to an std::string, of which the
> CellRendererText would take care of.  Is there an easier(cleaner) option(method)
> of going about displaying this converted string than the aforementioned methods?

Yes, you need to use one of these methods in order to visualize objects
of custom type.

The easier way is to use the cell_data_func(). A custom cell renderer
would be way over the top just for implementing the conversion of
something to a string.  Generally, you'd only implement your own cell
renderer if you need to customize the user interface.

Writing a cell data function is no more difficult than any other signal
handler.  All it has to do to is to set a cell renderer property.  Just
a few lines of code, really.

Here's a code example from one of my own projects:
http://git.gnome.org/cgit/regexxer/tree/src/filetree.cc#n318

> I appreciate your help, as the archive seems to show quite a lot of inquiries
> about the TreeView and TreeModel architecture.

Don't worry.  It will start to make sense after a while. ;-)

--Daniel




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