[kupfer] objects, plugin.clipboard: Simplify TextLeaf name/description handling
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] objects, plugin.clipboard: Simplify TextLeaf name/description handling
- Date: Tue, 25 Aug 2009 13:21:03 +0000 (UTC)
commit 0e6e633514396a6bd26642b22728994d8fec6d96
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Mon Aug 24 15:41:26 2009 +0200
objects, plugin.clipboard: Simplify TextLeaf name/description handling
kupfer/objects.py | 6 ++----
kupfer/plugin/clipboard.py | 6 +-----
2 files changed, 3 insertions(+), 9 deletions(-)
---
diff --git a/kupfer/objects.py b/kupfer/objects.py
index 3b1b5fd..16bc424 100644
--- a/kupfer/objects.py
+++ b/kupfer/objects.py
@@ -1119,16 +1119,14 @@ class TextLeaf (Leaf):
return ()
def get_description(self):
- # FIXME: We should return full text and UI should handle truncating?
lines = self.object.splitlines()
- striplines = [l for l in lines if l.strip()]
+ desc = unicode(self)
numlines = len(lines) or 1
- firstline = striplines[0] if striplines else self.object
# TRANS: This is description for a TextLeaf, a free-text search
# TRANS: The plural parameter is the number of lines %(num)d
return ngettext('"%(text)s"', '(%(num)d lines) "%(text)s"',
- numlines) % {"num": numlines, "text": firstline }
+ numlines) % {"num": numlines, "text": desc }
def get_icon_name(self):
return "gtk-select-all"
diff --git a/kupfer/plugin/clipboard.py b/kupfer/plugin/clipboard.py
index 1a710eb..e62e6cd 100644
--- a/kupfer/plugin/clipboard.py
+++ b/kupfer/plugin/clipboard.py
@@ -22,14 +22,10 @@ __kupfer_settings__ = plugin_support.PluginSettings(
)
class ClipboardText (TextLeaf):
- def __init__(self, text):
- # take first non-empty line
- firstline = [l for l in text.splitlines() if l.strip()][0]
- TextLeaf.__init__(self, text, name=firstline)
def get_description(self):
lines = self.object.splitlines()
desc = unicode(self)
- numlines = len(lines)
+ numlines = len(lines) or 1
return ngettext('Clipboard "%(desc)s"',
'Clipboard with %(num)d lines "%(desc)s"',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]