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-04-17 19:53:34 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-04-17 19:53:34 (GMT)
commitb7030a74dd5208afc75be42c81201cfa72ebbcc9 (patch)
tree9f047f76e653130d2cadf98a9bf6434a1eee57b3 /shell
parent92416d1519c67012e02af17a672edead91f68011 (diff)
Drag images out of mozilla.
Diffstat (limited to 'shell')
-rw-r--r--shell/view/frame/clipboardbox.py46
1 files changed, 31 insertions, 15 deletions
diff --git a/shell/view/frame/clipboardbox.py b/shell/view/frame/clipboardbox.py
index 2dcad10..c057a42 100644
--- a/shell/view/frame/clipboardbox.py
+++ b/shell/view/frame/clipboardbox.py
@@ -1,4 +1,7 @@
+import shutil
+import os
import logging
+
import hippo
import gtk
@@ -72,13 +75,25 @@ class ClipboardBox(hippo.CanvasBox):
if not selection.data:
return
- logging.debug('ClipboardBox: adding type ' + selection.type + '.')
-
+ logging.debug('ClipboardBox: adding type ' + selection.type + ' ' + selection.data)
+
cb_service = clipboardservice.get_instance()
- cb_service.add_object_format(object_id,
- selection.type,
- selection.data,
- on_disk = False)
+ if selection.type == 'text/uri-list':
+ # Copy the file, as it will be deleted when the dnd operation finishes.
+ file_path = selection.data.replace('file://', '')
+ new_file_path = os.path.join(os.path.split(file_path)[0],
+ "cb" + os.path.split(file_path)[1])
+ shutil.copyfile(file_path, new_file_path)
+
+ cb_service.add_object_format(object_id,
+ selection.type,
+ 'file://' + new_file_path,
+ on_disk=True)
+ else:
+ cb_service.add_object_format(object_id,
+ selection.type,
+ selection.data,
+ on_disk=False)
def _object_added_cb(self, cb_service, object_id, name):
icon = ClipboardIcon(self._popup_context, object_id, name)
@@ -165,15 +180,16 @@ class ClipboardBox(hippo.CanvasBox):
def drag_data_received_cb(self, widget, context, x, y, selection, targetType, time):
logging.debug('ClipboardBox: got data for target ' + selection.target)
- if selection:
- object_id = self._context_map.get_object_id(context)
- self._add_selection(object_id, selection)
- else:
- logging.warn('ClipboardBox: empty selection for target ' + selection.target)
-
- # If it's the last target to be processed, finish the dnd transaction
- if not self._context_map.has_context(context):
- context.finish(True, False, time)
+ try:
+ if selection:
+ object_id = self._context_map.get_object_id(context)
+ self._add_selection(object_id, selection)
+ else:
+ logging.warn('ClipboardBox: empty selection for target ' + selection.target)
+ finally:
+ # If it's the last target to be processed, finish the dnd transaction
+ if not self._context_map.has_context(context):
+ context.drop_finish(True, gtk.get_current_event_time())
def drag_data_get_cb(self, widget, context, selection, targetType, eventTime):
logging.debug("drag_data_get_cb: requested target " + selection.target)