[gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)

  • From: Erik Winkels <euqirea@xxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Mon, 8 Sep 2008 10:21:26 +0200

Hi Peter,

First of all thanks for you patience :-)  Although I've been programming for
the better part of my life this is actually the first time I'm seriously
using a GUI library.

Things are finally starting to sink in and your last post and example have
explained a lot, but one thing is still causing me problems which isn't
explained by your example either:

> Date: Sat, 06 Sep 2008 10:36:28 +0200
> From: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
> Subject: [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5
> So, make sure the iter has the correct line in the table, and create a
> separate cellrenderer for the column where you store the float values.
> Then format your value with 'g_snprintf' and set the value with
> g_object_set. Don't forget to redefine some of the GTK/GLib calls
> correctly! 

I don't know how I can make sure the iter is on the correct line when the
view is getting drawn.  I do know on which line the iter is when I'm filling
the model but setting the cell renderer text property is of little use then,
because when the view is shown each line of the column will show the value
the text property was last set to during the initialisation of the model.

Or, more concrete: in your example if you do not want to display 1.23 but
a different value on each line... how would you do that?

Would I need to make an event for each time the cell is going to get drawn
and set the text property then?  This solution would bring a whole lot of
extra code and complexity with it since my list store has got nine columns,
each of which can be sorted, of which two need to display monetary values.

(I don't even known whether it's possible to set an event for this since
I really do not want to go into this direction :-) )


Other related posts: