this is how I currently initialize the Tree view from the glade file (Removed the uninteresting parts)
tree_view <- xmlGetWidget xml castToTreeView "tree_view"
To make it easy, how could I add a new entry to the tree_view using the text from an already filled text field?
text <- get text_field entryText
May someone help me?
Thanks
From your description, I assume that you have a tree view, but haven't set it up properly. A GTK tree view is worth nothing if you don't connect it to several other widgets.
A tree model, which holds the data to be displayed in the tree view. The tree model can either be a list store, which stores data as a list, or a tree store, which stores the data as a tree, with nodes containing children. In your case, you'd probably need to create a ListStore:
Tree models can store data of any type, including complex custom data types.
A tree view column for each piece of data to be shown. In this case, we just need one column because we want to display one string per row:
The tree view column must know what data to show and how to display it (as text, as a tick box, as a picture...) So we need a cell renderer. The cell renderer will get a piece of data from each row in the tree model and show it in the given column. For displaying text, a CellRendererText is needed. There are other types of cell renderers for showing data in other forms (for instance CellRendererToggle for True/False values).
Next, insert the column into the tree view. If you don't do this, the column won't be shown!
And last but not least: connect the tree view to the tree model:
Now you should see an empty column in your tree view. See the documentation of the gtk package at http://hackage.haskell.org/package/gtk to learn how to insert, remove and get data to/from a tree model (listStoreAppend, listStoreRemove, listStoreGetValue etc.)
Note that every tree model has a type and can only work with data of that type (but you can use any data type, even your own, so you can indeed store and show rows of complex data provided you set up every tree view column correctly). Otherwise you will get a type error when compiling the program.