evolution r34800 - in trunk: addressbook addressbook/gui/contact-editor e-util mail widgets/misc



Author: mcrha
Date: Fri Jan 11 16:05:07 2008
New Revision: 34800
URL: http://svn.gnome.org/viewvc/evolution?rev=34800&view=rev

Log:
2008-01-11  Milan Crha  <mcrha redhat com>

	** Fix for bug #488213

	* e-util/e-icon-factory.h: (e_icon_factory_pixbuf_scale):
	* e-util/e-icon-factory.c: (e_icon_factory_pixbuf_scale):
	New global function for pixbuf scaling which speeds up scaling when
	HAVE_LIBGNOMEUI_GNOME_THUMBNAIL_H.

	* addressbook/gui/contact-editor/e-contact-editor.c: (extract_simple_field):
	* mail/em-icon-stream.c: (emis_fit):
	* mail/em-format-html-display.c: (efhd_attachment_button):
	* e-util/e-icon-factory.c: (load_icon):
	* widgets/misc/e-spinner.c: (scale_to_size):
	* widgets/misc/e-image-chooser.c: (set_image_from_data):
	* widgets/misc/e-attachment-bar.c: (e_attachment_bar_create_attachment_cache), (update):
	Use global function e_icon_factory_pixbuf_scale for scaling pixbufs.



Modified:
   trunk/addressbook/ChangeLog
   trunk/addressbook/gui/contact-editor/e-contact-editor.c
   trunk/e-util/ChangeLog
   trunk/e-util/e-icon-factory.c
   trunk/e-util/e-icon-factory.h
   trunk/mail/ChangeLog
   trunk/mail/em-format-html-display.c
   trunk/mail/em-icon-stream.c
   trunk/widgets/misc/ChangeLog
   trunk/widgets/misc/e-attachment-bar.c
   trunk/widgets/misc/e-image-chooser.c
   trunk/widgets/misc/e-spinner.c

Modified: trunk/addressbook/gui/contact-editor/e-contact-editor.c
==============================================================================
--- trunk/addressbook/gui/contact-editor/e-contact-editor.c	(original)
+++ trunk/addressbook/gui/contact-editor/e-contact-editor.c	Fri Jan 11 16:05:07 2008
@@ -2293,7 +2293,7 @@
 								height = 96;
 							}
 
-							new = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR);
+							new = e_icon_factory_pixbuf_scale (pixbuf, width, height);
 							if (new) {
 								GdkPixbufFormat *format = gdk_pixbuf_loader_get_format (loader);
 								gchar *format_name = gdk_pixbuf_format_get_name (format);

Modified: trunk/e-util/e-icon-factory.c
==============================================================================
--- trunk/e-util/e-icon-factory.c	(original)
+++ trunk/e-util/e-icon-factory.c	Fri Jan 11 16:05:07 2008
@@ -32,6 +32,9 @@
 
 #include <gtk/gtkicontheme.h>
 #include <gtk/gtkimage.h>
+#ifdef HAVE_LIBGNOMEUI_GNOME_THUMBNAIL_H
+#include <libgnomeui/gnome-thumbnail.h>
+#endif
 
 #include "e-icon-factory.h"
 #include "e-util-private.h"
@@ -161,7 +164,7 @@
 	if (unscaled != NULL) {
 		if(gdk_pixbuf_get_width(unscaled) != size || gdk_pixbuf_get_height(unscaled) != size)
 		{
-			pixbuf = gdk_pixbuf_scale_simple (unscaled, size, size, GDK_INTERP_BILINEAR);
+			pixbuf = e_icon_factory_pixbuf_scale (unscaled, size, size);
 			g_object_unref (unscaled);
 		} else
 			pixbuf = unscaled;
@@ -402,3 +405,30 @@
 
 	return list;
 }
+
+/**
+ * e_icon_factory_pixbuf_scale
+ * Scales pixbuf to desired size.
+ * @param pixbuf Pixbuf to be scaled.
+ * @param width Desired width, if less or equal to 0, then changed to 1.
+ * @param height Desired height, if less or equal to 0, then changed to 1.
+ * @return Scaled pixbuf.
+ **/
+GdkPixbuf *
+e_icon_factory_pixbuf_scale (GdkPixbuf *pixbuf, int width, int height)
+{
+	g_return_val_if_fail (pixbuf != NULL, NULL);
+
+	if (width <= 0)
+		width = 1;
+
+	if (height <= 0)
+		height = 1;
+
+#ifdef HAVE_LIBGNOMEUI_GNOME_THUMBNAIL_H
+	/* because this can only scale down, not up */
+	if (gdk_pixbuf_get_width (pixbuf) > width && gdk_pixbuf_get_height (pixbuf) > height)
+		return gnome_thumbnail_scale_down_pixbuf (pixbuf, width, height);
+#endif
+	return gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR);
+}

Modified: trunk/e-util/e-icon-factory.h
==============================================================================
--- trunk/e-util/e-icon-factory.h	(original)
+++ trunk/e-util/e-icon-factory.h	Fri Jan 11 16:05:07 2008
@@ -55,4 +55,6 @@
 
 GList     *e_icon_factory_get_icon_list     (const char *icon_name);
 
