[gtk-server] Re: gtk-server Digest V5 #7

  • From: Erik Winkels <euqirea@xxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Tue, 9 Sep 2008 12:17:41 +0200

> Date: Tue, 9 Sep 2008 01:28:46 -0700
> From: "John Spikowski" <johnspikowski@xxxxxxxxx>
>
>> From: Erik Winkels <euqirea@xxxxxxxxx>
>> Date: Tue, 9 Sep 2008 09:09:02 +0200
>>
>> Still, wanting control over the amount of decimals should be one of the
>> most (of not the most) common cases.
>
> Isn't the hosting language's FORMAT function (our something similar)
> responsible for expressions processing and data formatting?

No, that's the whole problem.  Otherwise I wouldn't have had this conversation
with Peter :-)

My problem is this: I've got a column with monetary (floats) values that also
needs to be sortable.  If I tell GTK the column contains strings I can use
my hosting language's formatting and it'll look exactly the way I want it to,
but the numbers will also be sorted as strings which is incorrect, ie:

    1
    10
    11
    2
    3

instead of:

    1
    2
    3
    10
    11

I could temporarily use ugly hacks like putting zeroes in front of all the
numbers so they all will be of equal length.

Now, when I tell GTK the column contains floats GTK somehow insists on using
its own format and prints them all with six decimals in my case, no matter
what I fill the columns with.  So if I fill the model column like this:

    123
    987.6543
    777.12345678
    456.78
    912.45

It will be printed in the view like this:
 
    123.000000
    987.654300
    777.123456
    456.780000
    912.450000

Which is horrible if you want to display monetary values, but the sorting
does work ;-)

Hope this explains it.


Erik

Other related posts: