[kupfer] gwibber, pidgin: Use normal TextSource



commit 49a54fc52ef0192f4078475c33dddd315bb13122
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Tue Mar 29 19:46:24 2011 +0200

    gwibber, pidgin: Use normal TextSource
    
    A character count in the text object itself is not needed.

 kupfer/plugin/gwibber.py |   35 +++++++++++++++--------------------
 kupfer/plugin/pidgin.py  |    5 ++++-
 2 files changed, 19 insertions(+), 21 deletions(-)
---
diff --git a/kupfer/plugin/gwibber.py b/kupfer/plugin/gwibber.py
index 9dc1e44..b7242ef 100644
--- a/kupfer/plugin/gwibber.py
+++ b/kupfer/plugin/gwibber.py
@@ -257,11 +257,15 @@ class SendMessageTo(Action):
 		return True
 
 	def object_source(self, for_item=None):
-		return StatusTextSource()
+		return TextSource()
 
 	def object_types(self):
 		yield TextLeaf
 
+	def valid_object(self, iobj, for_item=None):
+		# ugly, but we don't want derived text
+		return type(iobj) is TextLeaf
+
 	def get_gicon(self):
 		return icons.ComposedIcon("gwibber", "mail-message-new")
 
@@ -292,11 +296,15 @@ class Reply(Action):
 		return True
 
 	def object_source(self, for_item=None):
-		return StatusTextSource()
+		return TextSource()
 
 	def object_types(self):
 		yield TextLeaf
 
+	def valid_object(self, iobj, for_item=None):
+		# ugly, but we don't want derived text
+		return type(iobj) is TextLeaf
+
 	def get_gicon(self):
 		return icons.ComposedIcon("gwibber", "mail-reply-all")
 
@@ -346,11 +354,15 @@ class SendPrivate(Action):
 		return True
 
 	def object_source(self, for_item=None):
-		return StatusTextSource()
+		return TextSource()
 
 	def object_types(self):
 		yield TextLeaf
 
+	def valid_object(self, iobj, for_item=None):
+		# ugly, but we don't want derived text
+		return type(iobj) is TextLeaf
+
 	def get_gicon(self):
 		return icons.ComposedIcon("gwibber", "mail-reply-sender")
 
@@ -575,20 +587,3 @@ class StreamMessagesSource(Source):
 		yield Message
 
 
-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)
-
-	def provides(self):
-		yield TextLeaf
-
-
diff --git a/kupfer/plugin/pidgin.py b/kupfer/plugin/pidgin.py
index 66144aa..42935f0 100644
--- a/kupfer/plugin/pidgin.py
+++ b/kupfer/plugin/pidgin.py
@@ -130,7 +130,10 @@ class SendMessage (ContactAction):
 	def object_types(self):
 		yield TextLeaf
 	def object_source(self, for_item=None):
-		return ChatTextSource()
+		return TextSource()
+	def valid_object(self, iobj, for_item=None):
+		# ugly, but we don't want derived text
+		return type(iobj) is TextLeaf
 
 class PidginContact(ContactLeaf):
 	""" Leaf represent single contact from Pidgin """



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