aboutsummaryrefslogtreecommitdiffstats
path: root/composer
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-12-16 20:57:38 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-12-16 20:57:38 +0800
commitc24b6b2f71f529d7a89277d9d6957cb686ea1b6e (patch)
treec33c9d7a3cc1618fbff3377cfa6113a972ae022c /composer
parentf4899e740e50880f389276ea3941fb02da12e6c3 (diff)
downloadgsoc2013-evolution-c24b6b2f71f529d7a89277d9d6957cb686ea1b6e.tar.gz
gsoc2013-evolution-c24b6b2f71f529d7a89277d9d6957cb686ea1b6e.tar.zst
gsoc2013-evolution-c24b6b2f71f529d7a89277d9d6957cb686ea1b6e.zip
** Fix for bug #564248
2008-12-16 Milan Crha <mcrha@redhat.com> ** Fix for bug #564248 * e-msg-composer.c: (msg_composer_paste_clipboard): Attach images pasted from a clipboard. Note: Requires at least gtkhtml revision 9067. svn path=/trunk/; revision=36906
Diffstat (limited to 'composer')
-rw-r--r--composer/ChangeLog7
-rw-r--r--composer/e-msg-composer.c35
2 files changed, 40 insertions, 2 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 381e74dbe5..55ac3df4a6 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-16 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #564248
+
+ * e-msg-composer.c: (msg_composer_paste_clipboard):
+ Attach images pasted from a clipboard.
+
2008-12-11 Matthew Barnes <mbarnes@redhat.com>
** Fixes bug #562450
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 0f2026acac..b334e68e34 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -67,6 +67,7 @@
#include "e-util/e-plugin-ui.h"
#include "e-util/e-util-private.h"
#include "e-util/e-util.h"
+#include "e-util/e-mktemp.h"
#include <mail/em-event.h>
#include "e-signature-combo-box.h"
@@ -2454,6 +2455,7 @@ msg_composer_paste_clipboard (GtkhtmlEditor *editor)
EMsgComposer *composer;
GtkWidget *parent;
GtkWidget *widget;
+ GtkClipboard *clipboard;
composer = E_MSG_COMPOSER (editor);
widget = gtk_window_get_focus (GTK_WINDOW (editor));
@@ -2464,8 +2466,37 @@ msg_composer_paste_clipboard (GtkhtmlEditor *editor)
return;
}
- /* Chain up to parent's paste_clipboard() method. */
- GTKHTML_EDITOR_CLASS (parent_class)->paste_clipboard (editor);
+ clipboard = gtk_widget_get_clipboard (widget, GDK_SELECTION_CLIPBOARD);
+ if (clipboard && gtk_clipboard_wait_is_image_available (clipboard)) {
+ GdkPixbuf *pixbuf;
+
+ pixbuf = gtk_clipboard_wait_for_image (clipboard);
+ if (pixbuf) {
+ char *tmpl = g_strconcat (_("Image"), "-XXXXXX", NULL);
+ char *filename = e_mktemp (tmpl);
+
+ g_free (tmpl);
+
+ if (filename && gdk_pixbuf_save (pixbuf, filename, "png", NULL, NULL)) {
+ if (gtkhtml_editor_get_html_mode (editor)) {
+ char *uri = g_strconcat ("file://", filename, NULL);
+ /* this loads image async, thus cannot remove file from this */
+ gtkhtml_editor_insert_image (editor, uri);
+ g_free (uri);
+ } else {
+ /* this loads image immediately, remove file from cache to free up disk space */
+ e_attachment_bar_attach (E_ATTACHMENT_BAR (composer->priv->attachment_bar), filename, "image/png");
+ g_remove (filename);
+ }
+ }
+
+ g_free (filename);
+ g_object_unref (pixbuf);
+ }
+ } else {
+ /* Chain up to parent's paste_clipboard() method. */
+ GTKHTML_EDITOR_CLASS (parent_class)->paste_clipboard (editor);
+ }
}
static void