From 55baffea32b3754ca120a75ce1b1ebd76ba613f8 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 26 Sep 2007 10:09:26 +0200 Subject: [PATCH] Make DirectSave just a special text/uri-list which owns the disk data. --- services/shell/clipboardobject.py | 13 ++++--------- services/shell/clipboardservice.py | 6 ++++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/services/shell/clipboardobject.py b/services/shell/clipboardobject.py index ea5a9a11..86b719c2 100644 --- a/services/shell/clipboardobject.py +++ b/services/shell/clipboardobject.py @@ -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 diff --git a/services/shell/clipboardservice.py b/services/shell/clipboardservice.py index f0b2baa2..c8973edc 100644 --- a/services/shell/clipboardservice.py +++ b/services/shell/clipboardservice.py @@ -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)