aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/contact-editor/e-contact-editor.c
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavam@novell.com>2005-07-25 19:28:40 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2005-07-25 19:28:40 +0800
commitc89aef269f18f8160771d535c703f6b69856e4a6 (patch)
tree24c78a652f5a3ae2bb230e4d8767eab2a86d56eb /addressbook/gui/contact-editor/e-contact-editor.c
parent88f3cfaa05579162f1e7a7b3d06954a16f2e7acd (diff)
downloadgsoc2013-evolution-c89aef269f18f8160771d535c703f6b69856e4a6.tar
gsoc2013-evolution-c89aef269f18f8160771d535c703f6b69856e4a6.tar.gz
gsoc2013-evolution-c89aef269f18f8160771d535c703f6b69856e4a6.tar.bz2
gsoc2013-evolution-c89aef269f18f8160771d535c703f6b69856e4a6.tar.lz
gsoc2013-evolution-c89aef269f18f8160771d535c703f6b69856e4a6.tar.xz
gsoc2013-evolution-c89aef269f18f8160771d535c703f6b69856e4a6.tar.zst
gsoc2013-evolution-c89aef269f18f8160771d535c703f6b69856e4a6.zip
Added a string for resize popup Added code to check the size of image and
2005-07-25 Srinivasa Ragavan <sragavam@novell.com> * addressbook.error.xml: Added a string for resize popup * gui/contact-editor/e-contact-editor.c: (image_selected) Added code to check the size of image and prompt for resize. svn path=/trunk/; revision=29885
Diffstat (limited to 'addressbook/gui/contact-editor/e-contact-editor.c')
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index f2e92dd64d..befeea1e72 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -2526,8 +2526,9 @@ categories_clicked (GtkWidget *button, EContactEditor *editor)
static void
image_selected (EContactEditor *editor)
{
- gchar *file_name;
+ gchar *file_name, *scaled_file = NULL;
GtkWidget *image_chooser;
+ GdkPixbuf *new, *photo;
#ifdef USE_GTKFILECHOOSER
file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (editor->file_selector));
@@ -2538,6 +2539,35 @@ image_selected (EContactEditor *editor)
if (!file_name)
return;
+ photo = gdk_pixbuf_new_from_file (file_name, NULL);
+ if (photo) {
+ int width, height;
+
+ height = gdk_pixbuf_get_height (photo);
+ width = gdk_pixbuf_get_width (photo);
+
+ if ((height > 96 || width > 96) && e_error_run (GTK_WINDOW (editor), "addressbook:prompt-resize", NULL) == GTK_RESPONSE_YES) {
+
+ if ( width > height) {
+ height = height * 96 / width;
+ width = 96;
+ } else {
+ width = width *96 / height;
+ height = 96;
+ }
+ scaled_file = e_mktemp("eab-XXXXXX");
+
+ new = gdk_pixbuf_scale_simple (photo, width, height, GDK_INTERP_BILINEAR);
+ gdk_pixbuf_save (new, scaled_file, "jpeg", NULL, "quality", "100", NULL);
+ file_name = scaled_file;
+ g_object_unref (new);
+ }
+ g_object_unref (photo);
+ } else {
+ return;
+ }
+
+
image_chooser = glade_xml_get_widget (editor->gui, "image-chooser");
g_signal_handlers_block_by_func (image_chooser, image_chooser_changed, editor);
@@ -2546,6 +2576,7 @@ image_selected (EContactEditor *editor)
editor->image_set = TRUE;
object_changed (G_OBJECT (image_chooser), editor);
+ g_free(scaled_file);
}
static void