Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-09-09 13:04:26 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-09-09 13:04:26 (GMT)
commit547df751a762065292156bc321d335fb4158b48d (patch)
tree5423f2128d5506afc1e89adccd9ceae738760b20
parenteb7ad2066c61afc4ac62a6635d375a0c2f0c421e (diff)
Fixed some issues with text objects in the clipboard.
-rw-r--r--NEWS2
-rw-r--r--services/shell/clipboardservice.py18
-rw-r--r--sugar/datastore/datastore.py3
-rw-r--r--sugar/objects/mime.py2
4 files changed, 21 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 2ef1e94..bdb0bc8 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 90e1b8e..6671fbf 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 d4340fe..9b4bcc9 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 b933143..baa014f 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'