I ran into something similar in the past with clists. Below is code
that finds the selected rows in a Clist. A CTree is extended from a
CList, so the code should be very similar
GListPtr = my_clist.row_list;
for (j=0;j<my_clist.rows;j++){
GtkCListRowPtr = GTK_CLIST_ROW(GListPtr);
GListPtr=GListPtr->next;
if ( GtkCListRowPtr->state != GTK_STATE_SELECTED )
continue;
/* do something */
}
Heikki Vatiainen wrote:
>
> Guy Harris <guy@xxxxxxxxxx> writes:
>
> > "tree_view_select_row_cb()" could keep track of the currently selected
> > row, and the callback for key-press-event could use that.
> >
> > We do the same for additional packet windows; this means we'd have to
> > keep track of *multiple* selected rows in *different* CTree widgets if
> > we did that. It may be easier to do this the way we are doing it now.
>
> My first approach was using "tree-select-row" signal but I soon
> noticed that e.g. opening a new packet window made the "remember the
> last row" method fail. I kept toggling wrong rows and getting
> assertion failures when row numbers were incorrectly mixed up between
> unrelated CTree widgets.
>
> I thought a little about keeping track of ctrees and their currently
> selected rows, but then looked for an alternated method since the
> CTree widget already knows about its currently selected row/rows.
>
> This exercise did not feel wery keyboard friendly from GTK's part.
>
> Thanks for checking in the patch.
>
> --
> Heikki Vatiainen * hessu@xxxxxxxxx
> Tampere University of Technology * Tampere, Finland
>
> _______________________________________________
> Ethereal-dev mailing list
> Ethereal-dev@xxxxxxxxxxxx
> http://www.ethereal.com/mailman/listinfo/ethereal-dev