[kupfer] Make Rescan action user-available for selected sources



commit 083fbe1ae5fbcb2b9fb4020f2803e8d61e341c49
Author: Karol BÄ?dkowski <karol bedkowski gmail com>
Date:   Tue Apr 6 17:31:23 2010 +0200

    Make Rescan action user-available for selected sources
    
    Sources may set the class attribute source_user_reloadable to signal
    that they want the user action 'Rescan' available for the source.

 kupfer/obj/base.py             |    4 ++++
 kupfer/plugin/core/__init__.py |   29 +++++++++++++++++++++++++++++
 kupfer/plugin/core/debug.py    |   33 ---------------------------------
 3 files changed, 33 insertions(+), 33 deletions(-)
---
diff --git a/kupfer/obj/base.py b/kupfer/obj/base.py
index 988b79f..55d7669 100644
--- a/kupfer/obj/base.py
+++ b/kupfer/obj/base.py
@@ -296,8 +296,12 @@ class Source (KupferObject, pretty.OutputMixin):
 	All Sources should be hashable and treated as equal if
 	their @repr are equal!
 
+	@source_user_reloadable if True source get "Reload" action without
+		debug mode.
 	"""
 	fallback_icon_name = "kupfer-object-multiple"
+	source_user_reloadable = False
+
 	def __init__(self, name):
 		KupferObject.__init__(self, name)
 		self.cached_items = None
diff --git a/kupfer/plugin/core/__init__.py b/kupfer/plugin/core/__init__.py
index 32111d0..9291a2e 100644
--- a/kupfer/plugin/core/__init__.py
+++ b/kupfer/plugin/core/__init__.py
@@ -6,6 +6,7 @@ __kupfer_contents__ = ()
 __kupfer_actions__ = (
 	"SearchInside",
 	"CopyToClipboard",
+	"Rescan",
 	)
 __description__ = u"Core actions and items"
 __version__ = ""
@@ -98,3 +99,31 @@ class CopyToClipboard (Action):
 	def get_icon_name(self):
 		return "gtk-copy"
 
+
+class Rescan (Action):
+	"""A source action: Rescan a source!  """
+	rank_adjust = -5
+	def __init__(self):
+		Action.__init__(self, _("Rescan"))
+
+	def activate(self, leaf):
+		if not leaf.has_content():
+			raise InvalidLeafError("Must have content")
+		source = leaf.content_source()
+		source.get_leaves(force_update=True)
+
+	def get_description(self):
+		return _("Force reindex of this source")
+	def get_icon_name(self):
+		return "gtk-refresh"
+
+	def item_types(self):
+		yield objects.AppLeaf
+		yield objects.SourceLeaf
+
+	def valid_for_item(self, item):
+		if not item.has_content():
+			return False
+		if item.content_source().is_dynamic():
+			return False
+		return _is_debug() or item.content_source().source_user_reloadable
diff --git a/kupfer/plugin/core/debug.py b/kupfer/plugin/core/debug.py
index b5c1c92..0f73ad2 100644
--- a/kupfer/plugin/core/debug.py
+++ b/kupfer/plugin/core/debug.py
@@ -15,7 +15,6 @@ __kupfer_contents__ = (
 		"ComposedSource",
 	)
 __kupfer_actions__ = (
-		"Rescan",
 		"DebugInfo",
 		"Forget",
 	)
@@ -23,38 +22,6 @@ __description__ = __doc__
 __author__ = "Ulrik Sverdrup <ulrik sverdrup gmail com>"
 
 
-class Rescan (Action):
-	"""A source action: Rescan a source!
-
-	This is a debug action because normal users should not need to use it;
-	it is only confusing and inconsistent:
-
-	* Sources with internal caching don't really rescan anyway.
-	* Change callbacks make it redundant
-	"""
-	rank_adjust = -5
-	def __init__(self):
-		Action.__init__(self, _("Rescan"))
-
-	def activate(self, leaf):
-		if not leaf.has_content():
-			raise InvalidLeafError("Must have content")
-		source = leaf.content_source()
-		source.get_leaves(force_update=True)
-
-	def get_description(self):
-		return _("Force reindex of this source")
-	def get_icon_name(self):
-		return "gtk-refresh"
-
-	def item_types(self):
-		yield objects.AppLeaf
-		yield objects.SourceLeaf
-	def valid_for_item(self, item):
-		if not item.has_content():
-			return False
-		return not item.content_source().is_dynamic()
-
 class DebugInfo (Action):
 	""" Print debug info to terminal """
 	rank_adjust = -50



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