Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-11-23 17:38:55 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-11-23 17:38:55 (GMT)
commit972fecd920e4a13c96365b41c777a0ef6a1d6947 (patch)
tree71b972d9c44ab5dbb3981e702f1f062d5cbf8453 /shell
parent1cecee8da36deb610acd0315036c20547d62a942 (diff)
#5097: Fix pasting text between activities through the clipboard.
Diffstat (limited to 'shell')
-rw-r--r--shell/view/clipboardicon.py19
-rw-r--r--shell/view/frame/clipboardbox.py8
-rw-r--r--shell/view/frame/clipboardpanelwindow.py44
3 files changed, 40 insertions, 31 deletions
diff --git a/shell/view/clipboardicon.py b/shell/view/clipboardicon.py
index 56ae669..4b36395 100644
--- a/shell/view/clipboardicon.py
+++ b/shell/view/clipboardicon.py
@@ -44,12 +44,14 @@ class ClipboardIcon(RadioToolButton):
self._preview = None
self._activity = None
self.owns_clipboard = False
+ self.props.sensitive = False
+ self.props.active = False
self._icon = Icon()
self._icon.props.xo_color = profile.get_color()
self.set_icon_widget(self._icon)
self._icon.show()
-
+
cb_service = clipboardservice.get_instance()
cb_service.connect('object-state-changed', self._object_state_changed_cb)
obj = cb_service.get_object(self._object_id)
@@ -80,6 +82,10 @@ class ClipboardIcon(RadioToolButton):
def _put_in_clipboard(self):
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()
if targets:
clipboard = gtk.Clipboard()
@@ -125,14 +131,19 @@ class ClipboardIcon(RadioToolButton):
self.child.drag_source_set_icon_name(self._icon.props.icon_name)
self._name = name
- self._percent = percent
self._preview = preview
self._activity = activity
self.palette.set_state(name, percent, preview, activity,
self._is_bundle(obj['FORMATS']))
- if self.props.active:
- self._put_in_clipboard()
+ old_percent = self._percent
+ 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):
if self.props.active:
diff --git a/shell/view/frame/clipboardbox.py b/shell/view/frame/clipboardbox.py
index 1195c02..cf2f9f5 100644
--- a/shell/view/frame/clipboardbox.py
+++ b/shell/view/frame/clipboardbox.py
@@ -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)
diff --git a/shell/view/frame/clipboardpanelwindow.py b/shell/view/frame/clipboardpanelwindow.py
index 6a01844..b492e78 100644
--- a/shell/view/frame/clipboardpanelwindow.py
+++ b/shell/view/frame/clipboardpanelwindow.py
@@ -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)