From 1d53cce44de58ed4069d44b4d29d9aee145ccc8e Mon Sep 17 00:00:00 2001
From: Sai Vineet <saivineet89@gmail.com>
Date: Thu, 4 Dec 2014 22:01:42 +0530
Subject: [PATCH 1/1] Add ability to preview images in Clipboard (with gonzalo)
---
src/jarabe/frame/clipboardmenu.py | 7 ++++++-
src/jarabe/frame/clipboardobject.py | 6 ++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/jarabe/frame/clipboardmenu.py b/src/jarabe/frame/clipboardmenu.py
index bee4ce1..ea6ec08 100644
a
|
b
|
from gi.repository import Gio |
23 | 23 | from gi.repository import GLib |
24 | 24 | |
25 | 25 | from gi.repository import Gtk |
| 26 | from gi.repository import GdkPixbuf |
26 | 27 | |
27 | 28 | from sugar3.graphics.palette import Palette |
28 | 29 | from sugar3.graphics.menuitem import MenuItem |
… |
… |
class ClipboardMenu(Palette): |
149 | 150 | self.props.primary_text = GLib.markup_escape_text(name) |
150 | 151 | preview = self._cb_object.get_preview() |
151 | 152 | if preview: |
152 | | self.props.secondary_text = GLib.markup_escape_text(preview) |
| 153 | if isinstance(preview, str): |
| 154 | self.props.secondary_text = GLib.markup_escape_text(preview) |
| 155 | if isinstance(preview, GdkPixbuf.Pixbuf): |
| 156 | self.set_pixbuf(preview) |
| 157 | |
153 | 158 | self._update_items_visibility() |
154 | 159 | self._update_open_submenu() |
155 | 160 | |
diff --git a/src/jarabe/frame/clipboardobject.py b/src/jarabe/frame/clipboardobject.py
index 039eab2..09ceed6 100644
a
|
b
|
from gi.repository import Gtk |
23 | 23 | from gettext import gettext as _ |
24 | 24 | from sugar3 import mime |
25 | 25 | from sugar3.bundle.activitybundle import ActivityBundle |
| 26 | from sugar3.graphics.objectchooser import get_preview_pixbuf |
26 | 27 | |
27 | 28 | |
28 | 29 | class ClipboardObject(object): |
… |
… |
class ClipboardObject(object): |
77 | 78 | for mime_type in ['text/plain']: |
78 | 79 | if mime_type in self._formats: |
79 | 80 | return self._formats[mime_type].get_data() |
| 81 | for mime_type in ['image/png']: |
| 82 | if mime_type in self._formats: |
| 83 | pixbuf = get_preview_pixbuf( |
| 84 | self._formats[mime_type].get_data()) |
| 85 | return pixbuf |
80 | 86 | return '' |
81 | 87 | |
82 | 88 | def is_bundle(self): |