Some more usability fixes for the clipboard.
This commit is contained in:
@@ -26,6 +26,9 @@ class ClipboardObject:
|
||||
|
||||
def get_preview(self):
|
||||
return self._get_type_info().get_preview()
|
||||
|
||||
def get_activity(self):
|
||||
return self._get_type_info().get_activity()
|
||||
|
||||
def get_percent(self):
|
||||
return self._percent
|
||||
|
||||
@@ -26,6 +26,7 @@ NAME_KEY = 'NAME'
|
||||
PERCENT_KEY = 'PERCENT'
|
||||
ICON_KEY = 'ICON'
|
||||
PREVIEW_KEY = 'PREVIEW'
|
||||
ACTIVITY_KEY = 'ACTIVITY'
|
||||
FORMATS_KEY = 'FORMATS'
|
||||
|
||||
class ClipboardDBusServiceHelper(dbus.service.Object):
|
||||
@@ -63,7 +64,8 @@ class ClipboardDBusServiceHelper(dbus.service.Object):
|
||||
self.object_state_changed(object_id, {NAME_KEY: cb_object.get_name(),
|
||||
PERCENT_KEY: cb_object.get_percent(),
|
||||
ICON_KEY: cb_object.get_icon(),
|
||||
PREVIEW_KEY: cb_object.get_preview()})
|
||||
PREVIEW_KEY: cb_object.get_preview(),
|
||||
ACTIVITY_KEY: cb_object.get_activity()})
|
||||
|
||||
@dbus.service.method(_CLIPBOARD_DBUS_INTERFACE,
|
||||
in_signature="s", out_signature="")
|
||||
@@ -80,7 +82,8 @@ class ClipboardDBusServiceHelper(dbus.service.Object):
|
||||
self.object_state_changed(object_id, {NAME_KEY: cb_object.get_name(),
|
||||
PERCENT_KEY: percent,
|
||||
ICON_KEY: cb_object.get_icon(),
|
||||
PREVIEW_KEY: cb_object.get_preview()})
|
||||
PREVIEW_KEY: cb_object.get_preview(),
|
||||
ACTIVITY_KEY: cb_object.get_activity()})
|
||||
|
||||
logging.debug('Changed object with object_id ' + object_id +
|
||||
' with percent ' + str(percent))
|
||||
@@ -99,6 +102,7 @@ class ClipboardDBusServiceHelper(dbus.service.Object):
|
||||
PERCENT_KEY: cb_object.get_percent(),
|
||||
ICON_KEY: cb_object.get_icon(),
|
||||
PREVIEW_KEY: cb_object.get_preview(),
|
||||
ACTIVITY_KEY: cb_object.get_activity(),
|
||||
FORMATS_KEY: format_types}
|
||||
return result_dict
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ class FileType:
|
||||
|
||||
def get_preview(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_activity(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def matches_mime_type(cls, mime_type):
|
||||
raise NotImplementedError
|
||||
@@ -38,6 +41,9 @@ class TextFileType(FileType):
|
||||
return text[0:49] + "..."
|
||||
|
||||
return ''
|
||||
|
||||
def get_activity(self):
|
||||
return ''
|
||||
|
||||
def matches_mime_type(cls, mime_type):
|
||||
return mime_type in cls._types
|
||||
@@ -55,6 +61,9 @@ class ImageFileType(FileType):
|
||||
|
||||
def get_preview(self):
|
||||
return ''
|
||||
|
||||
def get_activity(self):
|
||||
return ''
|
||||
|
||||
def matches_mime_type(cls, mime_type):
|
||||
return mime_type in cls._types
|
||||
@@ -78,7 +87,10 @@ class UriFileType(FileType):
|
||||
return title
|
||||
|
||||
return ''
|
||||
|
||||
|
||||
def get_activity(self):
|
||||
return ''
|
||||
|
||||
def matches_mime_type(cls, mime_type):
|
||||
return mime_type in cls._types
|
||||
matches_mime_type = classmethod(matches_mime_type)
|
||||
@@ -95,6 +107,9 @@ class PdfFileType(FileType):
|
||||
|
||||
def get_preview(self):
|
||||
return ''
|
||||
|
||||
def get_activity(self):
|
||||
return 'org.laptop.sugar.Xbook'
|
||||
|
||||
def matches_mime_type(cls, mime_type):
|
||||
return mime_type in cls._types
|
||||
@@ -112,6 +127,9 @@ class MsWordFileType(FileType):
|
||||
|
||||
def get_preview(self):
|
||||
return ''
|
||||
|
||||
def get_activity(self):
|
||||
return 'org.laptop.AbiWordActivity'
|
||||
|
||||
def matches_mime_type(cls, mime_type):
|
||||
return mime_type in cls._types
|
||||
@@ -129,6 +147,29 @@ class RtfFileType(FileType):
|
||||
|
||||
def get_preview(self):
|
||||
return ''
|
||||
|
||||
def get_activity(self):
|
||||
return 'org.laptop.AbiWordActivity'
|
||||
|
||||
def matches_mime_type(cls, mime_type):
|
||||
return mime_type in cls._types
|
||||
matches_mime_type = classmethod(matches_mime_type)
|
||||
|
||||
class OOTextFileType(FileType):
|
||||
|
||||
_types = set(['application/vnd.oasis.opendocument.text'])
|
||||
|
||||
def get_name(self):
|
||||
return _('OpenOffice text file')
|
||||
|
||||
def get_icon(self):
|
||||
return 'activity-abiword'
|
||||
|
||||
def get_preview(self):
|
||||
return ''
|
||||
|
||||
def get_activity(self):
|
||||
return 'org.laptop.AbiWordActivity'
|
||||
|
||||
def matches_mime_type(cls, mime_type):
|
||||
return mime_type in cls._types
|
||||
@@ -143,6 +184,9 @@ class UnknownFileType(FileType):
|
||||
|
||||
def get_preview(self):
|
||||
return ''
|
||||
|
||||
def get_activity(self):
|
||||
return ''
|
||||
|
||||
def matches_mime_type(cls, mime_type):
|
||||
return true
|
||||
@@ -154,6 +198,7 @@ class TypeRegistry:
|
||||
self._types.append(PdfFileType)
|
||||
self._types.append(MsWordFileType)
|
||||
self._types.append(RtfFileType)
|
||||
self._types.append(OOTextFileType)
|
||||
self._types.append(UriFileType)
|
||||
self._types.append(ImageFileType)
|
||||
self._types.append(TextFileType)
|
||||
|
||||
Reference in New Issue
Block a user