showing and editing different types in same treeview column

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

showing and editing different types in same treeview column

Rob Groen

Hello,

In a GtkTreeView I want to show and edit in the same column different types of entities, e.g. integers, strings, enums. I would like to edit these entities using spinbutton, entry and combobox respectively. Also, some of the entities are editable, and some aren't.

What I can do is pack 3 different renderers in the treeview column, but that implies for each renderer a different column in the underlying tree/list-store to set the value and the editability of the renderer.

Is there a better / more convenient way to do this?

Regards,

Rob Groen


_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: showing and editing different types in same treeview column

Dmitry A. Kazakov
On 19/05/2016 07:23, Rob Groen wrote:
In a GtkTreeView I want to show and edit in the same column different types of entities, e.g. integers, strings, enums. I would like to edit these entities using spinbutton, entry and combobox respectively. Also, some of the entities are editable, and some aren't.

What I can do is pack 3 different renderers in the treeview column, but that implies for each renderer a different column in the underlying tree/list-store to set the value and the editability of the renderer.

You can use single text renderer and use custom Set_Cell_Data function to set the renderer's "text" property to whatever text you want it to show.
-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: showing and editing different types in same treeview column

Rob Groen
On 19-05-16 08:58, Dmitry A. Kazakov wrote:

You can use single text renderer and use custom Set_Cell_Data function
to set the renderer's "text" property to whatever text you want it to show.
 >
 > it is not the showing of the cell contents that is the problem, it is
editing the cell. For integer types I want to
 > use a spinbutton, for enums a combo box and for strings an entry. How
do I arrange that in one treeview
 > column without packing different renderers and needing additional
columns in the store to set the editability
 > of the renderers
 >
 > regards, Rob
_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: showing and editing different types in same treeview column

Nicolas Soubeiran
In reply to this post by Rob Groen
Hello,
If you want to set your cell editable or not use the "Editing_Properties" of Gtk.Cell_Renderer.

For edition you have 2 solutions :
1. You implement your own Gtk.Cell_Renderer_Text, and you use the Gtk.Cell_Editable interface to customize edition on the cell : see Start_Editing (for displaying the "good" widget), On_Editing_Done (when user validate the value) and Remove_Widget (when user cancel action) subprograms.
2.  add 3 cellrenderers in your Treeview Column : Gtk.Cell_Renderer_Spin (for integer), Gtk.Cell_Renderer_Combo (for enum), and Gtk_Cell_Renderer_Text (for string) and use the "visible" property to show the "good" cell_renderer and hide the 2 others.

The first solution is the cleanest, but if you lack time the second will fit your need.
regards




_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: showing and editing different types in same treeview column

Rob Groen
On 20-05-16 17:43, Nicolas Soubeiran wrote:
Sorry, for my 2nd point; I didn't read enough you first mail. My apologies.
Then like said Dmitry A. Kazakov, if you do not want to use the underlying model to store the editability of the cell, you have to use Set_Cell_Data to set the editability property. FWIW : it is more efficient to map property of tree model to an attribute of a treeview column cell than use the Set_Cell_Data subprogram since Set_Cell_Data will be called each time the treeview has to be refreshed (e.g on mouse hover)
regards
Ok, will take this into account
2016-05-20 13:46 GMT+02:00 Nicolas Soubeiran <[hidden email]>:
Hello,
If you want to set your cell editable or not use the "Editing_Properties" of Gtk.Cell_Renderer.

For edition you have 2 solutions :
1. You implement your own Gtk.Cell_Renderer_Text, and you use the Gtk.Cell_Editable interface to customize edition on the cell : see Start_Editing (for displaying the "good" widget), On_Editing_Done (when user validate the value) and Remove_Widget (when user cancel action) subprograms.
2.  add 3 cellrenderers in your Treeview Column : Gtk.Cell_Renderer_Spin (for integer), Gtk.Cell_Renderer_Combo (for enum), and Gtk_Cell_Renderer_Text (for string) and use the "visible" property to show the "good" cell_renderer and hide the 2 others.

The first solution is the cleanest, but if you lack time the second will fit your need.
regards
Thanks, will try 2nd solution first (quickest) and will try (as an exercise :-)) the 1st when more time is avalaible. Thanks
Regards. Rob


_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada