[gtkada] How can I make a GtkAda text cell renderer editable?

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Thu Oct 14 15:18:50 CEST 2010


On Thu, 14 Oct 2010 14:01:05 +0200, you wrote:

> I am trying to make a table with editable data using a Tree_View and an 
> associated Tree_Store. I am using a Gtk_Cell_Renderer_Text for all the 
> columns.
> 
> I set the Editable mode with:
> 
>   Set_Property(My_Text_Renderer,ModeProperty,Cell_Renderer_Mode_Editable)
> 
> If I read the property with Get_Property it has the desired value.
> 
> According to the reference manual, if you set this mode the renderer 
> should allow the user to edit the contents. However, my text columns are 
> not editable.
> 
> Is there something else that I need to do? How can I make the text 
> columns editable? Can you give me a pointer to some example?

Maybe this: a cell renderer does not change the model. It only creates an
editable widget upon its activation. Upon editing completion the widget
sends a signal to the renderer and that is it. So you want to commit the
changes made in that transient widget.

Specifically to the Gtk_Cell_Renderer_Text, you should catch the signal
"edited" and then put the new text into the model [you can also reject the
text in a more advanced UI, color it, etc].

The "edited" signal carries the model path with it, from which you can get
the iterator to the cell where to set the text into. (There is a call to
restore the iterator from a path string.) Note that this is only a path, so
if you have several editable cells per row, you should also do something in
order to detect which cell has been edited. E.g. you may use different
instances of Gtk_Cell_Renderer_Text, one per column etc.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



More information about the gtkada mailing list