[meld: 2/5] [feat]add a new feature: switch the panes
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 2/5] [feat]add a new feature: switch the panes
- Date: Sat, 9 Apr 2022 23:19:04 +0000 (UTC)
commit d7ae51d8485cc54ce8f2fe02b7b2c32e7d254ccd
Author: Helly Guo <buffoonguo gmail com>
Date: Wed Apr 6 17:56:58 2022 +0800
[feat]add a new feature: switch the panes
- remove the button in toolbar
- add a menu entry in the global menu
- add a shortcut "alt + backslash" to fire the swap action
meld/accelerators.py | 2 ++
meld/dirdiff.py | 6 +++---
meld/filediff.py | 6 +++---
meld/resources/gtk/help-overlay.ui | 7 +++++++
meld/resources/gtk/menus.ui | 7 +++++++
meld/resources/ui/dirdiff-actions.ui | 22 ----------------------
meld/resources/ui/filediff-actions.ui | 22 ----------------------
7 files changed, 22 insertions(+), 50 deletions(-)
---
diff --git a/meld/accelerators.py b/meld/accelerators.py
index ccf2ea7e..1d2b9fe2 100644
--- a/meld/accelerators.py
+++ b/meld/accelerators.py
@@ -47,6 +47,8 @@ VIEW_ACCELERATORS: Dict[str, Union[str, Sequence[str]]] = {
# Version control actions
'view.vc-commit': '<Primary>M',
'view.vc-console-visible': 'F9',
+ # Swap the two panes
+ 'view.swap-2-panes': '<Alt>backslash',
}
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 125c9810..88aef33b 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -497,7 +497,7 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
('folder-compare-marked', self.action_diff_marked),
('folder-copy-left', self.action_copy_left),
('folder-copy-right', self.action_copy_right),
- ('folder-switch', self.action_switch),
+ ('swap-2-panes', self.action_swap),
('folder-delete', self.action_delete),
('folder-expand', self.action_folder_expand),
('next-change', self.action_next_change),
@@ -1328,7 +1328,7 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
self.set_action_enabled(
'folder-compare-marked',
self.marked is not None and self.marked.pane != pane)
- self.set_action_enabled('folder-switch', self.num_panes == 2)
+ self.set_action_enabled('swap-2-panes', self.num_panes == 2)
self.set_action_enabled('folder-delete', is_valid)
self.set_action_enabled('folder-copy-left', is_valid and pane > 0)
self.set_action_enabled(
@@ -1581,7 +1581,7 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
def action_copy_right(self, *args):
self.copy_selected(1)
- def action_switch(self, *args):
+ def action_swap(self, *args):
folder_x = self.folders[0]
self.folders[0] = self.folders[1]
self.folders[1] = folder_x
diff --git a/meld/filediff.py b/meld/filediff.py
index c6a04f46..651d8c0a 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -351,7 +351,7 @@ class FileDiff(Gtk.VBox, MeldDoc):
('save-all', self.action_save_all),
('save-as', self.action_save_as),
('undo', self.action_undo),
- ('file-switch', self.action_switch),
+ ('swap-2-panes', self.action_swap),
)
for name, callback in actions:
action = Gio.SimpleAction.new(name, None)
@@ -726,7 +726,7 @@ class FileDiff(Gtk.VBox, MeldDoc):
self.set_action_enabled('file-copy-right-down', copy_right)
self.set_action_enabled('previous-pane', pane > 0)
self.set_action_enabled('next-pane', pane < self.num_panes - 1)
- self.set_action_enabled('file-switch', self.num_panes == 2)
+ self.set_action_enabled('swap-2-panes', self.num_panes == 2)
# FIXME: don't queue_draw() on everything... just on what changed
self.queue_draw()
@@ -2471,7 +2471,7 @@ class FileDiff(Gtk.VBox, MeldDoc):
mgr.clear()
self.refresh_comparison()
- def action_switch(self, *args):
+ def action_swap(self, *args):
buffer0 = self.textbuffer[0]
buffer1 = self.textbuffer[1]
self.set_files([buffer1.data.gfile, buffer0.data.gfile])
diff --git a/meld/resources/gtk/help-overlay.ui b/meld/resources/gtk/help-overlay.ui
index 2f7cd9c8..ea84acf3 100644
--- a/meld/resources/gtk/help-overlay.ui
+++ b/meld/resources/gtk/help-overlay.ui
@@ -54,6 +54,13 @@
<property name="title" translatable="yes" context="shortcut window">Fullscreen</property>
</object>
</child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <property name="accelerator"><alt>backslash</property>
+ <property name="title" translatable="yes" context="shortcut window">Swap the two
panes</property>
+ </object>
+ </child>
</object>
</child>
<child>
diff --git a/meld/resources/gtk/menus.ui b/meld/resources/gtk/menus.ui
index 992f67c1..c01980ff 100644
--- a/meld/resources/gtk/menus.ui
+++ b/meld/resources/gtk/menus.ui
@@ -50,6 +50,13 @@
<attribute name="action">view.find-replace</attribute>
</item>
</section>
+ <section>
+ <attribute name="id">swap-section</attribute>
+ <item>
+ <attribute name="label" translatable="yes">Swap two panes</attribute>
+ <attribute name="action">view.swap-2-panes</attribute>
+ </item>
+ </section>
<section>
<submenu>
<attribute name="label" translatable="yes">View</attribute>
diff --git a/meld/resources/ui/dirdiff-actions.ui b/meld/resources/ui/dirdiff-actions.ui
index 9f42ceec..42028fb8 100644
--- a/meld/resources/ui/dirdiff-actions.ui
+++ b/meld/resources/ui/dirdiff-actions.ui
@@ -58,28 +58,6 @@
</child>
</object>
</child>
- <child>
- <object class="GtkButton">
- <property name="visible">True</property>
- <property name="action-name">view.folder-switch</property>
- <property name="use-action-appearance">True</property>
- <property name="tooltip-text" translatable="yes">Switch the two panes</property>
- <property name="focus_on_click">False</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">system-switch-user-symbolic</property>
- <property name="icon-size">1</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
diff --git a/meld/resources/ui/filediff-actions.ui b/meld/resources/ui/filediff-actions.ui
index ce7086dd..375a1173 100644
--- a/meld/resources/ui/filediff-actions.ui
+++ b/meld/resources/ui/filediff-actions.ui
@@ -58,28 +58,6 @@
</child>
</object>
</child>
- <child>
- <object class="GtkButton">
- <property name="visible">True</property>
- <property name="action-name">view.file-switch</property>
- <property name="use-action-appearance">True</property>
- <property name="tooltip-text" translatable="yes">Switch the two panes</property>
- <property name="focus_on_click">False</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">system-switch-user-symbolic</property>
- <property name="icon-size">1</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
<child>
<object class="GtkMenuButton" id="copy_action_button">
<property name="visible">true</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]