[meld] Add Edit -> Find Previous menu item



commit 3fc02a526fbef3c37b6842ff996c26e1de3f8d5c
Author: Oliver Gerlich <oliver gerlich gmx de>
Date:   Mon Apr 18 20:56:36 2011 +0200

    Add Edit -> Find Previous menu item
    
    This also enables the Ctrl+Shift+G accelerator for searching previous
    match, which complements the Ctrl+G accelerator.

 data/ui/meldapp-ui.xml |    1 +
 meld/filediff.py       |    3 +++
 meld/melddoc.py        |    2 ++
 meld/meldwindow.py     |    4 ++++
 meld/ui/findbar.py     |    7 +++++++
 5 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/meldapp-ui.xml b/data/ui/meldapp-ui.xml
index 1c54a49..7308574 100644
--- a/data/ui/meldapp-ui.xml
+++ b/data/ui/meldapp-ui.xml
@@ -22,6 +22,7 @@
       <separator/>
       <menuitem action="Find"/>
       <menuitem action="FindNext"/>
+      <menuitem action="FindPrevious"/>
       <menuitem action="Replace"/>
       <separator/>
       <menuitem name="Preferences" action="Preferences"/>
diff --git a/meld/filediff.py b/meld/filediff.py
index c743151..74e30a6 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -768,6 +768,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
     def on_find_next_activate(self, *args):
         self.findbar.start_find_next(self.textview_focussed)
 
+    def on_find_previous_activate(self, *args):
+        self.findbar.start_find_previous(self.textview_focussed)
+
     def on_filediff__key_press_event(self, entry, event):
         if event.keyval == gtk.keysyms.Escape:
             self.findbar.hide()
diff --git a/meld/melddoc.py b/meld/melddoc.py
index 55718ae..ff1bfea 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -99,6 +99,8 @@ class MeldDoc(gobject.GObject):
         pass
     def on_find_next_activate(self, *extra):
         pass
+    def on_find_previous_activate(self, *extra):
+        pass
     def on_replace_activate(self, *extra):
         pass
 
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index e83ba2d..9d84379 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -137,6 +137,7 @@ class MeldWindow(gnomeglade.Component):
             ("Paste",   gtk.STOCK_PASTE,    None, None, _("Paste the clipboard"), self.on_menu_paste_activate),
             ("Find",    gtk.STOCK_FIND,     None, None, _("Search for text"), self.on_menu_find_activate),
             ("FindNext", None,              _("Find Ne_xt"), "<control>G", _("Search forwards for the same text"), self.on_menu_find_next_activate),
+            ("FindPrevious", None,          _("Find _Previous"), "<control><shift>G", _("Search backwards for the same text"), self.on_menu_find_previous_activate),
             ("Replace", gtk.STOCK_FIND_AND_REPLACE, _("_Replace"), "<control>H", _("Find and replace text"), self.on_menu_replace_activate),
             ("Preferences", gtk.STOCK_PREFERENCES, _("Prefere_nces"), None, _("Configure the application"), self.on_menu_preferences_activate),
 
@@ -420,6 +421,9 @@ class MeldWindow(gnomeglade.Component):
     def on_menu_find_next_activate(self, *extra):
         self.current_doc().on_find_next_activate()
 
+    def on_menu_find_previous_activate(self, *extra):
+        self.current_doc().on_find_previous_activate()
+
     def on_menu_replace_activate(self, *extra):
         self.current_doc().on_replace_activate()
 
diff --git a/meld/ui/findbar.py b/meld/ui/findbar.py
index 7cadb9e..5cbfee7 100644
--- a/meld/ui/findbar.py
+++ b/meld/ui/findbar.py
@@ -48,6 +48,13 @@ class FindBar(gnomeglade.Component):
         else:
             self.start_find(self.textview)
 
+    def start_find_previous(self, textview):
+        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):
         self.textview = textview
         self.widget.show_all()



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