#5097: Fix pasting text between activities through the clipboard.

This commit is contained in:
Tomeu Vizoso
2007-11-23 18:38:55 +01:00
parent 1cecee8da3
commit 972fecd920
4 changed files with 41 additions and 31 deletions
-8
View File
@@ -62,7 +62,6 @@ class ClipboardBox(hippo.CanvasBox):
hippo.CanvasBox.__init__(self)
self._icons = {}
self._context_map = _ContextMap()
self._selected_icon = None
self._tray = VTray()
self.append(hippo.CanvasWidget(widget=self._tray), hippo.PACK_EXPAND)
@@ -109,17 +108,10 @@ class ClipboardBox(hippo.CanvasBox):
icon = ClipboardIcon(object_id, name, group)
self._tray.add_item(icon, 0)
icon.show()
self._set_icon_selected(icon)
self._icons[object_id] = icon
logging.debug('ClipboardBox: ' + object_id + ' was added.')
def _set_icon_selected(self, icon):
logging.debug('_set_icon_selected')
icon.props.active = True
self._selected_icon = icon
def _object_deleted_cb(self, cb_service, object_id):
icon = self._icons[object_id]
self._tray.remove_item(icon)
+25 -19
View File
@@ -59,29 +59,35 @@ class ClipboardPanelWindow(FrameWindow):
targets = clipboard.wait_for_targets()
for target in targets:
if target not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE', 'SAVE_TARGETS'):
logging.debug('Asking for target %s.' % target)
selection = clipboard.wait_for_contents(target)
if selection:
self._add_selection(key, selection)
if not selection:
logging.warning('no data for selection target %s.' % target)
continue
self._add_selection(key, selection)
cb_service.set_object_percent(key, percent=100)
def _add_selection(self, key, selection):
if selection.data:
logging.debug('adding type ' + selection.type + '.')
cb_service = clipboardservice.get_instance()
if selection.type == 'text/uri-list':
uris = selection.data.split('\n')
if len(uris) > 1:
raise NotImplementedError('Multiple uris in text/uri-list still not supported.')
if not selection.data:
logging.warning('no data for selection target %s.' % selection.type)
return
logging.debug('adding type ' + selection.type + '.')
cb_service = clipboardservice.get_instance()
if selection.type == 'text/uri-list':
uris = selection.data.split('\n')
if len(uris) > 1:
raise NotImplementedError('Multiple uris in text/uri-list still not supported.')
cb_service.add_object_format(key,
selection.type,
uris[0],
on_disk=True)
else:
cb_service.add_object_format(key,
selection.type,
selection.data,
on_disk=False)
cb_service.add_object_format(key,
selection.type,
uris[0],
on_disk=True)
else:
cb_service.add_object_format(key,
selection.type,
selection.data,
on_disk=False)