[meld] Make label a MeldBufferData property
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Make label a MeldBufferData property
- Date: Sat, 5 May 2012 21:20:37 +0000 (UTC)
commit d99037d6003eba2c1ba7aeed3a023c79ebba3d97
Author: Kai Willadsen <kai willadsen gmail com>
Date: Wed Sep 28 13:09:12 2011 +1000
Make label a MeldBufferData property
meld/filediff.py | 8 ++------
meld/meldbuffer.py | 15 +++++++++++----
meld/patchdialog.py | 2 +-
3 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index b68f301..4c07cc7 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -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
diff --git a/meld/meldbuffer.py b/meld/meldbuffer.py
index 3e19bfa..83c673c 100644
--- a/meld/meldbuffer.py
+++ b/meld/meldbuffer.py
@@ -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
diff --git a/meld/patchdialog.py b/meld/patchdialog.py
index 7ab3f6d..9693856 100644
--- a/meld/patchdialog.py
+++ b/meld/patchdialog.py
@@ -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]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]