[meld: 1/2] dirdiff: Add 'Copy File Names' to context menu
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 1/2] dirdiff: Add 'Copy File Names' to context menu
- Date: Sat, 11 Jan 2020 21:55:17 +0000 (UTC)
commit 00d7fdc672599b3b5d649f544135ba65eb393f50
Author: WenGuoyao <wenguoyao outlook com>
Date: Sat Jan 11 21:54:58 2020 +0000
dirdiff: Add 'Copy File Names' to context menu
During directory comparison, it's sometimes useful to copy the names
of the files to clipboard.
meld/dirdiff.py | 15 +++++++++++++++
meld/resources/ui/dirdiff-menus.ui | 4 ++++
2 files changed, 19 insertions(+)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 5d5c7428..a99779dd 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -423,6 +423,7 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
('previous-change', self.action_previous_change),
('previous-pane', self.action_prev_pane),
('refresh', self.action_refresh),
+ ('copy-file-paths', self.action_copy_file_paths),
)
for name, callback in actions:
action = Gio.SimpleAction.new(name, None)
@@ -1354,6 +1355,20 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
if files:
self._open_files(files)
+ def action_copy_file_paths(self, *args):
+ pane = self._get_focused_pane()
+ if pane is None:
+ return
+ files = [
+ self.model.value_path(self.model.get_iter(p), pane)
+ for p in self._get_selected_paths(pane)
+ ]
+ files = [f for f in files if f]
+ if files:
+ clip = Gtk.Clipboard.get_default(Gdk.Display.get_default())
+ clip.set_text(''.join([str(f) for f in files]), -1)
+ clip.store()
+
def action_ignore_case_change(self, action, value):
action.set_state(value)
self.refresh()
diff --git a/meld/resources/ui/dirdiff-menus.ui b/meld/resources/ui/dirdiff-menus.ui
index ece808ce..4a2b459c 100644
--- a/meld/resources/ui/dirdiff-menus.ui
+++ b/meld/resources/ui/dirdiff-menus.ui
@@ -40,6 +40,10 @@
<attribute name="label" translatable="yes">_Open Externally</attribute>
<attribute name="action">view.open-external</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">_Copy File Paths</attribute>
+ <attribute name="action">view.copy-file-paths</attribute>
+ </item>
</section>
</menu>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]