[meld] Rework recent comparison API to return Gio.File instead of a URI
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Rework recent comparison API to return Gio.File instead of a URI
- Date: Sat, 18 Nov 2017 21:41:21 +0000 (UTC)
commit 51681d718899ab8c73522043a6cbd53c5a6ecbbb
Author: Kai Willadsen <kai willadsen gmail com>
Date: Wed Nov 15 07:30:15 2017 +1000
Rework recent comparison API to return Gio.File instead of a URI
Previously this took a path, and the with the other Gio.File changes
changed to take a URI. While this is fine, there's no reason we can't
do the URI conversion on the recent files end and avoid doing it
in multiple places elsewhere.
As a bonus, this fixes a traceback when you tried to compare a file
with None (e.g., by using the New Comparison tab and selecting only one
file, leaving the second selector empty).
meld/dirdiff.py | 2 +-
meld/filediff.py | 3 +--
meld/recent.py | 6 ++++--
meld/vcview.py | 2 +-
4 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 0920b37..ab1ade1 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -641,7 +641,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
def get_comparison(self):
root = self.model.get_iter_first()
if root:
- uris = [Gio.File.new_for_path(d).get_uri()
+ uris = [Gio.File.new_for_path(d)
for d in self.model.value_paths(root)]
else:
uris = []
diff --git a/meld/filediff.py b/meld/filediff.py
index 6c8f754..0fbb20f 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1069,8 +1069,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
)
def get_comparison(self):
- uris = [b.data.gfile.get_uri()
- for b in self.textbuffer[:self.num_panes]]
+ uris = [b.data.gfile for b in self.textbuffer[:self.num_panes]]
return recent.TYPE_FILE, uris
def file_loaded(self, loader, result, user_data):
diff --git a/meld/recent.py b/meld/recent.py
index 380684b..e64360e 100644
--- a/meld/recent.py
+++ b/meld/recent.py
@@ -81,13 +81,15 @@ class RecentFiles(object):
The passed flags are currently ignored. In the future these are to be
used for extra initialisation not captured by the tab itself.
"""
- comp_type, uris = tab.get_comparison()
+ comp_type, gfiles = tab.get_comparison()
# While Meld handles comparisons including None, recording these as
# recently-used comparisons just isn't that sane.
- if None in uris:
+ if None in gfiles:
return
+ uris = [f.get_uri() for f in gfiles]
+
# If a (type, uris) comparison is already registered, then re-add
# the corresponding comparison file
comparison_key = (comp_type, tuple(uris))
diff --git a/meld/vcview.py b/meld/vcview.py
index 13ba513..2aa853b 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -325,7 +325,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
self.scheduler.add_task(self.on_treeview_cursor_changed)
def get_comparison(self):
- uris = [Gio.File.new_for_path(self.location).get_uri()]
+ uris = [Gio.File.new_for_path(self.location)]
return recent.TYPE_VC, uris
def recompute_label(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]