From ecb8816bc9b59fc633302c47eb4d7f98b802b610 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 17 Sep 2007 00:39:02 +0000 Subject: Add XdndDirectSave support to the clipboard. I think it could be a little cleaner, but it would require refactoring, we can do that post Trial-3. Also we might have to figure out a way to get file saving progress feedback at some point. --- (limited to 'services') diff --git a/services/shell/clipboardobject.py b/services/shell/clipboardobject.py index c3cdab3..ea5a9a1 100644 --- a/services/shell/clipboardobject.py +++ b/services/shell/clipboardobject.py @@ -95,17 +95,21 @@ class ClipboardObject: format = mime.choose_most_significant(self._formats.keys()) - if format == 'text/uri-list': + uri = None + if format == 'XdndDirectSave0': + uri = self._formats['XdndDirectSave0'].get_data() + elif format == 'text/uri-list': data = self._formats['text/uri-list'].get_data() - uris = data.split('\n') - if len(uris) == 1 or not uris[1]: - uri = urlparse.urlparse(uris[0], 'file') - if uri.scheme == 'file': - if os.path.exists(uri.path): - format = mime.get_for_file(uri.path) - else: - format = mime.get_from_file_name(uri.path) - logging.debug('Choosed %r!' % format) + uri = data.split('\n')[0] + + if uri: + uri = urlparse.urlparse(uri, 'file') + if uri.scheme == 'file': + if os.path.exists(uri.path): + format = mime.get_for_file(uri.path) + else: + format = mime.get_from_file_name(uri.path) + logging.debug('Choosed %r!' % format) return format diff --git a/services/shell/clipboardservice.py b/services/shell/clipboardservice.py index 6671fbf..f0b2baa 100644 --- a/services/shell/clipboardservice.py +++ b/services/shell/clipboardservice.py @@ -75,7 +75,9 @@ class ClipboardService(dbus.service.Object): logging.debug('ClipboardService.add_object_format') cb_object = self._objects[str(object_path)] - if on_disk and cb_object.get_percent() == 100: + if format_type == 'XdndDirectSave0': + cb_object.add_format(Format(format_type, data, on_disk)) + 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)) logging.debug('Added format of type ' + format_type + ' with path at ' + new_uri) @@ -114,7 +116,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(): + if format.is_on_disk() and format_name != 'XdndDirectSave0': new_uri = self._copy_file(format.get_data()) format.set_data(new_uri) -- cgit v0.9.1