Skip to content

Commit 87d35b7

Browse files
committed
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.
1 parent a110252 commit 87d35b7

4 files changed

Lines changed: 15 additions & 0 deletions

File tree

data/ui/meldapp-ui.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<menuitem action="FindNext"/>
2727
<menuitem action="FindPrevious"/>
2828
<menuitem action="Replace"/>
29+
<separator/>
30+
<menuitem action="GoToLine"/>
2931
</menu>
3032
<menu action="ChangesMenu">
3133
<menuitem action="PrevChange"/>

meld/filediff.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,10 @@ def on_find_next_activate(self, *args):
959959
def on_find_previous_activate(self, *args):
960960
self.findbar.start_find_previous(self.focus_pane)
961961

962+
@with_focused_pane
963+
def on_go_to_line_activate(self, pane, *args):
964+
self.statusbar[pane].emit('start-go-to-line')
965+
962966
def on_scrolledwindow_size_allocate(self, scrolledwindow, allocation):
963967
index = self.scrolledwindow.index(scrolledwindow)
964968
if index == 0 or index == 1:

meld/meldwindow.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def __init__(self):
8282
_("_Replace…"), "<Primary>H",
8383
_("Find and replace text"),
8484
self.on_menu_replace_activate),
85+
("GoToLine", None, _("Go to _Line"), "<Primary>I",
86+
_("Go to a specific line"),
87+
self.on_menu_go_to_line_activate),
8588

8689
("ChangesMenu", None, _("_Changes")),
8790
("NextChange", Gtk.STOCK_GO_DOWN, _("Next Change"), "<Alt>Down",
@@ -446,6 +449,9 @@ def on_menu_find_previous_activate(self, *extra):
446449
def on_menu_replace_activate(self, *extra):
447450
self.current_doc().on_replace_activate()
448451

452+
def on_menu_go_to_line_activate(self, *extra):
453+
self.current_doc().on_go_to_line_activate()
454+
449455
def on_menu_copy_activate(self, *extra):
450456
widget = self.widget.get_focus()
451457
if isinstance(widget, Gtk.Editable):

meld/ui/statusbar.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class MeldStatusBar(Gtk.Statusbar):
103103
__gtype_name__ = "MeldStatusBar"
104104

105105
__gsignals__ = {
106+
'start-go-to-line': (
107+
GObject.SignalFlags.ACTION, None, tuple()),
106108
'go-to-line': (
107109
GObject.SignalFlags.RUN_FIRST, None, (int,)),
108110
'encoding-changed': (
@@ -205,6 +207,7 @@ def format_cursor_position(binding, cursor):
205207
self.bind_property(
206208
'cursor_position', button, 'label', GObject.BindingFlags.DEFAULT,
207209
format_cursor_position)
210+
self.connect('start-go-to-line', lambda *args: button.clicked())
208211
button.set_popover(pop)
209212
button.show()
210213

0 commit comments

Comments
 (0)