aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorDevashish Sharma <sdevashish@novell.com>2006-02-01 19:07:17 +0800
committerDevashish Sharma <dsharma@src.gnome.org>2006-02-01 19:07:17 +0800
commit8a617df4348d86c31bae365e35f38d49ad4721a0 (patch)
treea7232ba7acc30301797d826bc9d31c2838e0f499 /addressbook/gui
parent6826f9d01e6680ec6265ce4ece0618c71ed7c070 (diff)
downloadgsoc2013-evolution-8a617df4348d86c31bae365e35f38d49ad4721a0.tar
gsoc2013-evolution-8a617df4348d86c31bae365e35f38d49ad4721a0.tar.gz
gsoc2013-evolution-8a617df4348d86c31bae365e35f38d49ad4721a0.tar.bz2
gsoc2013-evolution-8a617df4348d86c31bae365e35f38d49ad4721a0.tar.lz
gsoc2013-evolution-8a617df4348d86c31bae365e35f38d49ad4721a0.tar.xz
gsoc2013-evolution-8a617df4348d86c31bae365e35f38d49ad4721a0.tar.zst
gsoc2013-evolution-8a617df4348d86c31bae365e35f38d49ad4721a0.zip
File selector shows preview of the image when choosing picture of a
2006-02-01 Devashish Sharma <sdevashish@novell.com> * gui/contact-editor/e-contact-editor.c: File selector shows preview of the image when choosing picture of a contact. svn path=/trunk/; revision=31395
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index fa454cf395..fe56acec5d 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -2730,10 +2730,33 @@ file_selector_deleted (GtkWidget *widget)
}
static void
+update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
+{
+ GtkWidget *preview;
+ char *filename;
+ GdkPixbuf *pixbuf;
+ gboolean have_preview;
+
+ preview = GTK_WIDGET (data);
+ filename = gtk_file_chooser_get_preview_filename (file_chooser);
+
+ pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
+ have_preview = (pixbuf != NULL);
+ g_free (filename);
+
+ gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
+ if (pixbuf)
+ gdk_pixbuf_unref (pixbuf);
+
+ gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
+}
+
+static void
image_clicked (GtkWidget *button, EContactEditor *editor)
{
const gchar *title = _("Please select an image for this contact");
const gchar *no_image = _("No image");
+ GtkImage *preview;
if (!editor->file_selector) {
#ifdef USE_GTKFILECHOOSER
@@ -2744,6 +2767,10 @@ image_clicked (GtkWidget *button, EContactEditor *editor)
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
no_image, GTK_RESPONSE_NO,
NULL);
+ preview = GTK_IMAGE (gtk_image_new());
+ gtk_file_chooser_set_preview_widget ((GtkFileChooser *)editor->file_selector, GTK_WIDGET (preview));
+ g_signal_connect (editor->file_selector, "update-preview",
+ G_CALLBACK (update_preview_cb), preview);
gtk_dialog_set_default_response (GTK_DIALOG (editor->file_selector), GTK_RESPONSE_ACCEPT);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (editor->file_selector), g_get_home_dir ());