From 8a617df4348d86c31bae365e35f38d49ad4721a0 Mon Sep 17 00:00:00 2001 From: Devashish Sharma Date: Wed, 1 Feb 2006 11:07:17 +0000 Subject: File selector shows preview of the image when choosing picture of a 2006-02-01 Devashish Sharma * 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 --- addressbook/ChangeLog | 6 +++++ addressbook/gui/contact-editor/e-contact-editor.c | 27 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'addressbook') diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 62c9896e23..f3d417f58b 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,9 @@ +2006-02-01 Devashish Sharma + + * gui/contact-editor/e-contact-editor.c: File selector shows preview + of the image when choosing picture of a contact. + Fixes bug #300884. + 2006-02-01 Devashish Sharma * gui/widgets/e-minicard.c : (e_minicard_reflow) Fixed a bug which was 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 @@ -2729,11 +2729,34 @@ file_selector_deleted (GtkWidget *widget) return TRUE; } +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 ()); -- cgit v1.2.3