From 547df751a762065292156bc321d335fb4158b48d Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 9 Sep 2007 15:04:26 +0200 Subject: [PATCH] Fixed some issues with text objects in the clipboard. --- NEWS | 2 ++ services/shell/clipboardservice.py | 18 ++++++++++++++++-- sugar/datastore/datastore.py | 3 ++- sugar/objects/mime.py | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 2ef1e943..bdb0bc8e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +* Fixed some issues with text objects in the clipboard. (tomeu) + Snapshot a1f5cece18 * Fix traceback on mesh disconnect command (dcbw) diff --git a/services/shell/clipboardservice.py b/services/shell/clipboardservice.py index 90e1b8ee..6671fbfb 100644 --- a/services/shell/clipboardservice.py +++ b/services/shell/clipboardservice.py @@ -80,7 +80,7 @@ class ClipboardService(dbus.service.Object): cb_object.add_format(Format(format_type, new_uri, on_disk)) logging.debug('Added format of type ' + format_type + ' with path at ' + new_uri) else: - cb_object.add_format(Format(format_type, data, on_disk)) + cb_object.add_format(Format(format_type, data, on_disk)) logging.debug('Added in-memory format of type ' + format_type + '.') self.object_state_changed(object_path, {NAME_KEY: cb_object.get_name(), @@ -112,11 +112,25 @@ class ClipboardService(dbus.service.Object): cb_object.set_percent(percent) if percent == 100: - for format_name, format in cb_object.get_formats().iteritems(): + formats = cb_object.get_formats() + for format_name, format in formats.iteritems(): if format.is_on_disk(): new_uri = self._copy_file(format.get_data()) format.set_data(new_uri) + # Add a text/plain format to objects that are text but lack it + if 'text/plain' not in formats.keys(): + if 'UTF8_STRING' in formats.keys(): + self.add_object_format(object_path, + 'text/plain', + data=formats['UTF8_STRING'].get_data(), + on_disk=False) + elif 'text/unicode' in formats.keys(): + self.add_object_format(object_path, + 'text/plain', + data=formats['UTF8_STRING'].get_data(), + on_disk=False) + self.object_state_changed(object_path, {NAME_KEY: cb_object.get_name(), PERCENT_KEY: percent, ICON_KEY: cb_object.get_icon(), diff --git a/sugar/datastore/datastore.py b/sugar/datastore/datastore.py index d4340feb..9b4bcc9a 100644 --- a/sugar/datastore/datastore.py +++ b/sugar/datastore/datastore.py @@ -138,7 +138,8 @@ class DSObject(object): activityfactory.create(bundle.get_service_name()) else: - if not self.get_activities(): + if not self.get_activities() and service_name is None: + logging.warning('No activity can open this object.') return if service_name is None: service_name = self.get_activities()[0].service_name diff --git a/sugar/objects/mime.py b/sugar/objects/mime.py index b9331434..baa014fe 100644 --- a/sugar/objects/mime.py +++ b/sugar/objects/mime.py @@ -81,7 +81,7 @@ def choose_most_significant(mime_types): logging.debug('Choosed text/html!') return 'text/html' - if 'text/plain' in mime_types or 'STRING' in mime_types: + if 'text/plain' in mime_types: logging.debug('Choosed text/plain!') return 'text/plain'