Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-09-17 00:39:02 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-09-17 00:39:02 (GMT)
commitecb8816bc9b59fc633302c47eb4d7f98b802b610 (patch)
tree76739526e0d5d0356a9134a827275b621e310ee1 /shell
parent6ec3246a1e6c7225131d8497d2eb53014753dd73 (diff)
Add XdndDirectSave support to the clipboard.
I think it could be a little cleaner, but it would require refactoring, we can do that post Trial-3. Also we might have to figure out a way to get file saving progress feedback at some point.
Diffstat (limited to 'shell')
-rw-r--r--shell/view/frame/clipboardbox.py46
1 files changed, 39 insertions, 7 deletions
diff --git a/shell/view/frame/clipboardbox.py b/shell/view/frame/clipboardbox.py
index 9c6d859..1195c02 100644
--- a/shell/view/frame/clipboardbox.py
+++ b/shell/view/frame/clipboardbox.py
@@ -16,6 +16,7 @@
import os
import logging
+import tempfile
import hippo
import gtk
@@ -137,9 +138,28 @@ class ClipboardBox(hippo.CanvasBox):
self._context_map.add_context(context, object_id, len(context.targets))
- for target in context.targets:
- if str(target) not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE'):
- widget.drag_get_data(context, target, time)
+ if 'XdndDirectSave0' in context.targets:
+ window = context.source_window
+ prop_type, format, filename = \
+ window.property_get('XdndDirectSave0','text/plain')
+
+ # FIXME query the clipboard service for a filename?
+ base_dir = tempfile.gettempdir()
+ dest_filename = util.unique_id()
+
+ name, dot, extension = filename.rpartition('.')
+ dest_filename += dot + extension
+
+ dest_uri = 'file://' + os.path.join(base_dir, dest_filename)
+
+ window.property_change('XdndDirectSave0', prop_type, format,
+ gtk.gdk.PROP_MODE_REPLACE, dest_uri)
+
+ widget.drag_get_data(context, 'XdndDirectSave0', time)
+ else:
+ for target in context.targets:
+ if str(target) not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE'):
+ widget.drag_get_data(context, target, time)
cb_service.set_object_percent(object_id, percent=100)
@@ -147,12 +167,24 @@ class ClipboardBox(hippo.CanvasBox):
def drag_data_received_cb(self, widget, context, x, y, selection, targetType, time):
logging.debug('ClipboardBox: got data for target %r' % selection.target)
+
+ object_id = self._context_map.get_object_id(context)
try:
- if selection:
- object_id = self._context_map.get_object_id(context)
- self._add_selection(object_id, selection)
- else:
+ if selection is None:
logging.warn('ClipboardBox: empty selection for target ' + selection.target)
+ elif selection.target == 'XdndDirectSave0':
+ if selection.data == 'S':
+ window = context.source_window
+
+ prop_type, format, dest = \
+ window.property_get('XdndDirectSave0','text/plain')
+
+ clipboard = clipboardservice.get_instance()
+ clipboard.add_object_format(
+ object_id, 'XdndDirectSave0', dest, on_disk=True)
+ else:
+ self._add_selection(object_id, selection)
+
finally:
# If it's the last target to be processed, finish the dnd transaction
if not self._context_map.has_context(context):