[kupfer] gwibber: Use StatusTextSource



commit dbab7cbec13865cd03b87d39c43c36f05c049672
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Fri Mar 11 00:25:32 2011 +0100

    gwibber: Use StatusTextSource

 kupfer/plugin/gwibber.py |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/plugin/gwibber.py b/kupfer/plugin/gwibber.py
index 8a198d5..61e819b 100644
--- a/kupfer/plugin/gwibber.py
+++ b/kupfer/plugin/gwibber.py
@@ -27,7 +27,7 @@ import gwibber.microblog
 from kupfer import icons
 from kupfer import pretty
 from kupfer import plugin_support
-from kupfer.objects import Action, TextLeaf, Source, Leaf
+from kupfer.objects import Action, TextLeaf, Source, Leaf, TextSource
 from kupfer.obj.objects import OpenUrl
 from kupfer.weaklib import dbus_signal_connect_weakly
 
@@ -253,6 +253,9 @@ class SendMessageTo(Action):
 	def requires_object(self):
 		return True
 
+	def object_source(self, for_item=None):
+		return StatusTextSource()
+
 	def object_types(self):
 		yield TextLeaf
 
@@ -285,6 +288,9 @@ class Reply(Action):
 	def requires_object(self):
 		return True
 
+	def object_source(self, for_item=None):
+		return StatusTextSource()
+
 	def object_types(self):
 		yield TextLeaf
 
@@ -336,6 +342,9 @@ class SendPrivate(Action):
 	def requires_object(self):
 		return True
 
+	def object_source(self, for_item=None):
+		return StatusTextSource()
+
 	def object_types(self):
 		yield TextLeaf
 
@@ -540,3 +549,17 @@ class StreamMessagesSource(Source):
 
 	def get_icon_name(self):
 		return 'gwibber'
+
+class StatusTextSource (TextSource):
+	def get_rank(self):
+		return 100
+
+	def get_text_items(self, text):
+		n = len(text)
+		summary = _trunc_message(text)
+		desc_template = ngettext("%s (%d character)", "%s (%d characters)", n)
+		yield TextLeaf(text, desc_template % (summary, n))
+
+	def get_items(self, text):
+		return self.get_text_items(text)
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]