#5097: Fix pasting text between activities through the clipboard.
This commit is contained in:
parent
1cecee8da3
commit
972fecd920
1
NEWS
1
NEWS
@ -1,3 +1,4 @@
|
|||||||
|
* #5097: Fix pasting text between activities through the clipboard. (tomeu)
|
||||||
* #4660: Use improved PS API which streamlines ShareActivity process (smcv)
|
* #4660: Use improved PS API which streamlines ShareActivity process (smcv)
|
||||||
|
|
||||||
0.70.1
|
0.70.1
|
||||||
|
@ -44,6 +44,8 @@ class ClipboardIcon(RadioToolButton):
|
|||||||
self._preview = None
|
self._preview = None
|
||||||
self._activity = None
|
self._activity = None
|
||||||
self.owns_clipboard = False
|
self.owns_clipboard = False
|
||||||
|
self.props.sensitive = False
|
||||||
|
self.props.active = False
|
||||||
|
|
||||||
self._icon = Icon()
|
self._icon = Icon()
|
||||||
self._icon.props.xo_color = profile.get_color()
|
self._icon.props.xo_color = profile.get_color()
|
||||||
@ -80,6 +82,10 @@ class ClipboardIcon(RadioToolButton):
|
|||||||
|
|
||||||
def _put_in_clipboard(self):
|
def _put_in_clipboard(self):
|
||||||
logging.debug('ClipboardIcon._put_in_clipboard')
|
logging.debug('ClipboardIcon._put_in_clipboard')
|
||||||
|
|
||||||
|
if self._percent < 100:
|
||||||
|
raise ValueError('Object is not complete, cannot be put into the clipboard.')
|
||||||
|
|
||||||
targets = self._get_targets()
|
targets = self._get_targets()
|
||||||
if targets:
|
if targets:
|
||||||
clipboard = gtk.Clipboard()
|
clipboard = gtk.Clipboard()
|
||||||
@ -125,14 +131,19 @@ class ClipboardIcon(RadioToolButton):
|
|||||||
self.child.drag_source_set_icon_name(self._icon.props.icon_name)
|
self.child.drag_source_set_icon_name(self._icon.props.icon_name)
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self._percent = percent
|
|
||||||
self._preview = preview
|
self._preview = preview
|
||||||
self._activity = activity
|
self._activity = activity
|
||||||
self.palette.set_state(name, percent, preview, activity,
|
self.palette.set_state(name, percent, preview, activity,
|
||||||
self._is_bundle(obj['FORMATS']))
|
self._is_bundle(obj['FORMATS']))
|
||||||
|
|
||||||
if self.props.active:
|
old_percent = self._percent
|
||||||
self._put_in_clipboard()
|
self._percent = percent
|
||||||
|
if self._percent == 100:
|
||||||
|
self.props.sensitive = True
|
||||||
|
|
||||||
|
# Clipboard object became complete. Make it the active one.
|
||||||
|
if old_percent < 100 and self._percent == 100:
|
||||||
|
self.props.active = True
|
||||||
|
|
||||||
def _notify_active_cb(self, widget, pspec):
|
def _notify_active_cb(self, widget, pspec):
|
||||||
if self.props.active:
|
if self.props.active:
|
||||||
|
@ -62,7 +62,6 @@ class ClipboardBox(hippo.CanvasBox):
|
|||||||
hippo.CanvasBox.__init__(self)
|
hippo.CanvasBox.__init__(self)
|
||||||
self._icons = {}
|
self._icons = {}
|
||||||
self._context_map = _ContextMap()
|
self._context_map = _ContextMap()
|
||||||
self._selected_icon = None
|
|
||||||
|
|
||||||
self._tray = VTray()
|
self._tray = VTray()
|
||||||
self.append(hippo.CanvasWidget(widget=self._tray), hippo.PACK_EXPAND)
|
self.append(hippo.CanvasWidget(widget=self._tray), hippo.PACK_EXPAND)
|
||||||
@ -109,17 +108,10 @@ class ClipboardBox(hippo.CanvasBox):
|
|||||||
icon = ClipboardIcon(object_id, name, group)
|
icon = ClipboardIcon(object_id, name, group)
|
||||||
self._tray.add_item(icon, 0)
|
self._tray.add_item(icon, 0)
|
||||||
icon.show()
|
icon.show()
|
||||||
|
|
||||||
self._set_icon_selected(icon)
|
|
||||||
self._icons[object_id] = icon
|
self._icons[object_id] = icon
|
||||||
|
|
||||||
logging.debug('ClipboardBox: ' + object_id + ' was added.')
|
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):
|
def _object_deleted_cb(self, cb_service, object_id):
|
||||||
icon = self._icons[object_id]
|
icon = self._icons[object_id]
|
||||||
self._tray.remove_item(icon)
|
self._tray.remove_item(icon)
|
||||||
|
@ -59,14 +59,20 @@ class ClipboardPanelWindow(FrameWindow):
|
|||||||
targets = clipboard.wait_for_targets()
|
targets = clipboard.wait_for_targets()
|
||||||
for target in targets:
|
for target in targets:
|
||||||
if target not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE', 'SAVE_TARGETS'):
|
if target not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE', 'SAVE_TARGETS'):
|
||||||
|
logging.debug('Asking for target %s.' % target)
|
||||||
selection = clipboard.wait_for_contents(target)
|
selection = clipboard.wait_for_contents(target)
|
||||||
if selection:
|
if not selection:
|
||||||
|
logging.warning('no data for selection target %s.' % target)
|
||||||
|
continue
|
||||||
self._add_selection(key, selection)
|
self._add_selection(key, selection)
|
||||||
|
|
||||||
cb_service.set_object_percent(key, percent=100)
|
cb_service.set_object_percent(key, percent=100)
|
||||||
|
|
||||||
def _add_selection(self, key, selection):
|
def _add_selection(self, key, selection):
|
||||||
if selection.data:
|
if not selection.data:
|
||||||
|
logging.warning('no data for selection target %s.' % selection.type)
|
||||||
|
return
|
||||||
|
|
||||||
logging.debug('adding type ' + selection.type + '.')
|
logging.debug('adding type ' + selection.type + '.')
|
||||||
|
|
||||||
cb_service = clipboardservice.get_instance()
|
cb_service = clipboardservice.get_instance()
|
||||||
|
Loading…
Reference in New Issue
Block a user