Make DirectSave just a special text/uri-list which owns
the disk data.
This commit is contained in:
parent
a449430500
commit
55baffea32
@ -94,16 +94,9 @@ class ClipboardObject:
|
||||
return ''
|
||||
|
||||
format = mime.choose_most_significant(self._formats.keys())
|
||||
|
||||
uri = None
|
||||
if format == 'XdndDirectSave0':
|
||||
uri = self._formats['XdndDirectSave0'].get_data()
|
||||
elif format == 'text/uri-list':
|
||||
if format == 'text/uri-list':
|
||||
data = self._formats['text/uri-list'].get_data()
|
||||
uri = data.split('\n')[0]
|
||||
|
||||
if uri:
|
||||
uri = urlparse.urlparse(uri, 'file')
|
||||
uri = urlparse.urlparse(data.split('\n')[0], 'file')
|
||||
if uri.scheme == 'file':
|
||||
if os.path.exists(uri.path):
|
||||
format = mime.get_for_file(uri.path)
|
||||
@ -116,6 +109,8 @@ class ClipboardObject:
|
||||
class Format:
|
||||
|
||||
def __init__(self, type, data, on_disk):
|
||||
self.owns_disk_data = False
|
||||
|
||||
self._type = type
|
||||
self._data = data
|
||||
self._on_disk = on_disk
|
||||
|
@ -76,7 +76,9 @@ class ClipboardService(dbus.service.Object):
|
||||
cb_object = self._objects[str(object_path)]
|
||||
|
||||
if format_type == 'XdndDirectSave0':
|
||||
cb_object.add_format(Format(format_type, data, on_disk))
|
||||
format = Format('text/uri-list', data, on_disk)
|
||||
format.owns_disk_data = True
|
||||
cb_object.add_format(format)
|
||||
elif on_disk and cb_object.get_percent() == 100:
|
||||
new_uri = self._copy_file(data)
|
||||
cb_object.add_format(Format(format_type, new_uri, on_disk))
|
||||
@ -116,7 +118,7 @@ class ClipboardService(dbus.service.Object):
|
||||
if percent == 100:
|
||||
formats = cb_object.get_formats()
|
||||
for format_name, format in formats.iteritems():
|
||||
if format.is_on_disk() and format_name != 'XdndDirectSave0':
|
||||
if format.is_on_disk() and not format.owns_disk_data:
|
||||
new_uri = self._copy_file(format.get_data())
|
||||
format.set_data(new_uri)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user