aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
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
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')
-rw-r--r--addressbook/ChangeLog6
-rw-r--r--addressbook/addressbook.error.xml6
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c33
3 files changed, 44 insertions, 1 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 733edeea53..e4083c9b8f 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -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)
diff --git a/addressbook/addressbook.error.xml b/addressbook/addressbook.error.xml
index 523d420ce3..b4bbfff684 100644
--- a/addressbook/addressbook.error.xml
+++ b/addressbook/addressbook.error.xml
@@ -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>
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