aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
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:03:37 +0800
commit009ac971e069ced92547800a78ab3119f733c333 (patch)
treeb2bbc5ff36e2afec8243188d2812db3fc98007f7 /e-util
parent0bc6624005e0d52a475243e9606e892d04ebe035 (diff)
downloadgsoc2013-evolution-009ac971e069ced92547800a78ab3119f733c333.tar.gz
gsoc2013-evolution-009ac971e069ced92547800a78ab3119f733c333.tar.zst
gsoc2013-evolution-009ac971e069ced92547800a78ab3119f733c333.zip
Bug 698488 - Attachment file chooser should preview attachments' content when possible
Diffstat (limited to 'e-util')
-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);