Merge branch 'master' of git+ssh://danw@dev.laptop.org/git/sugar
commit
bdba2d149e
@ -1 +1 @@
|
||||
SUBDIRS = clipboard console
|
||||
SUBDIRS = shell console
|
||||
|
@ -1,29 +1,37 @@
|
||||
servicedir = $(datadir)/dbus-1/services
|
||||
|
||||
service_in_files = \
|
||||
org.laptop.ActivityRegistry.service.in \
|
||||
org.laptop.Clipboard.service.in \
|
||||
org.laptop.ObjectTypeRegistry.service.in
|
||||
|
||||
service_DATA = \
|
||||
org.laptop.ActivityRegistry.service \
|
||||
org.laptop.Clipboard.service \
|
||||
org.laptop.ObjectTypeRegistry.service
|
||||
|
||||
org.laptop.ActivityRegistry.service: org.laptop.ActivityRegistry.service.in Makefile
|
||||
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
|
||||
|
||||
org.laptop.Clipboard.service: org.laptop.Clipboard.service.in Makefile
|
||||
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
|
||||
|
||||
org.laptop.ObjectTypeRegistry.service: org.laptop.ObjectTypeRegistry.service.in Makefile
|
||||
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
|
||||
|
||||
sugardir = $(pkgdatadir)/services/clipboard
|
||||
sugardir = $(pkgdatadir)/services/shell
|
||||
|
||||
sugar_PYTHON = \
|
||||
__init__.py \
|
||||
clipboardobject.py \
|
||||
clipboardservice.py \
|
||||
sugar_PYTHON = \
|
||||
__init__.py \
|
||||
activityregistryservice.py \
|
||||
bundleregistry.py \
|
||||
clipboardobject.py \
|
||||
clipboardservice.py \
|
||||
objecttypeservice.py
|
||||
|
||||
bin_SCRIPTS = sugar-clipboard
|
||||
bin_SCRIPTS = sugar-shell-service
|
||||
|
||||
DISTCLEANFILES = $(service_DATA)
|
||||
|
||||
EXTRA_DIST = $(service_in_files) $(bin_SCRIPTS)
|
||||
|
@ -0,0 +1,104 @@
|
||||
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||
# Copyright (C) 2007 One Laptop Per Child
|
||||
#
|
||||
# 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
|
||||
|
||||
import bundleregistry
|
||||
|
||||
_ACTIVITY_REGISTRY_SERVICE_NAME = 'org.laptop.ActivityRegistry'
|
||||
_ACTIVITY_REGISTRY_IFACE = 'org.laptop.ActivityRegistry'
|
||||
_ACTIVITY_REGISTRY_PATH = '/org/laptop/ActivityRegistry'
|
||||
|
||||
class ActivityRegistry(dbus.service.Object):
|
||||
def __init__(self):
|
||||
bus = dbus.SessionBus()
|
||||
bus_name = dbus.service.BusName(_ACTIVITY_REGISTRY_SERVICE_NAME, bus=bus)
|
||||
dbus.service.Object.__init__(self, bus_name, _ACTIVITY_REGISTRY_PATH)
|
||||
|
||||
bundle_registry = bundleregistry.get_registry()
|
||||
bundle_registry.connect('bundle-added', self._bundle_added_cb)
|
||||
|
||||
@dbus.service.method(_ACTIVITY_REGISTRY_IFACE,
|
||||
in_signature='s', out_signature='b')
|
||||
def AddBundle(self, bundle_path):
|
||||
'''Register the activity bundle with the global registry
|
||||
|
||||
bundle_path -- path to the activity bundle's root directory,
|
||||
that is, the directory with activity/activity.info as a
|
||||
child of the directory.
|
||||
|
||||
The bundleregistry.BundleRegistry is responsible for setting
|
||||
up a set of d-bus service mappings for each available activity.
|
||||
'''
|
||||
registry = bundleregistry.get_registry()
|
||||
return registry.add_bundle(bundle_path)
|
||||
|
||||
@dbus.service.method(_ACTIVITY_REGISTRY_IFACE,
|
||||
in_signature='s', out_signature='a{sv}')
|
||||
def GetActivity(self, service_name):
|
||||
registry = bundleregistry.get_registry()
|
||||
bundle = registry.get_bundle(service_name)
|
||||
if not bundle:
|
||||
return {}
|
||||
|
||||
return self._bundle_to_dict(bundle)
|
||||
|
||||
@dbus.service.method(_ACTIVITY_REGISTRY_IFACE,
|
||||
in_signature='s', out_signature='aa{sv}')
|
||||
def FindActivity(self, name):
|
||||
result = []
|
||||
key = name.lower()
|
||||
|
||||
for bundle in bundleregistry.get_registry():
|
||||
name = bundle.get_name().lower()
|
||||
service_name = bundle.get_service_name().lower()
|
||||
if name.find(key) != -1 or service_name.find(key) != -1:
|
||||
result.append(self._bundle_to_dict(bundle))
|
||||
|
||||
return result
|
||||
|
||||
@dbus.service.method(_ACTIVITY_REGISTRY_IFACE,
|
||||
in_signature='s', out_signature='aa{sv}')
|
||||
def GetActivitiesForType(self, mime_type):
|
||||
result = []
|
||||
registry = bundleregistry.get_registry()
|
||||
for bundle in registry.get_activities_for_type(mime_type):
|
||||
result.append(self._bundle_to_dict(bundle))
|
||||
return result
|
||||
|
||||
@dbus.service.signal(_ACTIVITY_REGISTRY_IFACE, signature='a{sv}')
|
||||
def ActivityAdded(self, activity_info):
|
||||
pass
|
||||
|
||||
def _bundle_to_dict(self, bundle):
|
||||
return {'name': bundle.get_name(),
|
||||
'icon': bundle.get_icon(),
|
||||
'service_name': bundle.get_service_name(),
|
||||
'path': bundle.get_path()}
|
||||
|
||||
def _bundle_added_cb(self, bundle_registry, bundle):
|
||||
self.ActivityAdded(self._bundle_to_dict(bundle))
|
||||
|
||||
_instance = None
|
||||
|
||||
def get_instance():
|
||||
global _instance
|
||||
if not _instance:
|
||||
_instance = ActivityRegistry()
|
||||
return _instance
|
||||
|
@ -0,0 +1,4 @@
|
||||
[D-BUS Service]
|
||||
Name = org.laptop.ActivityRegistry
|
||||
Exec = @bindir@/sugar-shell-service
|
||||
|
@ -1,4 +1,4 @@
|
||||
[D-BUS Service]
|
||||
Name = org.laptop.Clipboard
|
||||
Exec = @bindir@/sugar-clipboard
|
||||
Exec = @bindir@/sugar-shell-service
|
||||
|
@ -1,4 +1,4 @@
|
||||
[D-BUS Service]
|
||||
Name = org.laptop.ObjectTypeRegistry
|
||||
Exec = @bindir@/sugar-clipboard
|
||||
Exec = @bindir@/sugar-shell-service
|
||||
|
Loading…
Reference in New Issue