[gedit] ViewFrame: select text in the search entry



commit 9afcbc99e69138dbdb31b28403bc59e818a990c5
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Feb 2 22:16:08 2014 +0100

    ViewFrame: select text in the search entry
    
    Steps:
    - Ctrl+F and search for 'something', with a least one match
    - the match becomes selected in the buffer
    - press Enter to quit the search
    - press Ctrl+F again
    - the search takes the buffer selection to put it in the search entry
    
    What the code did in this case is to put the cursor at the end of the
    search text (in the search entry). Now it selects the text.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723267

 gedit/gedit-view-frame.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gedit/gedit-view-frame.c b/gedit/gedit-view-frame.c
index 2ac109d..5a7735a 100644
--- a/gedit/gedit-view-frame.c
+++ b/gedit/gedit-view-frame.c
@@ -1292,11 +1292,17 @@ init_search_entry (GeditViewFrame *frame)
                                search_text_escaped = gtk_source_utils_escape_search_text (search_text);
                        }
 
+                       g_signal_handler_block (frame->priv->search_entry,
+                                               frame->priv->search_entry_changed_id);
+
                        gtk_entry_set_text (GTK_ENTRY (frame->priv->search_entry),
                                            search_text_escaped);
 
-                       gtk_editable_set_position (GTK_EDITABLE (frame->priv->search_entry),
-                                                  -1);
+                       gtk_editable_select_region (GTK_EDITABLE (frame->priv->search_entry),
+                                                   0, -1);
+
+                       g_signal_handler_unblock (frame->priv->search_entry,
+                                                 frame->priv->search_entry_changed_id);
 
                        g_free (search_text_escaped);
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]