Fixed some issues with text objects in the clipboard.

master
Tomeu Vizoso 17 years ago
parent eb7ad2066c
commit 547df751a7

@ -1,3 +1,5 @@
* Fixed some issues with text objects in the clipboard. (tomeu)
Snapshot a1f5cece18
* Fix traceback on mesh disconnect command (dcbw)

@ -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(),

@ -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

@ -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'

Loading…
Cancel
Save