[kupfer] plugin.core: Internalize Selection and Text



commit 828dfa53aac9e8b27dd06fd78a99ceb62a09e56c
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Dec 17 00:37:41 2009 +0100

    plugin.core: Internalize Selection and Text
    
    We make the very basic plugins for current text selection and for
    Free-text Queries built-in parts of the core plugin package.
    
    These plugins are too light to stand on their own, and in normal
    Kupfer use it hardly makes sense to be able to remove the text.py
    plugin.
    
    The core plugin *package* makes it rational to internalize more
    functionality to be "builtin" to Kupfer (by virtue of being part of
    the hidden, enabled-by-default core plugin).
    
    This allows us to remove some noise on the string side; these
    internalized plugins don't need localized plugin descriptions etc.

 data/defaults.cfg                     |    6 ------
 kupfer/plugin/core/__init__.py        |   32 +++++++++++++++++++++-----------
 kupfer/plugin/{ => core}/selection.py |   14 ++++++++------
 kupfer/plugin/{ => core}/text.py      |   10 +++++-----
 po/POTFILES.in                        |    4 ++--
 5 files changed, 36 insertions(+), 30 deletions(-)
---
diff --git a/data/defaults.cfg b/data/defaults.cfg
index 29d230c..e2a6f9d 100644
--- a/data/defaults.cfg
+++ b/data/defaults.cfg
@@ -70,9 +70,6 @@ kupfer_enabled = True
 [plugin_rhythmbox]
 kupfer_enabled = True
 
-[plugin_selection]
-kupfer_enabled = True
-
 [plugin_session_gnome]
 kupfer_enabled = True
 
@@ -82,9 +79,6 @@ kupfer_enabled = False
 [plugin_screen]
 kupfer_enabled = True
 
-[plugin_text]
-kupfer_enabled = True
-
 [plugin_tracker]
 kupfer_enabled = False
 
diff --git a/kupfer/plugin/core/__init__.py b/kupfer/plugin/core/__init__.py
index e01c90e..d547741 100644
--- a/kupfer/plugin/core/__init__.py
+++ b/kupfer/plugin/core/__init__.py
@@ -4,8 +4,9 @@ from kupfer.objects import Leaf, Action, Source
 from kupfer import objects
 
 __kupfer_name__ = u"Core"
