Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import os
|
||||
import logging
|
||||
|
||||
import typeregistry
|
||||
|
||||
class ClipboardObject:
|
||||
@@ -8,6 +11,10 @@ class ClipboardObject:
|
||||
self._percent = 0
|
||||
self._formats = {}
|
||||
|
||||
def destroy(self):
|
||||
for type, format in self._formats.iteritems():
|
||||
format.destroy()
|
||||
|
||||
def get_id(self):
|
||||
return self._id
|
||||
|
||||
@@ -49,6 +56,10 @@ class Format:
|
||||
self._data = data
|
||||
self._on_disk = on_disk
|
||||
|
||||
def destroy(self):
|
||||
if self._on_disk:
|
||||
os.remove(self._data.replace('file://', ''))
|
||||
|
||||
def get_type(self):
|
||||
return self._type
|
||||
|
||||
|
||||
@@ -109,7 +109,8 @@ class ClipboardDBusServiceHelper(dbus.service.Object):
|
||||
@dbus.service.method(_CLIPBOARD_DBUS_INTERFACE,
|
||||
in_signature="o", out_signature="")
|
||||
def delete_object(self, object_path):
|
||||
del self._objects[str(object_path)]
|
||||
cb_object = self._objects.pop(str(object_path))
|
||||
cb_object.destroy()
|
||||
self.object_deleted(object_path)
|
||||
logging.debug('Deleted object with object_id ' + object_path)
|
||||
|
||||
|
||||
@@ -197,6 +197,26 @@ class OOTextFileType(FileType):
|
||||
return mime_type in cls._types
|
||||
matches_mime_type = classmethod(matches_mime_type)
|
||||
|
||||
class UriListFileType(FileType):
|
||||
|
||||
_types = set(['text/uri-list'])
|
||||
|
||||
def get_name(self):
|
||||
return _('text/uri-list')
|
||||
|
||||
def get_icon(self):
|
||||
return 'theme:stock-missing'
|
||||
|
||||
def get_preview(self):
|
||||
return 'preview'
|
||||
|
||||
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)
|
||||
|
||||
class UnknownFileType(FileType):
|
||||
def get_name(self):
|
||||
return _('Object')
|
||||
@@ -221,6 +241,7 @@ class TypeRegistry:
|
||||
self._types.append(MsWordFileType)
|
||||
self._types.append(RtfFileType)
|
||||
self._types.append(OOTextFileType)
|
||||
self._types.append(UriListFileType)
|
||||
self._types.append(UriFileType)
|
||||
self._types.append(ImageFileType)
|
||||
self._types.append(AbiwordFileType)
|
||||
|
||||
Reference in New Issue
Block a user