Re: Appending to treestore - how to set selection on new entry?



On 08/28/2018 04:24 PM, infirit wrote:
Next is to get the selection from your view with
gtk_tree_view_get_selection and call gtk_tree_selection_select_iter with
the toplevel iter from earlier. It should now have selected the newly
added row.

~infirit

Yes, thank you, that is what I did. The problem I had to solve was the reverse
of the appending case. There where toplevel is used, I am simply adding an
entry to the tree model. The case I had to solve was when the model was
completely filled and I had multiple views which could be associated with any
one instance contained in the model. The challenge was to take the focus on
any of the views and then go figure out which entry in the tree model the
focused textview buffer came from.

For example, here is the editor interface shown with the treeview and 3 editor
windows:

http://paste.opensuse.org/25076757

The task was to be able to click to place focus in any one of the edit
(textview) windows and have the selection automatically move to the associated
file. That's where using the "focus-in-event" signal from the textview allowed
getting the associated buffer which I could then iterate through the treemodel
and match with the buffer held in the model using the iterator to set the
selection.


-- 
David C. Rankin, J.D.,P.E.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]