diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c index 9834033ed..bfa4653e3 100644 --- a/gtk/gtkfilesystem.c +++ b/gtk/gtkfilesystem.c @@ -1922,10 +1922,38 @@ _gtk_file_info_render_icon (GFileInfo *info, thumbnail_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH); + /* A thumbnail is shown from the next larger size there is (normal or + * large, see the file chooser) made smaller with the quick bilinear + * filter, as a page of them is decoded at once; one smaller than + * @icon_size, of a small picture, is shown as it is, not enlarged */ if (thumbnail_path) - pixbuf = gdk_pixbuf_new_from_file_at_size (thumbnail_path, - icon_size, icon_size, - NULL); + { + pixbuf = gdk_pixbuf_new_from_file (thumbnail_path, NULL); + if (pixbuf) + { + gint width = gdk_pixbuf_get_width (pixbuf); + gint height = gdk_pixbuf_get_height (pixbuf); + + if (width > icon_size || height > icon_size) + { + GdkPixbuf *scaled; + + if (width > height) + { + height = MAX (1, (gint) ((gint64) height * icon_size / width)); + width = icon_size; + } + else + { + width = MAX (1, (gint) ((gint64) width * icon_size / height)); + height = icon_size; + } + scaled = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR); + g_object_unref (pixbuf); + pixbuf = scaled; + } + } + } if (!pixbuf) {