[meld] Add go-to-line menu item and shortcut support



commit 87d35b719bcbb7e73fa3b0d876225021b8b3858f
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Nov 25 06:21:31 2017 +1000

    Add go-to-line menu item and shortcut support
    
    This is bound to Ctrl+I for parity with gedit and Builder. This is
    starting to become a good argument for swappable keybinding support.

 data/ui/meldapp-ui.xml |    2 ++
 meld/filediff.py       |    4 ++++
 meld/meldwindow.py     |    6 ++++++
 meld/ui/statusbar.py   |    3 +++
 4 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/meldapp-ui.xml b/data/ui/meldapp-ui.xml
index d475f76..a23f8fc 100644
--- a/data/ui/meldapp-ui.xml
+++ b/data/ui/meldapp-ui.xml
@@ -26,6 +26,8 @@
       <menuitem action="FindNext"/>
       <menuitem action="FindPrevious"/>
       <menuitem action="Replace"/>
+      <separator/>
+      <menuitem action="GoToLine"/>
     </menu>
     <menu action="ChangesMenu">
       <menuitem action="PrevChange"/>
diff --git a/meld/filediff.py b/meld/filediff.py
index 9cbd052..9f6e530 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -959,6 +959,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
     def on_find_previous_activate(self, *args):
         self.findbar.start_find_previous(self.focus_pane)
 
+    @with_focused_pane
+    def on_go_to_line_activate(self, pane, *args):
+        self.statusbar[pane].emit('start-go-to-line')
+
     def on_scrolledwindow_size_allocate(self, scrolledwindow, allocation):
         index = self.scrolledwindow.index(scrolledwindow)
         if index == 0 or index == 1:
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index c828615..0c26e91 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -82,6 +82,9 @@ class MeldWindow(gnomeglade.Component):
                 _("_Replaceā€¦"), "<Primary>H",
                 _("Find and replace text"),
                 self.on_menu_replace_activate),
+            ("GoToLine", None, _("Go to _Line"), "<Primary>I",
+                _("Go to a specific line"),
+                self.on_menu_go_to_line_activate),
 
             ("ChangesMenu", None, _("_Changes")),
             ("NextChange", Gtk.STOCK_GO_DOWN, _("Next Change"), "<Alt>Down",
@@ -446,6 +449,9 @@ class MeldWindow(gnomeglade.Component):
     def on_menu_replace_activate(self, *extra):
         self.current_doc().on_replace_activate()
 
+    def on_menu_go_to_line_activate(self, *extra):
+        self.current_doc().on_go_to_line_activate()
+
     def on_menu_copy_activate(self, *extra):
         widget = self.widget.get_focus()
         if isinstance(widget, Gtk.Editable):
diff --git a/meld/ui/statusbar.py b/meld/ui/statusbar.py
index 27570bd..86519c3 100644
--- a/meld/ui/statusbar.py
+++ b/meld/ui/statusbar.py
@@ -103,6 +103,8 @@ class MeldStatusBar(Gtk.Statusbar):
     __gtype_name__ = "MeldStatusBar"
 
     __gsignals__ = {
+        'start-go-to-line': (
+            GObject.SignalFlags.ACTION, None, tuple()),
         'go-to-line': (
             GObject.SignalFlags.RUN_FIRST, None, (int,)),
         'encoding-changed': (
@@ -205,6 +207,7 @@ class MeldStatusBar(Gtk.Statusbar):
         self.bind_property(
             'cursor_position', button, 'label', GObject.BindingFlags.DEFAULT,
             format_cursor_position)
+        self.connect('start-go-to-line', lambda *args: button.clicked())
         button.set_popover(pop)
         button.show()
 


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