[meld: 1/5] [feat]add a new feature: switch the panes - only supports in the two panes mode - the left pane to r
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 1/5] [feat]add a new feature: switch the panes - only supports in the two panes mode - the left pane to r
- Date: Sat, 9 Apr 2022 23:19:04 +0000 (UTC)
commit 4cc699b74428fec87e2f818dbfd39e0cc3341ed3
Author: Helly Guo <buffoonguo gmail com>
Date: Tue Mar 22 21:20:49 2022 +0800
[feat]add a new feature: switch the panes
- only supports in the two panes mode
- the left pane to right and the right one to left
meld/dirdiff.py | 8 ++++++++
meld/filediff.py | 7 +++++++
meld/resources/ui/dirdiff-actions.ui | 22 ++++++++++++++++++++++
meld/resources/ui/filediff-actions.ui | 22 ++++++++++++++++++++++
4 files changed, 59 insertions(+)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 34dffc07..125c9810 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -497,6 +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),
('folder-delete', self.action_delete),
('folder-expand', self.action_folder_expand),
('next-change', self.action_next_change),
@@ -1327,6 +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('folder-delete', is_valid)
self.set_action_enabled('folder-copy-left', is_valid and pane > 0)
self.set_action_enabled(
@@ -1579,6 +1581,12 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
def action_copy_right(self, *args):
self.copy_selected(1)
+ def action_switch(self, *args):
+ folder_x = self.folders[0]
+ self.folders[0] = self.folders[1]
+ self.folders[1] = folder_x
+ self.refresh()
+
def action_delete(self, *args):
self.delete_selected()
diff --git a/meld/filediff.py b/meld/filediff.py
index 108a68b8..c6a04f46 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -351,6 +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),
)
for name, callback in actions:
action = Gio.SimpleAction.new(name, None)
@@ -725,6 +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)
# FIXME: don't queue_draw() on everything... just on what changed
self.queue_draw()
@@ -2469,5 +2471,10 @@ class FileDiff(Gtk.VBox, MeldDoc):
mgr.clear()
self.refresh_comparison()
+ def action_switch(self, *args):
+ buffer0 = self.textbuffer[0]
+ buffer1 = self.textbuffer[1]
+ self.set_files([buffer1.data.gfile, buffer0.data.gfile])
+
FileDiff.set_css_name('meld-file-diff')
diff --git a/meld/resources/ui/dirdiff-actions.ui b/meld/resources/ui/dirdiff-actions.ui
index 42028fb8..9f42ceec 100644
--- a/meld/resources/ui/dirdiff-actions.ui
+++ b/meld/resources/ui/dirdiff-actions.ui
@@ -58,6 +58,28 @@
</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 375a1173..ce7086dd 100644
--- a/meld/resources/ui/filediff-actions.ui
+++ b/meld/resources/ui/filediff-actions.ui
@@ -58,6 +58,28 @@
</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]