Added icon, title and preview for clipboard objects. Also allow for opening docs and rtfs from the web.
This commit is contained in:
@@ -2,7 +2,11 @@ import logging
|
||||
import dbus
|
||||
import gobject
|
||||
|
||||
from sugar import util
|
||||
NAME_KEY = 'NAME'
|
||||
PERCENT_KEY = 'PERCENT'
|
||||
ICON_KEY = 'ICON'
|
||||
PREVIEW_KEY = 'PREVIEW'
|
||||
FORMATS_KEY = 'FORMATS'
|
||||
|
||||
DBUS_SERVICE = "org.laptop.Clipboard"
|
||||
DBUS_INTERFACE = "org.laptop.Clipboard"
|
||||
@@ -16,7 +20,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, int])),
|
||||
([str, str, int, str, str])),
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
@@ -58,8 +62,9 @@ class ClipboardService(gobject.GObject):
|
||||
def _object_deleted_cb(self, object_id):
|
||||
self.emit('object-deleted', object_id)
|
||||
|
||||
def _object_state_changed_cb(self, object_id, percent):
|
||||
self.emit('object-state-changed', object_id, percent)
|
||||
def _object_state_changed_cb(self, object_id, values):
|
||||
self.emit('object-state-changed', object_id, values[NAME_KEY],
|
||||
values[PERCENT_KEY], values[ICON_KEY], values[PREVIEW_KEY])
|
||||
|
||||
def add_object(self, object_id, name):
|
||||
self._dbus_service.add_object(object_id, name)
|
||||
@@ -67,27 +72,25 @@ class ClipboardService(gobject.GObject):
|
||||
def add_object_format(self, object_id, formatType, data, on_disk):
|
||||
self._dbus_service.add_object_format(object_id,
|
||||
formatType,
|
||||
dbus.types.ByteArray(data),
|
||||
data,
|
||||
on_disk)
|
||||
|
||||
def delete_object(self, object_id):
|
||||
self._dbus_service.delete_object(object_id)
|
||||
|
||||
def set_object_state(self, object_id, percent):
|
||||
self._dbus_service.set_object_state(object_id, percent)
|
||||
def set_object_percent(self, object_id, percent):
|
||||
self._dbus_service.set_object_percent(object_id, percent)
|
||||
|
||||
def get_object_format_types(self, object_id):
|
||||
return self._dbus_service.get_object_format_types(object_id)
|
||||
|
||||
def get_object_data(self, object_id, formatType):
|
||||
data = self._dbus_service.get_object_data(object_id, formatType)
|
||||
def get_object(self, object_id):
|
||||
result_dict = self._dbus_service.get_object(object_id,)
|
||||
|
||||
# FIXME: Take it out when using the 0.80 dbus bindings
|
||||
s = ""
|
||||
for i in data:
|
||||
s += chr(i)
|
||||
|
||||
return s
|
||||
return (result_dict[NAME_KEY], result_dict[PERCENT_KEY],
|
||||
result_dict[ICON_KEY], result_dict[PREVIEW_KEY],
|
||||
result_dict[FORMATS_KEY])
|
||||
|
||||
def get_object_data(self, object_id, formatType):
|
||||
return self._dbus_service.get_object_data(object_id, formatType,
|
||||
byte_arrays=True)
|
||||
|
||||
_clipboard_service = None
|
||||
def get_instance():
|
||||
|
||||
Reference in New Issue
Block a user