-__kupfer_sources__ = ()   # Updated later
-__kupfer_actions__ = (    # Updated later
+__kupfer_sources__ = ()      # Updated later
+__kupfer_text_sources__ = () # Updated later
+__kupfer_actions__ = (       # Updated later
 	"SearchInside",
 	"CopyToClipboard",
 	)
@@ -13,16 +14,25 @@ __description__ = u"Core actions and items"
 __version__ = ""
 __author__ = "Ulrik Sverdrup <ulrik sverdrup gmail com>"
 
-def _register_subplugin(module):
-	global __kupfer_sources__
-	global __kupfer_actions__
-	__kupfer_sources__ += module.__kupfer_sources__
-	__kupfer_actions__ += module.__kupfer_actions__
-	globals().update((attr, getattr(module, attr)) for attr in module.__all__)
+def register_subplugin(module):
+	attrs = (
+		"__kupfer_sources__",
+		"__kupfer_actions__",
+		"__kupfer_text_sources__"
+	)
+	for attr in attrs:
+		object_names = getattr(module, attr, ())
+		globals()[attr] += object_names
+		globals().update((sym, getattr(module, sym)) for sym in object_names)
+
+from kupfer.plugin.core import contents, selection, text
+from kupfer.plugin.core import debug
+
+register_subplugin(contents)
+register_subplugin(selection)
+register_subplugin(text)
+register_subplugin(debug)
 
-from kupfer.plugin.core import contents, debug
-_register_subplugin(contents)
-_register_subplugin(debug)
 
 class SearchInside (Action):
 	"""
diff --git a/kupfer/plugin/selection.py b/kupfer/plugin/core/selection.py
similarity index 81%
rename from kupfer/plugin/selection.py
rename to kupfer/plugin/core/selection.py
index 548ceec..28ffa04 100644
--- a/kupfer/plugin/selection.py
+++ b/kupfer/plugin/core/selection.py
@@ -1,19 +1,21 @@
 import gtk
 
-from kupfer.objects import Source, Leaf, TextLeaf, SourceLeaf, PicklingHelperMixin
-from kupfer import objects
+from kupfer.objects import Source, Leaf
+from kupfer.objects import TextLeaf, SourceLeaf
+from kupfer.helplib import DbusWeakCallback, PicklingHelperMixin
 from kupfer.helplib import gobject_connect_weakly
+from kupfer import kupferstring
 
 __kupfer_name__ = _("Selected Text")
 __kupfer_sources__ = ("SelectionSource", )
-__description__ = _("Provides current selection")
-__version__ = ""
+__description__ = u"Provides current selection"
+__version__ = "2009-12-16"
 __author__ = "Ulrik Sverdrup <ulrik sverdrup gmail com>"
 
 class SelectedText (TextLeaf):
 	qf_id = "selectedtext"
 	def __init__(self, text):
-		text = objects.tounicode(text)
+		text = kupferstring.tounicode(text)
 		lines = filter(None, text.splitlines())
 		summary = lines[0] if lines else text
 		maxlen = 10
@@ -49,7 +51,7 @@ class SelectionSource (Source, PicklingHelperMixin):
 			yield SelectedText(self._text)
 
 	def get_description(self):
-		return _("Provides current selection")
+		return None
 	def provides(self):
 		yield TextLeaf
 	def get_leaf_repr(self):
diff --git a/kupfer/plugin/text.py b/kupfer/plugin/core/text.py
similarity index 91%
rename from kupfer/plugin/text.py
rename to kupfer/plugin/core/text.py
index d2555d8..87cbc19 100644
--- a/kupfer/plugin/text.py
+++ b/kupfer/plugin/core/text.py
@@ -6,12 +6,12 @@ import gobject
 from kupfer.objects import TextSource, TextLeaf, FileLeaf, UrlLeaf, OpenUrl
 from kupfer import utils
 
-__kupfer_name__ = _("Free-text Queries")
+__kupfer_name__ = u"Free-text Queries"
 __kupfer_sources__ = ()
 __kupfer_text_sources__ = ("BasicTextSource", "PathTextSource", "URLTextSource",)
 __kupfer_actions__ = ("OpenTextUrl", )
-__description__ = _("Basic support for free-text queries")
-__version__ = ""
+__description__ = u"Basic support for free-text queries"
+__version__ = "2009-12-16"
 __author__ = "Ulrik Sverdrup <ulrik sverdrup gmail com>"
 
 class BasicTextSource (TextSource):
@@ -30,7 +30,7 @@ class BasicTextSource (TextSource):
 class PathTextSource (TextSource):
 	"""Return existing full paths if typed"""
 	def __init__(self):
-		TextSource.__init__(self, name=_("Filesystem Text Matches"))
+		TextSource.__init__(self, name=u"Filesystem Text Matches")
 
 	def get_rank(self):
 		return 80
@@ -81,7 +81,7 @@ class OpenTextUrl (OpenUrl):
 class URLTextSource (TextSource):
 	"""detect URLs and webpages"""
 	def __init__(self):
-		TextSource.__init__(self, name=_("URL Text Matches"))
+		TextSource.__init__(self, name=u"URL Text Matches")
 
 	def get_rank(self):
 		return 75
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d1ed577..1ce65d3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -20,6 +20,8 @@ kupfer/plugin/commands.py
 kupfer/plugin/core/contents.py
 kupfer/plugin/core/debug.py
 kupfer/plugin/core/__init__.py
+kupfer/plugin/core/selection.py
+kupfer/plugin/core/text.py
 kupfer/plugin/devhelp.py
 kupfer/plugin/dictionary.py
 kupfer/plugin/documents.py
@@ -43,7 +45,6 @@ kupfer/plugin/putty.py
 kupfer/plugin/rhythmbox.py
 kupfer/plugin/rst.py
 kupfer/plugin/screen.py
-kupfer/plugin/selection.py
 kupfer/plugin/services.py
 kupfer/plugin/session_gnome.py
 kupfer/plugin/session_support.py
@@ -52,7 +53,6 @@ kupfer/plugin/show_text.py
 kupfer/plugins.py
 kupfer/plugin_support.py
 kupfer/plugin/templates.py
-kupfer/plugin/text.py
 kupfer/plugin/top.py
 kupfer/plugin/tracker.py
 kupfer/plugin/trash.py



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