Commit e5522a83 authored by Kai Willadsen's avatar Kai Willadsen

filediff, meldbuffer: Have BufferData record and use a gfile

parent cb8ebcd4
......@@ -1024,16 +1024,14 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
return
self._disconnect_buffer_handlers()
files = list(files)
for i, f in enumerate(files):
if not f:
continue
if not isinstance(f, unicode):
files[i] = f = f.decode('utf8')
absfile = os.path.abspath(f)
self.fileentry[i].set_filename(absfile)
self.textbuffer[i].data.reset(absfile)
self.msgarea_mgr[i].clear()
files = [(pane, Gio.File.new_for_path(filename))
for pane, filename in enumerate(files) if filename]
for pane, gfile in files:
self.fileentry[pane].set_file(gfile)
self.textbuffer[pane].data.reset(gfile)
self.msgarea_mgr[pane].clear()
self.recompute_label()
self.textview[len(files) >= 2].grab_focus()
......@@ -1041,11 +1039,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.undosequence.clear()
self.linediffer.clear()
for pane, filename in enumerate(files):
if not filename:
continue
gfile = Gio.File.new_for_path(filename)
for pane, gfile in files:
sourcefile = GtkSource.File()
sourcefile.set_location(gfile)
......@@ -1486,6 +1480,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
return False
bufdata.filename = bufdata.label = os.path.abspath(filename)
bufdata.gfile = Gio.File.new_for_path(bufdata.filename)
bufdata.savefile = None
self.fileentry[pane].set_filename(bufdata.filename)
self.filelabel_toolitem[pane].set_visible(False)
......
......@@ -107,16 +107,23 @@ class MeldBufferData(GObject.GObject):
GObject.GObject.__init__(self)
self._filename = None
self._label = None
self.reset(filename=None)
self.reset(gfile=None)
def reset(self, filename):
def reset(self, gfile):
same_file = gfile and self.gfile and gfile.equal(self.gfile)
self.gfile = gfile
self.loaded = False
self.modified = False
self.editable = True
self._monitor = None
self._mtime = None
self._disk_mtime = None
self.label = self._label if self._filename == filename else filename
# This is aiming to maintain existing behaviour for filename. The
# behaviour is however wrong and should be fixed.
filename = gfile.get_path().decode('utf8') if gfile else None
self.label = self._label if same_file else filename
self.filename = filename
self.savefile = None
self.encoding = None
......
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