Index: gedit/dialogs/gedit-dialog-replace.c =================================================================== RCS file: /cvs/gnome/gedit/gedit/dialogs/gedit-dialog-replace.c,v retrieving revision 1.37 diff -u -r1.37 gedit-dialog-replace.c --- gedit/dialogs/gedit-dialog-replace.c 25 Jan 2005 10:26:25 -0000 1.37 +++ gedit/dialogs/gedit-dialog-replace.c 5 Aug 2005 17:00:47 -0000 @@ -615,8 +615,18 @@ selection_exists = get_selected_text (GTK_TEXT_BUFFER (doc), &find_text, &sel_len); if (selection_exists && find_text && sel_len < 80) { + GtkTextIter start, end; + + /* Remember the selection, cause we'll loose it when grabbing focus in the find entry */ + gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc), &start, &end); + + /* Now we set the text, and grab focus, that will erase selection in the buffer */ gtk_entry_set_text (GTK_ENTRY (dialog->search_entry), find_text); + gtk_widget_grab_focus (dialog->search_entry); g_free (find_text); + + /* Restore the selection in the buffer, as before grabbing focus. */ + gtk_text_buffer_select_range (GTK_TEXT_BUFFER (doc), &start, &end); } else { @@ -627,6 +637,8 @@ gtk_entry_set_text (GTK_ENTRY (dialog->search_entry), find_text); g_free (find_text); } + + gtk_widget_grab_focus (dialog->search_entry); } if (!was_search_backwards_id) @@ -673,9 +685,7 @@ was_wrap_around); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->search_backwards_checkbutton), was_search_backwards); - - gtk_widget_grab_focus (dialog->search_entry); - + gtk_widget_show (dialog->dialog); }