Commit b94a6ddf authored by Kai Willadsen's avatar Kai Willadsen

filediff: Remove cycle-pane action in favour of prev/next (bgo#701665)

Cycling panes has always felt a little bit weird, and really it's very
straightforward to use a previous/next model instead.
parent 99c84e70
......@@ -51,7 +51,8 @@
<menuitem action="LockScrolling"/>
</placeholder>
<placeholder name="ViewDocSpecificPlaceholder">
<menuitem action="CycleDocuments" />
<menuitem action="PrevPane" />
<menuitem action="NextPane" />
</placeholder>
</menu>
</menubar>
......
......@@ -155,12 +155,20 @@
</object>
</child>
<child>
<object class="GtkAction" id="CycleDocuments">
<property name="label" translatable="yes">Cycle Through Documents</property>
<object class="GtkAction" id="PrevPane">
<property name="label" translatable="yes">Previous Pane</property>
<property name="tooltip" translatable="yes">Move keyboard focus to the previous document in this comparison</property>
<signal name="activate" handler="action_prev_pane" swapped="no"/>
</object>
<accelerator key="Page_Up" modifiers="GDK_MOD1_MASK"/>
</child>
<child>
<object class="GtkAction" id="NextPane">
<property name="label" translatable="yes">Next Pane</property>
<property name="tooltip" translatable="yes">Move keyboard focus to the next document in this comparison</property>
<signal name="activate" handler="action_cycle_documents" swapped="no"/>
<signal name="activate" handler="action_next_pane" swapped="no"/>
</object>
<accelerator key="Escape" modifiers="GDK_CONTROL_MASK"/>
<accelerator key="Page_Down" modifiers="GDK_MOD1_MASK"/>
</child>
<child>
<object class="GtkToggleAction" id="LockScrolling">
......
......@@ -503,6 +503,11 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.actiongroup.get_action("CopyLeftDown").set_sensitive(copy_left)
self.actiongroup.get_action("CopyRightUp").set_sensitive(copy_right)
self.actiongroup.get_action("CopyRightDown").set_sensitive(copy_right)
prev_pane = pane > 0
next_pane = pane < self.num_panes - 1
self.actiongroup.get_action("PrevPane").set_sensitive(prev_pane)
self.actiongroup.get_action("NextPane").set_sensitive(next_pane)
# FIXME: don't queue_draw() on everything... just on what changed
self.queue_draw()
......@@ -734,11 +739,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
return new_line
def action_cycle_documents(self, widget):
pane = self._get_focused_pane()
new_pane = (pane + 1) % self.num_panes
def move_cursor_pane(self, pane, new_pane):
chunk, line = self.cursor.chunk, self.cursor.line
new_line = self._corresponding_chunk_line(chunk, line, pane, new_pane)
new_buf = self.textbuffer[new_pane]
......@@ -747,6 +749,16 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.textview[new_pane].scroll_to_mark(
new_buf.get_insert(), 0.1, True, 0.5, 0.5)
def action_prev_pane(self, *args):
pane = self._get_focused_pane()
new_pane = (pane - 1) % self.num_panes
self.move_cursor_pane(pane, new_pane)
def action_next_pane(self, *args):
pane = self._get_focused_pane()
new_pane = (pane + 1) % self.num_panes
self.move_cursor_pane(pane, new_pane)
def _set_external_action_sensitivity(self):
have_file = self.focus_pane is not None
try:
......@@ -1862,7 +1874,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
widget.hide()
self.actiongroup.get_action("MakePatch").set_sensitive(n > 1)
self.actiongroup.get_action("CycleDocuments").set_sensitive(n > 1)
def coords_iter(i):
buf_index = 2 if i == 1 and self.num_panes == 3 else i
......
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