After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 770130 - File chooser dialog forgets "select-multiple" property after changing directories
File chooser dialog forgets "select-multiple" property after changing directo...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
3.20.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
Depends on:
Blocks: 770325
 
 
Reported: 2016-08-19 06:04 UTC by Sebastian Dröge (slomo)
Modified: 2016-09-11 20:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
testcase (470 bytes, text/plain)
2016-08-19 06:04 UTC, Sebastian Dröge (slomo)
  Details
treeview: Accept row selections even if unfocused (1.57 KB, patch)
2016-09-01 11:34 UTC, Timm Bäder
none Details | Review
patch: treeview: Grab the focus if no one else has grabbed it (4.78 KB, patch)
2016-09-09 14:24 UTC, Kjell Ahlstedt
none Details | Review
patch: treeview: Grab the focus if no one else has grabbed it (5.27 KB, patch)
2016-09-11 08:08 UTC, Kjell Ahlstedt
none Details | Review

Description Sebastian Dröge (slomo) 2016-08-19 06:04:19 UTC
Created attachment 333607 [details]
testcase

See attached trivial testcase. When starting this, you'll get a file chooser dialog that allows multiple selection, however after changing to a different directory it forgets about that and only a single selection is possible.

This is with GTK+ 3.20.7
Comment 1 Sebastian Dröge (slomo) 2016-08-19 07:33:03 UTC
This apparently only applies to ctrl+click and shift+click, not "rubberband" selection as baedert noted on IRC
Comment 2 Timm Bäder 2016-08-20 17:39:18 UTC
Looks like this just fails because https://git.gnome.org/browse/gtk+/tree/gtk/gtktreeview.c#n10965 is not TRUE anymore, i.e. it works fine if you manage to keyboard-focus the treeview again after clicking one of the sidebar rows.

That's the reason, I'm not sure why the check is there or what the best way to fix the issue is.
Comment 3 Matthias Clasen 2016-08-23 20:42:34 UTC
I can't reproduce this with master. How are you changing directories, exactly ?
Comment 4 Sebastian Dröge (slomo) 2016-08-23 20:58:25 UTC
For example by clicking on the "Documents" bookmark. It works for me in "Recent" (which is the default) but any change makes it fail.
Comment 5 Timm Bäder 2016-09-01 11:34:16 UTC
Created attachment 334598 [details] [review]
treeview: Accept row selections even if unfocused

When a treeview is unfocused but a row is selected and multiple rows can be selected, the next ctrl+click should select another row anyway.

I'm not sure why the treeview here (or generally?) does not get focused when clicked though.
Comment 6 Kjell Ahlstedt 2016-09-02 17:20:18 UTC
When the tree view does not have the keyboard focus, it does not react to
key presses. The patch in comment 5 only partially fixes the bug. Clicking on
the tree view does not give it focus. Ctrl-click and Shift-click give it focus.
When it's not focused, the up and down arrows move the selection in the places
sidebar. Ctrl-a for select-all has no effect. The right arrow gives the tree
view the focus.

The documentation of gtk_tree_view_set_cursor() says:
 * This function is often followed by gtk_widget_grab_focus(tree_view) 
 * in order to give keyboard focus to the widget.

GtkFileChooserWidget contains two calls to gtk_tree_view_set_cursor() which are
not followed by gtk_widget_grab_focus(tree_view). Could that be what causes the
bug? Or some other missing gtk_widget_grab_focus(tree_view) in
GtkFileChooserWidget?
Comment 7 Kjell Ahlstedt 2016-09-06 16:32:19 UTC
I suspect that this bug was introduced as a side-effect of the patch in
bug 767468. As a result of that patch, the tree view does not always get the
keyboard focus when it's clicked.
Comment 8 Kjell Ahlstedt 2016-09-09 14:24:43 UTC
Created attachment 335194 [details] [review]
patch: treeview: Grab the focus if no one else has grabbed it

The patch fixes this bug without reintroducing bug 767468.

