? .addressbook.error.swp
? addressbook.error
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1962
diff -u -p -r1.1962 ChangeLog
--- ChangeLog	25 Jul 2005 07:06:16 -0000	1.1962
+++ ChangeLog	25 Jul 2005 11:26:29 -0000
@@ -1,3 +1,9 @@
+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.
+
 2005-07-25  Arunprakash <arunp@novell.com>
 
 	* gui/contact-editor/e-contact-editor.c (file_as_entry_changed)
Index: addressbook.error.xml
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/addressbook.error.xml,v
retrieving revision 1.1
diff -u -p -r1.1 addressbook.error.xml
--- addressbook.error.xml	16 May 2005 06:11:10 -0000	1.1
+++ addressbook.error.xml	25 Jul 2005 11:26:29 -0000
@@ -74,6 +74,12 @@
   <button stock="gtk-yes" response="GTK_RESPONSE_YES"/>
  </error>
 
+  <error type="question" id="prompt-resize" default="GTK_RESPONSE_YES">
+  <primary>The image you have selected is large. Do you want to resize and store it? </primary>
+  <button stock="gtk-no" response="GTK_RESPONSE_NO"/>
+  <button stock="gtk-yes" response="GTK_RESPONSE_YES"/>
+ </error>
+
  <error id="save-error" type="error">
   <_primary>Unable to save {0}.</_primary>
   <_secondary>Error saving {0} to {1}: {2}</_secondary>
Index: gui/contact-editor/e-contact-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-editor/e-contact-editor.c,v
retrieving revision 1.235
diff -u -p -r1.235 e-contact-editor.c
--- gui/contact-editor/e-contact-editor.c	22 Jul 2005 11:12:02 -0000	1.235
+++ gui/contact-editor/e-contact-editor.c	25 Jul 2005 11:26:30 -0000
@@ -2527,8 +2527,9 @@ categories_clicked (GtkWidget *button, E
 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));
@@ -2539,6 +2540,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);
@@ -2547,6 +2577,7 @@ image_selected (EContactEditor *editor)
 
 	editor->image_set = TRUE;
 	object_changed (G_OBJECT (image_chooser), editor);
+	g_free(scaled_file);
 }
 
 static void
