[gtkada] more control when displaying numeric values by a Gtk_Cell_Renderer_Text

Rob Groen robgr at xs4all.nl
Tue Aug 18 11:27:53 CEST 2015


Emmanuel,

I followed your advice below and the example in testgtk and I got it 
working. There was perhaps one glitch.
When I run the program from the Xterm it all works fine. When I run it 
by double clicking from the filemanager the Gdoubles are display in 
their default form and I get an error (tested this by unsetting 
LD_LIBRARY_PATH in Xterm):

"(program:3369)): Gtk-CRITICAL **: 
gtk_tree_model_filter_set_modify_func: assertion 
'filter->priv->modify_func_set == FALSE' failed"


I am running Xubuntu, kernel version 3.13.0-53-generic, Ubuntu 14.04.3 LTS

I don't have LD_LIBRARY_PATH set system wide, because setting it to the 
GtkAda libraries severely disrupts the working of most pre-installed 
programs.
I only set it when working from an Xterm, then it is set to:
"/home/rob/ada/gtkada/lib:/usr/lib/i386-linux-gnu".

(Also, setting LD_LIBRARY_PATH must be accompanied by setting 
GDK_PIXBUF_MODULE_FILE to 
"/home/rob/ada/gtkada/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache")

Regards,
Rob

On 17-08-15 15:47, Emmanuel Briot wrote:
>> I have Gtk_List_Store with 1 column of Gtype_Double. In the corresponding Gtk_Tree_View I have a Gtk_Tree_Column with a Gtk_Cell_Renderer_Text (the renderer has attribute "text" added) to show the data. Now the data is shown in standard formatting, something like 1234.56789. But I want the data to be shown with 2 decimal places.
>> What I don't want to do is to add an extra column to the store (of type Gtype_String) and have the values stored there as strings.
>>
>> At first, Gtk_Tree_Cell_Data_Func seems an obvious choice, but the only thing you can do is add attributes to the renderer or change its properties. And there is no attribute/property that defines how to display Gtype_Doubles.
>>
>> How can I achieve more control on how numeric values are displayed by a Gtk_Cell_Renderer_Text?
> Rob,
>
> I think the intent from the gtk+ team is that people would create their own cell renderers here.
> This is not something we have already done in Ada, so I don't even know whether that is possible.
>
> Another approach you could explore is to use a Gtk_Tree_Model_Filter, which allows you to simulate
> extra columns. You could therefore simulate a text column, whose value is automatically computed
> from that of your double.
>
> The filter is useful in any case to implement dynamic filtering on a tree (as we do in a lot of places
> in GPS for instance), so the added cost is not that much.
>
> regards
> Emmanuel



More information about the gtkada mailing list