diff options
author | Marco Pesenti Gritti <mpg@redhat.com> | 2007-08-15 19:18:58 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <mpg@redhat.com> | 2007-08-15 19:18:58 (GMT) |
commit | 3bb86e0cbbbd5f93b14f0672a88a43776ec47d94 (patch) | |
tree | c9280615bc0fad5153b27f8b27a0d255326e8690 /sugar | |
parent | 4f1986e8a4e3ce567595404a9d425a58f16f4f1c (diff) | |
parent | 26c5ad6ad05d5d1eba9bfefb092ad2245caa5a94 (diff) |
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
Diffstat (limited to 'sugar')
-rw-r--r-- | sugar/clipboard/clipboardservice.py | 10 | ||||
-rw-r--r-- | sugar/datastore/datastore.py | 3 | ||||
-rw-r--r-- | sugar/datastore/dbus_helpers.py | 38 |
3 files changed, 31 insertions, 20 deletions
diff --git a/sugar/clipboard/clipboardservice.py b/sugar/clipboard/clipboardservice.py index dbdf41d..0e357fe 100644 --- a/sugar/clipboard/clipboardservice.py +++ b/sugar/clipboard/clipboardservice.py @@ -23,7 +23,7 @@ NAME_KEY = 'NAME' PERCENT_KEY = 'PERCENT' ICON_KEY = 'ICON' PREVIEW_KEY = 'PREVIEW' -ACTIVITY_KEY = 'ACTIVITY' +ACTIVITIES_KEY = 'ACTIVITIES' FORMATS_KEY = 'FORMATS' TYPE_KEY = 'TYPE' @@ -51,7 +51,7 @@ class ClipboardService(gobject.GObject): 'object-deleted': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([str])), 'object-state-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([str, str, int, str, str, str])), + ([str, str, int, str, str, object])), } def __init__(self): @@ -118,13 +118,13 @@ class ClipboardService(gobject.GObject): percent icon preview - activity + activities From the ClipboardObject instance which is being described. """ self.emit('object-state-changed', str(object_id), values[NAME_KEY], values[PERCENT_KEY], values[ICON_KEY], values[PREVIEW_KEY], - values[ACTIVITY_KEY]) + values[ACTIVITIES_KEY]) def add_object(self, name): """Add a new object to the path @@ -193,7 +193,7 @@ class ClipboardService(gobject.GObject): PERCENT_KEY: number, ICON_KEY: str, PREVIEW_KEY: XXX what is it?, - ACTIVITY_KEY: source activity id, + ACTIVITIES_KEY: activities that can open this object, FORMATS_KEY: list of XXX what is it? """ return self._dbus_service.get_object(dbus.ObjectPath(object_id),) diff --git a/sugar/datastore/datastore.py b/sugar/datastore/datastore.py index 5ba994d..0dbe35b 100644 --- a/sugar/datastore/datastore.py +++ b/sugar/datastore/datastore.py @@ -120,6 +120,9 @@ class DSObject(object): def resume(self, service_name=None): if self.is_bundle(): + if service_name is not None: + raise ValueError('Object is a bundle, cannot be resumed as an activity.') + bundle = Bundle(self.file_path) if not bundle.is_installed(): bundle.install() diff --git a/sugar/datastore/dbus_helpers.py b/sugar/datastore/dbus_helpers.py index f0cfa3b..442a35d 100644 --- a/sugar/datastore/dbus_helpers.py +++ b/sugar/datastore/dbus_helpers.py @@ -28,55 +28,63 @@ DS_DBUS_SERVICE = "org.laptop.sugar.DataStore" DS_DBUS_INTERFACE = "org.laptop.sugar.DataStore" DS_DBUS_PATH = "/org/laptop/sugar/DataStore" -_bus = dbus.SessionBus() -_data_store = dbus.Interface(_bus.get_object(DS_DBUS_SERVICE, DS_DBUS_PATH), - DS_DBUS_INTERFACE) +_data_store = None + +def _get_data_store(): + global _data_store + + if not _data_store: + _bus = dbus.SessionBus() + _data_store = dbus.Interface(_bus.get_object(DS_DBUS_SERVICE, + DS_DBUS_PATH), + DS_DBUS_INTERFACE) + return _data_store def create(properties, filename): - object_id = _data_store.create(dbus.Dictionary(properties), filename) + object_id = _get_data_store().create(dbus.Dictionary(properties), filename) logging.debug('dbus_helpers.create: ' + object_id) return object_id def update(uid, properties, filename, reply_handler=None, error_handler=None, timeout=-1): logging.debug('dbus_helpers.update: %s, %s, %s' % (uid, filename, properties)) if reply_handler and error_handler: - _data_store.update(uid, dbus.Dictionary(properties), filename, + _get_data_store().update(uid, dbus.Dictionary(properties), filename, reply_handler=reply_handler, error_handler=error_handler, timeout=timeout) else: - _data_store.update(uid, dbus.Dictionary(properties), filename) + _get_data_store().update(uid, dbus.Dictionary(properties), filename) def delete(uid): logging.debug('dbus_helpers.delete: %r' % uid) - _data_store.delete(uid) + _get_data_store().delete(uid) def get_properties(uid): logging.debug('dbus_helpers.get_properties: %s' % uid) - return _data_store.get_properties(uid) + return _get_data_store().get_properties(uid) def get_filename(uid): - filename = _data_store.get_filename(uid) + filename = _get_data_store().get_filename(uid) logging.debug('dbus_helpers.get_filename: %s, %s' % (uid, filename)) return filename def find(query, reply_handler, error_handler): logging.debug('dbus_helpers.find: %r' % query) if reply_handler and error_handler: - return _data_store.find(query, reply_handler=reply_handler, + return _get_data_store().find(query, reply_handler=reply_handler, error_handler=error_handler) else: - return _data_store.find(query) + return _get_data_store().find(query) def mount(uri, options): - return _data_store.mount(uri, options) + return _get_data_store().mount(uri, options) def unmount(mount_point_id): - _data_store.unmount(mount_point_id) + _get_data_store().unmount(mount_point_id) def mounts(): - return _data_store.mounts() + return _get_data_store().mounts() def get_unique_values(key): - return _data_store.get_uniquevaluesfor(key, dbus.Dictionary({}, signature='ss')) + return _get_data_store().get_uniquevaluesfor(key, dbus.Dictionary({}, signature='ss')) |