Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-05-30 16:43:31 (GMT)
committer Simon McVittie <simon.mcvittie@collabora.co.uk>2007-05-30 16:43:31 (GMT)
commitcd12b599673a9a9706d9a75f458b2727f404e572 (patch)
treed25374f5dab77dbb63ab8d62d477860ef13855e1 /services
parent22b1338ac5559e46136289711f5f7e91ec293839 (diff)
parent527e22ba5dbcbc9fcec877e95479ae71d7ddf317 (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
Diffstat (limited to 'services')
-rw-r--r--services/clipboard/Makefile.am17
-rw-r--r--services/clipboard/objecttypeservice.py62
-rw-r--r--services/clipboard/org.laptop.ObjectTypeRegistry.service.in4
3 files changed, 77 insertions, 6 deletions
diff --git a/services/clipboard/Makefile.am b/services/clipboard/Makefile.am
index a656ee2..7a957c2 100644
--- a/services/clipboard/Makefile.am
+++ b/services/clipboard/Makefile.am
@@ -1,17 +1,22 @@
servicedir = $(datadir)/dbus-1/services
-service_in_files = org.laptop.Clipboard.service.in
+
+service_in_files = \
+ org.laptop.Clipboard.service.in \
+ org.laptop.ObjectTypeRegistry.service.in
+
service_DATA = $(service_in_files:.service.in=.service)
$(service_DATA): $(service_in_files) Makefile
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
sugardir = $(pkgdatadir)/services/clipboard
-sugar_PYTHON = \
- __init__.py \
- clipboardobject.py \
- clipboardservice.py \
- typeregistry.py
+sugar_PYTHON = \
+ __init__.py \
+ clipboardobject.py \
+ clipboardservice.py \
+ objecttypeservice.py \
+ typeregistry.py
bin_SCRIPTS = sugar-clipboard
diff --git a/services/clipboard/objecttypeservice.py b/services/clipboard/objecttypeservice.py
new file mode 100644
index 0000000..bf9083f
--- /dev/null
+++ b/services/clipboard/objecttypeservice.py
@@ -0,0 +1,62 @@
+# Copyright (C) 2007, Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import dbus
+import dbus.service
+
+from sugar.objects.objecttype import ObjectType
+
+_REGISTRY_IFACE = "org.laptop.ObjectTypeRegistry"
+_REGISTRY_PATH = "/org/laptop/ObjectTypeRegistry"
+
+class ObjectTypeRegistry(dbus.service.Object):
+ def __init__(self):
+ bus = dbus.SessionBus()
+ bus_name = dbus.service.BusName(self._REGISTRY_IFACE, bus=bus)
+ dbus.service.Object.__init__(self, bus_name, self._REGISTRY_PATH)
+
+ self._types = {}
+
+ self._add_primitive('Text', _('Text'), 'object-text',
+ [ 'text/rtf' ])
+ self._add_primitive('Image', _('Image'), 'object-image',
+ [ 'image/png' ])
+
+ def _add_primitive(self, type_id, name, icon, mime_types):
+ object_type = ObjectType(type_id, name, icon, mime_types)
+ self._types.add(object_type)
+
+ def _get_type_for_mime(self, mime_type):
+ for object_type in self._types.values():
+ if mime_type in object_type.mime_types:
+ return object_type
+
+ @dbus.service.method(_CLIPBOARD_DBUS_INTERFACE,
+ in_signature="s", out_signature="a{sv}")
+ def GetType(self, type_id):
+ if self._types.has_key(type_id):
+ return self._types[type_id].to_dict()
+ else:
+ return []
+
+ @dbus.service.method(_CLIPBOARD_DBUS_INTERFACE,
+ in_signature="s", out_signature="a{sv}")
+ def GetTypeForMIME(self, mime_type):
+ object_type = self._get_type_for_mime(mime_type)
+ if object_type:
+ return object_type.to_dict()
+ else:
+ return []
diff --git a/services/clipboard/org.laptop.ObjectTypeRegistry.service.in b/services/clipboard/org.laptop.ObjectTypeRegistry.service.in
new file mode 100644
index 0000000..66477eb
--- /dev/null
+++ b/services/clipboard/org.laptop.ObjectTypeRegistry.service.in
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name = org.laptop.ObjectTypeRegistry
+Exec = @bindir@/sugar-clipboard
+