From 8b4ccf3eb10d0563344e123f7f2c773bba120a2f Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 14 Mar 2007 04:50:06 +0000 Subject: Cleanup clipboard D-Bus API - The clipboard now determines each objects unique id and returns it from add_object() - The ID is opaque to the client and should not be used/accessed other than with the clipboard service - Add object type hints for dbus-python - Sugar clipboard bindings for get_object() now return a dict rather than a tuple - ClipboardIcon now retrieves the real file path and uses that to open the file - Adapt sugar bits to clipboard changes --- (limited to 'sugar') diff --git a/sugar/clipboard/clipboardservice.py b/sugar/clipboard/clipboardservice.py index 1878cba..c7d68e4 100644 --- a/sugar/clipboard/clipboardservice.py +++ b/sugar/clipboard/clipboardservice.py @@ -64,40 +64,37 @@ class ClipboardService(gobject.GObject): self._connect_clipboard_signals() def _object_added_cb(self, object_id, name): - self.emit('object-added', object_id, name) + self.emit('object-added', str(object_id), name) def _object_deleted_cb(self, object_id): - self.emit('object-deleted', object_id) + self.emit('object-deleted', str(object_id)) def _object_state_changed_cb(self, object_id, values): - self.emit('object-state-changed', object_id, values[NAME_KEY], + self.emit('object-state-changed', str(object_id), values[NAME_KEY], values[PERCENT_KEY], values[ICON_KEY], values[PREVIEW_KEY], values[ACTIVITY_KEY]) - def add_object(self, object_id, name): - self._dbus_service.add_object(object_id, name) + def add_object(self, name): + return str(self._dbus_service.add_object(name)) def add_object_format(self, object_id, formatType, data, on_disk): - self._dbus_service.add_object_format(object_id, + self._dbus_service.add_object_format(dbus.ObjectPath(object_id), formatType, data, on_disk) def delete_object(self, object_id): - self._dbus_service.delete_object(object_id) + self._dbus_service.delete_object(dbus.ObjectPath(object_id)) def set_object_percent(self, object_id, percent): - self._dbus_service.set_object_percent(object_id, percent) + self._dbus_service.set_object_percent(dbus.ObjectPath(object_id), percent) def get_object(self, object_id): - result_dict = self._dbus_service.get_object(object_id,) - - return (result_dict[NAME_KEY], result_dict[PERCENT_KEY], - result_dict[ICON_KEY], result_dict[PREVIEW_KEY], - result_dict[ACTIVITY_KEY], result_dict[FORMATS_KEY]) + return self._dbus_service.get_object(dbus.ObjectPath(object_id),) def get_object_data(self, object_id, formatType): - return self._dbus_service.get_object_data(object_id, formatType, + return self._dbus_service.get_object_data(dbus.ObjectPath(object_id), + formatType, byte_arrays=True) _clipboard_service = None -- cgit v0.9.1