[gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- From: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
- To: gtk-server@xxxxxxxxxxxxx
- Date: Sat, 06 Sep 2008 10:36:28 +0200
how do I make such a function myself with gtk-server without restorting
to FFI's, callback, etc.?
Well, you can't. A callback function can only be 'called back' by GTK
when the address in memory is known; and with interpreted programs,
this is impossible. Also, GTK cannot find some procedure or function
in a random client language, and execute it's code.
Therefore, you need another approach. Instead of registering a
callback function, just format and set the value in the cellrenderer
directly using the 'g_object_set' construct as explained earlier. This
also will cost you less CPU, because the callback version will always
render all cells (as is mentioned in the same tutorial).
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!
Hope this helps,
Peter
Quoting Erik Winkels <aerique@xxxxxxxxx>:
Hi Peter,
I don't like to come across as particularly dense but I'm afraid it is
unavoidable this time :-)
For the past hour I've been looking at the examples you've provided but
I just don't see how I can make a GtkTreeCellDataFunc from it
(http://library.gnome.org/devel/gtk/unstable//GtkTreeViewColumn.html#GtkTreeCellDataFunc). As used in
this
example:
- http://scentric.net/tutorial/sec-treeview-col-celldatafunc.html
The g_snprintf and g_object_set are used in the cell data function but
how do I make such a function myself with gtk-server without restorting
to FFI's, callback, etc.?
Also I have no previous experience with GTK and my C is pretty rusty as
well since I haven't used it in years, so forgive any obvious questions
please.
Erik
--
http://www.gtk-server.org
- References:
- [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- From: Erik Winkels
Other related posts:
- » [gtk-server] Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- » [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
how do I make such a function myself with gtk-server without restorting to FFI's, callback, etc.?
Hi Peter, I don't like to come across as particularly dense but I'm afraid it is unavoidable this time :-) For the past hour I've been looking at the examples you've provided but I just don't see how I can make a GtkTreeCellDataFunc from it(http://library.gnome.org/devel/gtk/unstable//GtkTreeViewColumn.html#GtkTreeCellDataFunc). As used in this
example:
- http://scentric.net/tutorial/sec-treeview-col-celldatafunc.html
The g_snprintf and g_object_set are used in the cell data function but
how do I make such a function myself with gtk-server without restorting
to FFI's, callback, etc.?
Also I have no previous experience with GTK and my C is pretty rusty as
well since I haven't used it in years, so forgive any obvious questions
please.
Erik
- [gtk-server] Re: Formatting floats (Was: gtk-server Digest V5 #3)
- From: Erik Winkels