Commit 90ff3f37 authored by Kai Willadsen's avatar Kai Willadsen

Rework linkmap scroll handling to not require the parent MeldDoc

Keeping the parent MeldDoc is an annoying requirement, and the backref
shows up when trying to track down reference leaks. Having the parent
documents be responsible for hooking in the scroll-event signal handler,
as in this patch, is both a better separation and less pain.
parent a70e6e5d
......@@ -263,6 +263,7 @@
<property name="can_focus">False</property>
<property name="events">GDK_SCROLL_MASK</property>
<property name="vexpand">True</property>
<signal name="scroll-event" handler="on_linkmap_scroll_event" swapped="no"/>
</object>
<packing>
<property name="left_attach">4</property>
......@@ -321,6 +322,7 @@
<property name="can_focus">False</property>
<property name="events">GDK_SCROLL_MASK</property>
<property name="vexpand">True</property>
<signal name="scroll-event" handler="on_linkmap_scroll_event" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
......
......@@ -719,6 +719,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_SCROLL_MASK</property>
<signal name="scroll-event" handler="on_linkmap_scroll_event" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
......@@ -775,6 +776,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_SCROLL_MASK</property>
<signal name="scroll-event" handler="on_linkmap_scroll_event" swapped="no"/>
</object>
<packing>
<property name="left_attach">4</property>
......
......@@ -1467,9 +1467,6 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
idx = 1 if i else 0
w.setup(scroll, self.get_state_traversal(idx))
for w in self.linkmap:
w.associate(self)
for widget in (
self.vbox[:n] + self.file_toolbar[:n] + self.diffmap[:n] +
self.linkmap[:n - 1] + self.dummy_toolbar_linkmap[:n - 1]):
......@@ -1559,6 +1556,9 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self._update_diffmaps()
self.force_cursor_recalculate = True
def on_linkmap_scroll_event(self, linkmap, event):
self.next_diff(event.direction)
def next_diff(self, direction):
if self.focus_pane:
pane = self.treeview.index(self.focus_pane)
......
......@@ -491,6 +491,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.textview[pane].scroll_to_mark(
buf.get_insert(), tolerance, True, 0.5, 0.5)
def on_linkmap_scroll_event(self, linkmap, event):
self.next_diff(event.direction)
def next_diff(self, direction, centered=False):
target = (self.cursor.next if direction == Gdk.ScrollDirection.DOWN
else self.cursor.prev)
......
......@@ -131,9 +131,6 @@ class LinkMap(Gtk.DrawingArea):
Gdk.cairo_set_source_rgba(context, self.line_colors[c[0]])
context.stroke()
def do_scroll_event(self, event):
self.filediff.next_diff(event.direction)
LinkMap.set_css_name("link-map")
......@@ -141,14 +138,3 @@ LinkMap.set_css_name("link-map")
class ScrollLinkMap(Gtk.DrawingArea):
__gtype_name__ = "ScrollLinkMap"
def __init__(self):
self.melddoc = None
def associate(self, melddoc):
self.melddoc = melddoc
def do_scroll_event(self, event):
if not self.melddoc:
return
self.melddoc.next_diff(event.direction)
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