aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-attachment-store.c
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2013-04-21 05:01:48 +0800
committerFabiano FidĂȘncio <fidencio@redhat.com>2013-04-26 08:06:47 +0800
commite90c8380f91ecbff3f0125c89b5a90ca1d26acde (patch)
tree375c017bd53e0473d94b7acee4130054323d9c7f /e-util/e-attachment-store.c
parentbb3e7286a285213ec8c33d4b32cabce970f8b7e3 (diff)
downloadgsoc2013-evolution-e90c8380f91ecbff3f0125c89b5a90ca1d26acde.tar
gsoc2013-evolution-e90c8380f91ecbff3f0125c89b5a90ca1d26acde.tar.gz
gsoc2013-evolution-e90c8380f91ecbff3f0125c89b5a90ca1d26acde.tar.bz2
gsoc2013-evolution-e90c8380f91ecbff3f0125c89b5a90ca1d26acde.tar.lz
gsoc2013-evolution-e90c8380f91ecbff3f0125c89b5a90ca1d26acde.tar.xz
gsoc2013-evolution-e90c8380f91ecbff3f0125c89b5a90ca1d26acde.tar.zst
gsoc2013-evolution-e90c8380f91ecbff3f0125c89b5a90ca1d26acde.zip
Bug 698488 - Attachment file chooser should preview attachments' content when possible
Diffstat (limited to 'e-util/e-attachment-store.c')
-rw-r--r--e-util/e-attachment-store.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/e-util/e-attachment-store.c b/e-util/e-attachment-store.c
index 16f38fb5e5..a608c06f74 100644
--- a/e-util/e-attachment-store.c
+++ b/e-util/e-attachment-store.c
@@ -24,6 +24,7 @@
#endif
#include "e-attachment-store.h"
+#include "e-icon-factory.h"
#include <errno.h>
#include <glib/gi18n.h>
@@ -415,6 +416,31 @@ e_attachment_store_get_total_size (EAttachmentStore *store)
return total_size;
}
+static void
+update_preview_cb (GtkFileChooser *file_chooser,
+ gpointer data)
+{
+ GtkWidget *preview;
+ gchar *filename = NULL;
+ GdkPixbuf *pixbuf;
+
+ gtk_file_chooser_set_preview_widget_active (file_chooser, FALSE);
+ gtk_image_clear (GTK_IMAGE (data));
+ preview = GTK_WIDGET (data);
+ filename = gtk_file_chooser_get_preview_filename (file_chooser);
+ if (filename == NULL)
+ return;
+
+ pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
+ g_free (filename);
+ if (!pixbuf)
+ return;
+
+ gtk_file_chooser_set_preview_widget_active (file_chooser, TRUE);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
+ g_object_unref (pixbuf);
+}
+
void
e_attachment_store_run_load_dialog (EAttachmentStore *store,
GtkWindow *parent)
@@ -422,6 +448,7 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
GtkFileChooser *file_chooser;
GtkWidget *dialog;
GtkWidget *option;
+ GtkImage *preview;
GSList *files, *iter;
const gchar *disposition;
gboolean active;
@@ -442,6 +469,14 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_window_set_icon_name (GTK_WINDOW (dialog), "mail-attachment");
+ preview = GTK_IMAGE (gtk_image_new ());
+ gtk_file_chooser_set_preview_widget (
+ GTK_FILE_CHOOSER (file_chooser),
+ GTK_WIDGET (preview));
+ g_signal_connect (
+ file_chooser, "update-preview",
+ G_CALLBACK (update_preview_cb), preview);
+
option = gtk_check_button_new_with_mnemonic (
_("_Suggest automatic display of attachment"));
gtk_file_chooser_set_extra_widget (file_chooser, option);