[meld/ui-next] Move find next/previous to GActions



commit 14d3847e608fcec68abafb4ffa6e5fb3bf8432dd
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Fri Mar 1 09:27:33 2019 +1000

    Move find next/previous to GActions
    
    As with other things, exposing these as menu items is no longer common
    UI practice, so we'll follow that and make them shortcut-only. They're
    still buttons on the find bar, which is almost certainly good enough.

 data/ui/meldapp-ui.xml |  2 --
 meld/accelerators.py   |  2 ++
 meld/filediff.py       |  6 ++++--
 meld/melddoc.py        |  6 ------
 meld/meldwindow.py     | 17 ++---------------
 5 files changed, 8 insertions(+), 25 deletions(-)
---
diff --git a/data/ui/meldapp-ui.xml b/data/ui/meldapp-ui.xml
index 4af42b4a..950a7d14 100644
--- a/data/ui/meldapp-ui.xml
+++ b/data/ui/meldapp-ui.xml
@@ -2,8 +2,6 @@
   <menubar name="Menubar">
     <menu action="EditMenu">
       <menuitem action="Find"/>
-      <menuitem action="FindNext"/>
-      <menuitem action="FindPrevious"/>
       <menuitem action="Replace"/>
     </menu>
     <menu action="ChangesMenu">
diff --git a/meld/accelerators.py b/meld/accelerators.py
index 3db23d66..08b38007 100644
--- a/meld/accelerators.py
+++ b/meld/accelerators.py
@@ -4,6 +4,8 @@ from gi.repository import Gtk
 
 def register_accels(app: Gtk.Application):
     view_accels = (
+        ('view.find-next', '<Primary>G'),
+        ('view.find-previous', '<Primary><Shift>G'),
         ('view.folder-compare', 'Return'),
         ('view.folder-copy-left', '<Alt>Left'),
         ('view.folder-copy-right', '<Alt>Right'),
diff --git a/meld/filediff.py b/meld/filediff.py
index c8b04901..e9a68fe6 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -291,6 +291,8 @@ class FileDiff(Gtk.VBox, MeldDoc):
         actions = (
             ('add-sync-point', self.add_sync_point),
             ('clear-sync-point', self.clear_sync_points),
+            ('find-next', self.action_find_next),
+            ('find-previous', self.action_find_previous),
             ('format-as-patch', self.action_format_as_patch),
             ('go-to-line', self.action_go_to_line),
             ('merge-all-left', self.action_pull_all_changes_left),
@@ -1165,10 +1167,10 @@ class FileDiff(Gtk.VBox, MeldDoc):
         self.findbar.start_find(
             textview=self.focus_pane, replace=True, text=selected_text)
 
-    def on_find_next_activate(self, *args):
+    def action_find_next(self, *args):
         self.findbar.start_find_next(self.focus_pane)
 
-    def on_find_previous_activate(self, *args):
+    def action_find_previous(self, *args):
         self.findbar.start_find_previous(self.focus_pane)
 
     @with_focused_pane
diff --git a/meld/melddoc.py b/meld/melddoc.py
index 68d98c45..60ee5d0c 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -171,12 +171,6 @@ class MeldDoc(LabeledObjectMixin, GObject.GObject):
     def on_find_activate(self, *extra):
         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 166bd99c..8e647425 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -63,12 +63,6 @@ class MeldWindow(Gtk.ApplicationWindow):
             ("EditMenu", None, _("_Edit")),
             ("Find", Gtk.STOCK_FIND, _("Find…"), None, _("Search for text"),
                 self.on_menu_find_activate),
-            ("FindNext", None, _("Find Ne_xt"), "<Primary>G",
-                _("Search forwards for the same text"),
-                self.on_menu_find_next_activate),
-            ("FindPrevious", None, _("Find _Previous"), "<Primary><shift>G",
-                _("Search backwards for the same text"),
-                self.on_menu_find_previous_activate),
             ("Replace", Gtk.STOCK_FIND_AND_REPLACE,
                 _("_Replace…"), "<Primary>H",
                 _("Find and replace text"),
@@ -232,15 +226,14 @@ class MeldWindow(Gtk.ApplicationWindow):
         self.lookup_action('close').set_enabled(bool(page))
         if not isinstance(page, MeldDoc):
             for action in (
-                           "Find", "FindNext", "FindPrevious", "Replace",
+                           "Find", "Replace",
                            ):
                 self.actiongroup.get_action(action).set_sensitive(False)
         else:
             for action in ("Find",):
                 self.actiongroup.get_action(action).set_sensitive(True)
             is_filediff = isinstance(page, FileDiff)
-            for action in ("FindNext", "FindPrevious",
-                           "Replace"):
+            for action in ("Replace",):
                 self.actiongroup.get_action(action).set_sensitive(is_filediff)
 
     def handle_current_doc_switch(self, page):
@@ -290,12 +283,6 @@ class MeldWindow(Gtk.ApplicationWindow):
     def on_menu_find_activate(self, *extra):
         self.current_doc().on_find_activate()
 
-    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()
 


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