[PATCH] Select all dives in a trip when said trip is expanded and clicked

Linus Torvalds torvalds at linux-foundation.org
Mon Feb 18 10:35:49 PST 2013


On Mon, Feb 18, 2013 at 9:56 AM, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
>                 trip->selected = 1;
> -               /* If this is expanded, let the gtk selection happen for each dive under it */
> -               if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(dive_list.tree_view), path))
> -                       return;
> -               /* Otherwise, consider each dive under it selected */
> +               /* Select dives inside the trip */
>                 for_each_dive(i, dive) {
> -                       if (dive->divetrip == trip)
> +                       if (dive->divetrip == trip) {
>                                 select_dive(i);
> +                               /* Select the actual tree row */
> +                               if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(dive_list.tree_view), path)) {
> +                                       child = get_iter_from_idx(i);
> +                                       gtk_tree_selection_select_iter(selection, child);
> +                                       gtk_tree_iter_free(child);
> +                               }

I'm not understanding why you do thegtk_tree_view_row_expanded on each
iteration.

Also, it's very wrong according to the gtk docs. They say

  "Note that you cannot modify the tree or selection from within this function"

about the 'gtk_tree_selection_selected_foreach()' selection callback.

So no, I think this may end up "working", but in the same sense the
old code worked, IOW it will bite us in the ass later due to some
internal gtk corription.

I'll think about this.

            Linus


More information about the subsurface mailing list