1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
From 1f73eec9d8b45c85a8f67a3242fcf6246c184795 Mon Sep 17 00:00:00 2001
From: Ajay Garg <ajay@activitycentral.com>
Date: Mon, 13 May 2013 00:20:44 +0530
Subject: [PATCH] sdxo#3031: Support for image data, text and url to
clipboard.
Organization: Sugar Labs Foundation
Signed-off-by: Ajay Garg <ajay@activitycentral.com>
---
activity/activity.info | 2 +-
toolbar.py | 36 ++++++++++++++++--------------------
2 files changed, 17 insertions(+), 21 deletions(-)
diff --git a/activity/activity.info b/activity/activity.info
index 499a708..39e228d 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -3,7 +3,7 @@ name = Write
bundle_id = org.laptop.AbiWordActivity
exec = sugar-activity AbiWordActivity.AbiWordActivity
icon = activity-write
-activity_version = 86.2
+activity_version = 86.3
show_launcher = 1
mime_types = text/rtf;text/plain;application/x-abiword;text/x-xml-abiword;application/msword;application/rtf;application/xhtml+xml;text/html;application/vnd.oasis.opendocument.text
license = GPLv2+
diff --git a/toolbar.py b/toolbar.py
index 7f69bf7..60d338a 100644
--- a/toolbar.py
+++ b/toolbar.py
@@ -133,31 +133,27 @@ class EditToolbar(Gtk.Toolbar):
self._findnext.set_sensitive(False)
def __paste_button_cb(self, button):
+
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
if clipboard.wait_is_image_available():
- pixbuf_sel = clipboard.wait_for_image()
- size = int(pixbuf_sel.get_width()), int(pixbuf_sel.get_height())
- activity = self._abiword_canvas.get_toplevel()
- temp_path = os.path.join(activity.get_activity_root(), 'instance')
- if not os.path.exists(temp_path):
- os.makedirs(temp_path)
- fd, file_path = tempfile.mkstemp(dir=temp_path, suffix='.png')
- os.close(fd)
- logging.error('tempfile is %s' % file_path)
- success, data = pixbuf_sel.save_to_bufferv('png', [], [])
- if success:
- px_file = open(file_path, 'w')
- px_file.write(data)
- px_file.close()
- self._abiword_canvas.insert_image(file_path, False)
-
+ selection = clipboard.wait_for_image()
+
+ if selection != None:
+
+ for pixbuf in selection:
+ self._abiword_canvas.insert_image(pixbuf, False)
+
elif clipboard.wait_is_uris_available():
- selection = clipboard.wait_for_contents('text/uri-list')
+
+ selection = clipboard.wait_for_uris()
+
if selection != None:
- for uri in selection.get_uris():
- self._abiword_canvas.insert_image(urlparse(uri).path,
- False)
+
+ for uri in selection:
+ self._abiword_canvas.insert_image(
+ urlparse(uri).path, False)
+
else:
self._abiword_canvas.paste()
--
1.7.11.7
|