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

  • From: Erik Winkels <aerique@xxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Sun, 07 Sep 2008 13:50:20 +0200

Hi Peter,

An update:

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've tried it with this method but I've had no succes so far, but I'm also not in the most conductive environment for programming at the moment (family life).

What I've done: 1) g_malloc some address space, 2) g_snprintf the value to it (g_printf prints that value so it's there), 3) set it with g_object_set and finally 4) g_free the address space.

Points 2 and 3 happen during the loop where I'm filling the list store. The other columns are being set with gtk_list_store_set and show their correct values so I assume the iter is on the correct line.

What happens is the column for which the cell renderer is g_object_set just shows "0.000000" for every line in the column.

Would it be possible for gtk-server to provide the callback function to control the amount of decimals that are printed in a column? I realize this might start a flood of utility function requests and it also doesn't conform to the design of gtk-server perhaps, but on the other hand wanting to control the amount of decimals being printed isn't that uncommon :-)


Regards,
Erik

Other related posts: