GNOME Bugzilla – Bug 335169
Find dialog should start with last search pre-selected
Last modified: 2006-03-23 22:26:41 UTC
That bug has been opened on https://launchpad.net/distros/ubuntu/+source/gedit/+bug/34869 "When you press CTRL-F to find something in gedit, the last search terms should be pre-selected so that you can start typing a new search over the old one. Currently, to make a new search, you have to press CTRL-F, then delete the old terms, and type the new ones."
Created attachment 61580 [details] [review] Select the search entry contents when focused It basically does what the bug describes but it has also the drawback that it selects the entry contents everytime it is focused (before the cursor was put at the end of the entry)
Wouldn't it be easier to just gtk_widget_grab_focus (entry) when showing the dialogue with Ctrl-F ?
Created attachment 61859 [details] [review] Fix search selection focus This is actually a much simpler approach. It makes sure to first chain up the focus_in event so the window puts the focus on its default focus widget being the entry. Then on first showing the GTK_WIDGET_HAS_FOCUS will return true for the entry and the set_position won't be called. I think this is the correct behaviour.
I tested out the Jesse's patch. It seems to be working correctly in all the cases I could think of and restores the behavior of 2.12. I think we should get this in both on HEAD and on the 2.14 branch.
Why do we call "set_position"? I don't remember why we decided to do so.
ctrl+f, search, focus the document, then reclick on the entry with the mouse: in this case the text should not be selected, which is instead the default GtkEntry behavior on focus
Ok. I remember now Please, commit with a comment on why we use set_position and why we chain up the focus_in event (on both HEAD and gnome-2-14)
maybe it's just me being stubborn, but I can't convince myself of that code... I tried removing the whole the whole focus-in-event overriding from the search dialog and things seems to behave as expected. Can anyone of you guys find a case where removing the whole focus in handler behaves differently from the above patch? If only I could remember why we added that code in the first place... :(
Jesse, I now recall that we added after a report from you http://cvs.gnome.org/viewcvs/gedit/gedit/dialogs/gedit-search-dialog.c?r1=1.4&r2=1.5 do you remember the use case?
right, it was: - popup the dialog - search a word by clicking on find - focus the document - hit ctrl+F -> without the callback the focus is on the button, we want it on the entry
Ok, sorry for the noise. I verified that the patch deals with the above use case. I added the comment as requested by Paolo anc committed.