+GdkPixbuf *e_icon_factory_pixbuf_scale      (GdkPixbuf *pixbuf, int width, int height);
+
 #endif /* _E_ICON_FACTORY_H_ */

Modified: trunk/mail/em-format-html-display.c
==============================================================================
--- trunk/mail/em-format-html-display.c	(original)
+++ trunk/mail/em-format-html-display.c	Fri Jan 11 16:05:07 2008
@@ -1937,7 +1937,7 @@
 		GdkPixbuf *pixbuf, *mini;
 
 		if ((pixbuf = e_icon_for_mime_type (simple_type, 24))) {
-			if ((mini = gdk_pixbuf_scale_simple (pixbuf, 24, 24, GDK_INTERP_BILINEAR))) {
+			if ((mini = e_icon_factory_pixbuf_scale (pixbuf, 24, 24))) {
 				gtk_image_set_from_pixbuf ((GtkImage *) w, mini);
 				g_object_unref (mini);
 			}

Modified: trunk/mail/em-icon-stream.c
==============================================================================
--- trunk/mail/em-icon-stream.c	(original)
+++ trunk/mail/em-icon-stream.c	Fri Jan 11 16:05:07 2008
@@ -30,11 +30,9 @@
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gdk-pixbuf/gdk-pixbuf-loader.h>
-#ifdef HAVE_LIBGNOMEUI_GNOME_THUMBNAIL_H
-#include <libgnomeui/gnome-thumbnail.h>
-#endif
 #include <gtk/gtkimage.h>
 #include "em-icon-stream.h"
+#include "e-util/e-icon-factory.h"
 
 #include "libedataserver/e-msgport.h"
 
@@ -187,11 +185,7 @@
 		if (height <= 0)
 			height = 1;
 
-#ifdef HAVE_LIBGNOMEUI_GNOME_THUMBNAIL_H
-		mini = gnome_thumbnail_scale_down_pixbuf(pixbuf, width, height);
-#else
-		mini = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
-#endif
+		mini = e_icon_factory_pixbuf_scale (pixbuf, width, height);
 	}
 
 	return mini;

Modified: trunk/widgets/misc/e-attachment-bar.c
==============================================================================
--- trunk/widgets/misc/e-attachment-bar.c	(original)
+++ trunk/widgets/misc/e-attachment-bar.c	Fri Jan 11 16:05:07 2008
@@ -241,7 +241,7 @@
 				}
 			}
 
-			attachment->pixbuf_cache = gdk_pixbuf_scale_simple (pixbuf, width,height,GDK_INTERP_BILINEAR);
+			attachment->pixbuf_cache = e_icon_factory_pixbuf_scale (pixbuf, width, height);
 			pixbuf = attachment->pixbuf_cache;
 			g_object_ref(pixbuf);
 		} else {
@@ -334,8 +334,7 @@
 					}
 				}
 
-				attachment->pixbuf_cache = gdk_pixbuf_scale_simple (pixbuf, width, height,
-										    GDK_INTERP_BILINEAR);
+				attachment->pixbuf_cache = e_icon_factory_pixbuf_scale (pixbuf, width, height);
 				pixbuf = attachment->pixbuf_cache;
 				g_object_ref (pixbuf);
 			} else {

Modified: trunk/widgets/misc/e-image-chooser.c
==============================================================================
--- trunk/widgets/misc/e-image-chooser.c	(original)
+++ trunk/widgets/misc/e-image-chooser.c	Fri Jan 11 16:05:07 2008
@@ -34,6 +34,7 @@
 
 #include "e-image-chooser.h"
 #include "e-util/e-util-marshal.h"
+#include "e-util/e-icon-factory.h"
 
 struct _EImageChooserPrivate {
 
@@ -292,9 +293,7 @@
 
 			printf ("new scaled dimensions = (%d,%d)\n", new_width, new_height);
 
-			scaled = gdk_pixbuf_scale_simple (pixbuf,
-							  new_width, new_height,
-							  GDK_INTERP_BILINEAR);
+			scaled = e_icon_factory_pixbuf_scale (pixbuf, new_width, new_height);
 
 			composite = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, gdk_pixbuf_get_bits_per_sample (pixbuf),
 						    chooser->priv->image_width, chooser->priv->image_height);

Modified: trunk/widgets/misc/e-spinner.c
==============================================================================
--- trunk/widgets/misc/e-spinner.c	(original)
+++ trunk/widgets/misc/e-spinner.c	Fri Jan 11 16:05:07 2008
@@ -41,6 +41,8 @@
 #include <gtk/gtkiconfactory.h>
 #include <gtk/gtksettings.h>
 
+#include "e-util/e-icon-factory.h"
+
 /* Spinner cache implementation */
 
 #define E_TYPE_SPINNER_CACHE			(e_spinner_cache_get_type())
@@ -222,8 +224,7 @@
 
 	if (pw != dw || ph != dh)
 	{
-		result = gdk_pixbuf_scale_simple (pixbuf, dw, dh,
-						  GDK_INTERP_BILINEAR);
+		result = e_icon_factory_pixbuf_scale (pixbuf, dw, dh);
 		g_object_unref (pixbuf);
 		return result;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]