[kupfer] plugin.apt_tools: Only active for single word input



commit aa267609186a37b10060b0f414659416f7c94a57
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Tue Oct 27 00:51:46 2009 +0100

    plugin.apt_tools: Only active for single word input
    
    This action is only visible if the text is a single word. Also strip
    the text so that "python " is accepted as input.

 kupfer/plugin/apt_tools.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/plugin/apt_tools.py b/kupfer/plugin/apt_tools.py
index 93ff565..ce41b9d 100644
--- a/kupfer/plugin/apt_tools.py
+++ b/kupfer/plugin/apt_tools.py
@@ -41,10 +41,15 @@ class ShowPackageInfo (Action):
 	def is_async(self):
 		return True
 	def activate(self, leaf):
-		return InfoTask(leaf.object)
+		return InfoTask(leaf.object.strip())
 
-	def get_icon_name(self):
-		return "synaptic"
 	def item_types(self):
 		yield TextLeaf
+	def valid_for_item(self, item):
+		# check if it is a single word
+		text = item.object
+		return len(text.split(None, 1)) == 1
+
+	def get_icon_name(self):
+		return "synaptic"
 



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