Commit 87d35b71 authored by Kai Willadsen's avatar Kai Willadsen

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.
parent a110252c
......@@ -26,6 +26,8 @@
<menuitem action="FindNext"/>
<menuitem action="FindPrevious"/>
<menuitem action="Replace"/>
<separator/>
<menuitem action="GoToLine"/>
</menu>
<menu action="ChangesMenu">
<menuitem action="PrevChange"/>
......
......@@ -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:
......
......@@ -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):
......
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment