GNOME Bugzilla – Bug 768130
Keyboard activation leads to a CRITICAL and opens the wrong item
Last modified: 2016-06-28 17:43:21 UTC
Hitting ENTER in the main window to open an item leads to: CRITICAL **: photos_preview_view_set_model: assertion 'current_path != NULL' failed If you tab your way to the GtkIconView and use the arrow keys to select an item (with the grey dotted lines around it), then hitting ENTER will open the wrong image. The CRITICAL is caused by PhotosViewContainer->current_path only being set in response to GdMainView::item-activated, which is only emitted due to a mouse click. Therefore, when we try to use the current_path to handle the ENTER, it is still NULL. On top of that we don't use gtk_icon_view_get_cursor to get the position of the keyboard cursor. Instead we always open the first item in the model. The right thing to do, in my opinion, would be to use gtk_icon_view_get_cursor (so that the correct item is opened) and gtk_icon_view_item_activated (so that keyboard and mouse activation use the same code path).
I sketched out a solution in gnome-photos:wip/rishi/keyboard-activation Will attach shortly.
Created attachment 330479 [details] [review] view-container: Don't leak the GtkTreePath
Created attachment 330480 [details] [review] embed, view-container: Consolidate keyboard and mouse activation
Also, hitting ENTER on, say, a GtkButton while the searchbar is not up will also open the first item in the view. See bug 733191 for the gnome-documents counterpart of this bug.
Created attachment 330500 [details] [review] searchbar: Only use ENTER events when active Alessandro sent this over IRC in #photos on GIMPNet.
Created attachment 330501 [details] [review] view-container: Don't leak the GtkTreePath
Created attachment 330502 [details] [review] embed, view-container: Add a method to activate the first item
Created attachment 330503 [details] [review] view-container: Consolidate searchbar and mouse activation
Pushed to master.