[meld] Pre-fill the findbar Find entry with the selected text



commit a7a8b13288a5480b22c8f90c7b97cf6411e241f8
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Wed Aug 26 10:42:44 2009 +1000

    Pre-fill the findbar Find entry with the selected text

 meld/filediff.py   |    6 ++++--
 meld/ui/findbar.py |   10 +++++++---
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 87ce29e..d4e8dff 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -885,11 +885,13 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         return None
 
     def on_find_activate(self, *args):
-        self.findbar.start_find( self.textview_focussed )
+        selected_text = self.get_selected_text()
+        self.findbar.start_find(self.textview_focussed, selected_text)
         self.keymask = 0
 
     def on_replace_activate(self, *args):
-        self.findbar.start_replace( self.textview_focussed )
+        selected_text = self.get_selected_text()
+        self.findbar.start_replace(self.textview_focussed, selected_text)
         self.keymask = 0
 
     def on_find_next_activate(self, *args):
diff --git a/meld/ui/findbar.py b/meld/ui/findbar.py
index 5cbfee7..342bda5 100644
--- a/meld/ui/findbar.py
+++ b/meld/ui/findbar.py
@@ -32,12 +32,14 @@ class FindBar(gnomeglade.Component):
         self.textview = None
         self.widget.hide()
 
-    def start_find(self, textview):
+    def start_find(self, textview, text=None):
         self.textview = textview
         self.replace_label.hide()
         self.replace_entry.hide()
         self.replace_button.hide()
         self.replace_all_button.hide()
+        if text:
+            self.find_entry.set_text(text)
         self.widget.show()
         self.find_entry.grab_focus()
 
@@ -48,15 +50,17 @@ class FindBar(gnomeglade.Component):
         else:
             self.start_find(self.textview)
 
-    def start_find_previous(self, textview):
+    def start_find_previous(self, textview, text=None):
         self.textview = textview
         if self.find_entry.get_text():
             self.find_previous_button.activate()
         else:
             self.start_find(self.textview)
 
-    def start_replace(self, textview):
+    def start_replace(self, textview, text=None):
         self.textview = textview
+        if text:
+            self.find_entry.set_text(text)
         self.widget.show_all()
         self.find_entry.grab_focus()
 



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