[PATCH] Different logic for dive selection when trips are expanded

Linus Torvalds torvalds at linux-foundation.org
Mon Feb 18 15:57:31 PST 2013


On Mon, Feb 18, 2013 at 3:34 PM, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
>
> This is just an idea of a patch, which keeps the profile and statistics
> better consistent for user interaction with a selected, expanded trip.
> It pretty much maps the selection of the first dive in a trip to the trip
> row (can be observed with the stats widget open).

I don't think this can work:

> @@ -2746,7 +2734,11 @@ static void entry_selected(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *
>                 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;
> +                       for_each_dive(i, dive)
> +                               if (dive->divetrip == trip) {
> +                                       select_dive(i);
> +                                       return;
> +                               }

This selects the oldest dive in the trip, but then it doesn't
gtk-select it, so it doesn't show up as being selected in gtk. And
because it's not gtk-selected, when you now start selecting other
dives in that trip, because gtk doesn't know you selected it, it won't
unselect that hidden dive either.

So no. I didn't actually try applying this and running it, but from
just reading the patch, this is very very wrong. It will make the
"status" notebook look correct for the "select one trip" case (because
the oldest dive in the trip will now show up for the status
information), but it actually results in lots of confusion if you have
other dives selected too - or if you later select other dives.

The reason we've had tons of bugs in this area is that the interaction
with the native gtk selection and our "keep track of selected dives"
is really complicated. gtk makes it really hard to do anything sane
(unless you want *exactly* the semantics that the native gtk selection
logic gives you, and you just use that blindly)

             Linus


More information about the subsurface mailing list