[kupfer: 47/53] kupfer_plugins: Contain Source inside its own plugin object



commit 713cf6988cb08fa542abec0594a1cf9a04fe2714
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Mar 24 17:22:41 2011 +0100

    kupfer_plugins: Contain Source inside its own plugin object
    
    For fun and profit, the "Kupfer Plugins" source get a "leaf repr"
    which is the Plugin object representing itself. (So it goes recursive,
    but that's not important)
    
    This is simply what leaf_repr intended all along: reduce
    almost-duplicate objects in the catalog.

 kupfer/plugin/kupfer_plugins.py |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/plugin/kupfer_plugins.py b/kupfer/plugin/kupfer_plugins.py
index 15e103b..18eaa82 100644
--- a/kupfer/plugin/kupfer_plugins.py
+++ b/kupfer/plugin/kupfer_plugins.py
@@ -11,7 +11,7 @@ from kupfer import icons
 from kupfer import kupferui
 
 # Since this is a core plugin we break some rules
-# This module is normally out of bounds for plugins
+# These modules are normally out of bounds for plugins
 from kupfer.core import plugins, settings
 
 
@@ -100,5 +100,25 @@ class KupferPlugins (Source):
 	def provides(self):
 		yield Plugin
 
-	def get_gicon(self):
-		return icons.ComposedIcon("package-x-generic", "package-x-generic")
+	def get_icon_name(self):
+		return "package-x-generic"
+
+	@classmethod
+	def decorates_type(cls):
+		return Plugin
+
+	@classmethod
+	def decorate_item(cls, obj):
+		if cls.is_self_plugin(obj):
+			return cls()
+
+	@classmethod
+	def is_self_plugin(cls, obj):
+		self_plug_id = __name__.split(".")[-1]
+		return obj.object['name'] == self_plug_id
+
+	def get_leaf_repr(self):
+		for obj in self.get_leaves():
+			if self.is_self_plugin(obj):
+				return obj
+



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