[kupfer: 8/24] plugins.openoffice: Provide all OO.o apps with content
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer: 8/24] plugins.openoffice: Provide all OO.o apps with content
- Date: Fri, 27 Nov 2009 13:39:11 +0000 (UTC)
commit 17383e377949ed5b04ecc671cae349954728ba4b
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sun Nov 22 01:50:05 2009 +0100
plugins.openoffice: Provide all OO.o apps with content
Make a variant of AppLeafContentMixin to make the same recent
documents source provide content for multiple applications. This is
not a 1-to-1 correspondance, so we don't hide the source as being the
application.
kupfer/plugin/openoffice.py | 36 +++++++++++++++++++++++++++++++++---
1 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/plugin/openoffice.py b/kupfer/plugin/openoffice.py
index b1c6aa6..14e7c7e 100644
--- a/kupfer/plugin/openoffice.py
+++ b/kupfer/plugin/openoffice.py
@@ -4,9 +4,9 @@ import os
from xml.etree import ElementTree
import gio
-from kupfer.objects import (Source, FileLeaf, UrlLeaf, PicklingHelperMixin,
- AppLeafContentMixin)
+from kupfer.objects import Source, FileLeaf, UrlLeaf, AppLeaf
from kupfer import plugin_support
+from kupfer.helplib import PicklingHelperMixin
__kupfer_name__ = _("OpenOffice")
__kupfer_sources__ = ("RecentsSource", )
@@ -21,8 +21,37 @@ __kupfer_settings__ = plugin_support.PluginSettings(
_HISTORY_FILE = "~/.openoffice.org/3/user/registry/data/org/openoffice/Office/Histories.xcu"
_NAME_ATTR="{http://openoffice.org/2001/registry}name"
-
-class RecentsSource (AppLeafContentMixin, Source, PicklingHelperMixin):
+class MultiAppContentMixin (object):
+ """
+ Mixin for Source that decorates many app leaves
+
+ This Mixin sees to that the Source is set as content for the applications
+ with id 'cls.appleaf_content_id', which may also be a sequence of ids.
+
+ Source has to define the attribute appleaf_content_id and must
+ inherit this mixin BEFORE the Source
+
+ This Mixin defines:
+ decorates_type,
+ decorates_item
+ """
+ @classmethod
+ def __get_appleaf_id_iter(cls):
+ if hasattr(cls.appleaf_content_id, "__iter__"):
+ ids = iter(cls.appleaf_content_id)
+ else:
+ ids = (cls.appleaf_content_id, )
+ return ids
+ @classmethod
+ def decorates_type(cls):
+ return AppLeaf
+ @classmethod
+ def decorate_item(cls, leaf):
+ if leaf.get_id() in cls.__get_appleaf_id_iter():
+ return cls()
+
+
+class RecentsSource (MultiAppContentMixin, Source, PicklingHelperMixin):
appleaf_content_id = [
"openoffice.org-writer",
"openoffice.org-base",
@@ -30,6 +59,7 @@ class RecentsSource (AppLeafContentMixin, Source, PicklingHelperMixin):
"openoffice.org-draw",
"openoffice.org-impress",
"openoffice.org-math",
+ "openoffice.org-startcenter",
]
def __init__(self, name=_("OpenOffice Recent Items")):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]