Commit d99037d6 authored by Kai Willadsen's avatar Kai Willadsen

Make label a MeldBufferData property

parent 58815911
......@@ -711,10 +711,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
elif event.keyval == gtk.keysyms.ISO_Prev_Group:
self.keymask = 0
def _get_pane_label(self, i):
#TRANSLATORS: this is the name of a new file which has not yet been saved
return self.textbuffer[i].data.label or _("<unnamed>")
def on_delete_event(self, appquit=0):
response = gtk.RESPONSE_OK
modified = [b.data.modified for b in self.textbuffer]
......@@ -723,7 +719,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
dialog.widget.set_transient_for(self.widget.get_toplevel())
buttons = []
for i in range(self.num_panes):
b = gtk.CheckButton( self._get_pane_label(i) )
b = gtk.CheckButton(self.textbuffer[i].data.label)
b.set_use_underline(False)
buttons.append(b)
dialog.box.pack_start(b, 1, 1)
......@@ -857,7 +853,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
def recompute_label(self):
filenames = []
for i in range(self.num_panes):
filenames.append( self._get_pane_label(i) )
filenames.append(self.textbuffer[i].data.label)
shortnames = misc.shorten_names(*filenames)
for i in range(self.num_panes):
stock = None
......
......@@ -16,6 +16,7 @@
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import sys
from gettext import gettext as _
import meld.util.sourceviewer
......@@ -53,18 +54,24 @@ class MeldBuffer(meld.util.sourceviewer.srcviewer.GtkTextBuffer):
class MeldBufferData(object):
__slots__ = ("modified", "writable", "filename", "savefile", "label",
"encoding", "newlines")
def __init__(self, filename=None):
self.modified = False
self.writable = True
self.filename = filename
self.savefile = None
self.label = filename
self._label = filename
self.encoding = None
self.newlines = None
def get_label(self):
#TRANSLATORS: This is the label of a new, currently-unnamed file.
return self._label or _("<unnamed>")
def set_label(self, value):
self._label = value
label = property(get_label, set_label)
class BufferLines(object):
"""gtk.TextBuffer shim with line-based access and optional filtering
......
......@@ -87,7 +87,7 @@ class PatchDialog(gnomeglade.Component):
lines = text.splitlines(True)
texts.append(lines)
names = [self.filediff._get_pane_label(i) for i in range(3)]
names = [self.filediff.textbuffer[i].data.label for i in range(3)]
prefix = os.path.commonprefix(names)
names = [n[prefix.rfind("/") + 1:] for n in names]
......
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