As in the patch in bug 767468, e33e23a6d9403f634003e6fc611ba7d02b5cf950, I have
used gtk_grab_get_current() to check which widget has grabbed the focus. Is that
really correct? It "queries the current grab of the default window group."
What if the tree view is inside a window that does not belong to the default
window group?
Comment 9 Matthias Clasen 2016-09-10 11:09:47 UTC
Review of attachment 335194 [details] [review]:

this looks confused to me. What gtk_grab_get_current returns has nothing to do with the focus, per se.
Comment 10 Matthias Clasen 2016-09-11 01:47:07 UTC
hmm, on the other hand, the code already looks at the grab widget
Comment 11 Kjell Ahlstedt 2016-09-11 08:08:28 UTC
Created attachment 335293 [details] [review]
patch: treeview: Grab the focus if no one else has grabbed it

> hmm, on the other hand, the code already looks at the grab widget

Yes, a call to gtk_grab_get_current() was added in the problematic fix of
bug 767468. I doubt that it's the best way. My new patch uses
gtk_window_get_focus() instead.
Comment 12 Roman Lebedev 2016-09-11 10:30:09 UTC
Review of attachment 335293 [details] [review]:

Yes, this patch does seem to fix https://bugzilla.gnome.org/show_bug.cgi?id=770508
Comment 13 Matthias Clasen 2016-09-11 13:17:36 UTC
hmm, on the other hand, the code already looks at the grab widget(In reply to Kjell Ahlstedt from comment #7)
> I suspect that this bug was introduced as a side-effect of the patch in
> bug 767468. As a result of that patch, the tree view does not always get the
> keyboard focus when it's clicked.

I don't see it. Reverting but 767468 does not change the focus behavior when changing directories in the file chooser
Comment 14 Matthias Clasen 2016-09-11 13:23:11 UTC
I think there are two basic questions here:

- Do we want the filechooser to put focus on the file list when the sidebar selection changes ? Doing so makes keynav in the sidebar somewhat annoying. So far, the code doesn't do it

- Do we want the treeview to take focus on control- or shift-click in multi-selection mode ?
Comment 15 Kjell Ahlstedt 2016-09-11 15:05:51 UTC
(In reply to Matthias Clasen from comment #13)
> > I suspect that this bug was introduced as a side-effect of the patch in
> > bug 767468. As a result of that patch, the tree view does not always get the
> > keyboard focus when it's clicked.
> 
> I don't see it. Reverting but 767468 does not change the focus behavior when
> changing directories in the file chooser

First don't revert anything.
Run the test case in this bug.
Select a map in the sidebar, e.g. Home.
Click somewhere in the tree view. The clicked line is selected, but the tree
view does not get the focus.
Ctrl-click another line. Nothing happens, because the sidebar still has the
keyboard focus.

Then revert the patch in bug 767468.
Run the test as before. The result is different, because the tree view gets
the focus the first time it's clicked.

(In reply to Matthias Clasen from comment #14)
> - Do we want the filechooser to put focus on the file list when the sidebar
> selection changes ? Doing so makes keynav in the sidebar somewhat annoying.
> So far, the code doesn't do it

No, I don't think so. It didn't before bug 767468 was fixed, and it does not
if my patch is applied.

> - Do we want the treeview to take focus on control- or shift-click in
> multi-selection mode ?

Not important, if you ask me. The problem with the fix of bug 767468 is that
now the tree view does not get the focus when it's clicked, whether ctrl-click,
shift-click or a simple non-modified click. And when it does not have the focus,
ctrl-click and shift-click don't work as expected. It gets the focus when the
right-arrow key is pressed, but it would be nice if it also got the focus when
it's clicked, like before.
Comment 16 Kjell Ahlstedt 2016-09-11 16:41:44 UTC
Commit 29faa2db44b04b9cf7f4d96e32691f424490c730, which fixes bug 770508, also
fixes this file chooser bug. Simpler and better than my patches!
Comment 17 Matthias Clasen 2016-09-11 20:44:18 UTC
yay, thanks for confirming