[meld] filediff, ui.statusbar: Make go-to-line happen as you type
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] filediff, ui.statusbar: Make go-to-line happen as you type
- Date: Sat, 25 Nov 2017 22:08:28 +0000 (UTC)
commit d525ce65207afd4abe2a81be4c6e39fa9f5dfa8c
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Nov 26 07:52:50 2017 +1000
filediff, ui.statusbar: Make go-to-line happen as you type
meld/filediff.py | 7 ++++---
meld/ui/statusbar.py | 18 +++++++++++++-----
2 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index ad55fd9..e836d0e 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -230,7 +230,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.set_file(pane, self.textbuffer[pane].data.gfile, encoding)
def go_to_line(widget, line, pane):
- self.move_cursor(pane, line)
+ self.move_cursor(pane, line, focus=False)
pane = self.statusbar.index(statusbar)
statusbar.connect('encoding-changed', reload_with_encoding, pane)
@@ -706,9 +706,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
return new_line
- def move_cursor(self, pane, line):
+ def move_cursor(self, pane, line, focus=True):
buf, view = self.textbuffer[pane], self.textview[pane]
- view.grab_focus()
+ if focus:
+ view.grab_focus()
buf.place_cursor(buf.get_iter_at_line(line))
view.scroll_to_mark(buf.get_insert(), 0.1, True, 0.5, 0.5)
diff --git a/meld/ui/statusbar.py b/meld/ui/statusbar.py
index b9d60ca..12270bc 100644
--- a/meld/ui/statusbar.py
+++ b/meld/ui/statusbar.py
@@ -159,6 +159,13 @@ class MeldStatusBar(Gtk.Statusbar):
# Note that we're receiving one-based line numbers from the
# user and storing and emitting zero-base line numbers.
+ def go_to_line_text(text):
+ try:
+ line = int(text)
+ except ValueError:
+ return
+ self.emit('go-to-line', max(0, line - 1))
+
def line_entry_mapped(entry):
line, offset = self.props.cursor_position
entry.set_text(str(line + 1))
@@ -168,12 +175,12 @@ class MeldStatusBar(Gtk.Statusbar):
GObject.signal_stop_emission_by_name(entry, 'insert-text')
return
+ def line_entry_changed(entry):
+ go_to_line_text(entry.get_text())
+
def line_entry_activated(entry):
- try:
- line = int(entry.get_text())
- except ValueError:
- return
- self.emit('go-to-line', max(0, line - 1))
+ go_to_line_text(entry.get_text())
+ pop.popdown()
entry = Gtk.Entry()
entry.set_tooltip_text(_('Line you want to move the cursor to'))
@@ -183,6 +190,7 @@ class MeldStatusBar(Gtk.Statusbar):
entry.set_input_purpose(Gtk.InputPurpose.DIGITS)
entry.connect('map', line_entry_mapped)
entry.connect('insert-text', line_entry_insert_text)
+ entry.connect('changed', line_entry_changed)
entry.connect('activate', line_entry_activated)
selector = Gtk.Grid()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]