diff --git a/capplets/background/ChangeLog b/capplets/background/ChangeLog index c643e7fc2..5c83078f7 100644 --- a/capplets/background/ChangeLog +++ b/capplets/background/ChangeLog @@ -1,3 +1,14 @@ +2007-01-08 Ray Strode + + Fixes #351991 + + * gnome-wp-info.c (gnome_wp_info_new): don't try to pull from + ~/.thumbnails directly without checking mtime. + + * gnome-wp-item.c (collect_save_options, gnome_wp_item_get_thumbnail): + only generate thumbnails when a lookup shows there isn't already + one. Never load a background just to find out its size. + 2007-01-07 Thomas Wood Patch by: Jens Granseuer diff --git a/capplets/background/gnome-wp-info.c b/capplets/background/gnome-wp-info.c index 8e5b899b6..12ada351a 100644 --- a/capplets/background/gnome-wp-info.c +++ b/capplets/background/gnome-wp-info.c @@ -38,24 +38,11 @@ GnomeWPInfo * gnome_wp_info_new (const gchar * uri, GNOME_VFS_FILE_INFO_FOLLOW_LINKS); if (info == NULL || info->mime_type == NULL || result != GNOME_VFS_OK) { if (!strcmp (uri, "(none)")) { - gchar * md5sum; - new = g_new0 (GnomeWPInfo, 1); new->mime_type = g_strdup ("image/x-no-data"); new->uri = g_strdup (uri); - - md5sum = gnome_thumbnail_md5 (escaped_path); - - new->thumburi = g_strconcat (g_get_home_dir (), - "/.thumbnails/normal/", - md5sum, - ".png", - NULL); - g_free (md5sum); - new->name = g_strdup (_("No Wallpaper")); - new->size = 0; } else { new = NULL; @@ -68,19 +55,6 @@ GnomeWPInfo * gnome_wp_info_new (const gchar * uri, new->thumburi = gnome_thumbnail_factory_lookup (thumbs, escaped_path, info->mtime); - if (new->thumburi == NULL) { - gchar * md5sum; - - md5sum = gnome_thumbnail_md5 (escaped_path); - - new->thumburi = g_strconcat (g_get_home_dir (), - "/.thumbnails/normal/", - md5sum, - ".png", - NULL); - - g_free (md5sum); - } new->name = g_strdup (info->name); new->mime_type = g_strdup (info->mime_type); diff --git a/capplets/background/gnome-wp-item.c b/capplets/background/gnome-wp-item.c index 21ece890a..36a041b0d 100644 --- a/capplets/background/gnome-wp-item.c +++ b/capplets/background/gnome-wp-item.c @@ -202,7 +202,6 @@ static void collect_save_options (GdkPixbuf * pixbuf, GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item, GnomeThumbnailFactory * thumbs) { GdkPixbuf * pixbuf, * bgpixbuf; - GdkPixbuf * tmpbuf; GdkPixbuf * scaled = NULL; gint sw, sh, bw, bh, pw, ph, tw, th; gdouble ratio; @@ -242,22 +241,42 @@ GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item, If we are creating the thumbnail for "No Wallpaper", then we just copy the background colors pixbuf we created above, here */ - if (item->fileinfo->thumburi != NULL && - g_file_test (item->fileinfo->thumburi, G_FILE_TEST_EXISTS)) { - pixbuf = gdk_pixbuf_new_from_file (item->fileinfo->thumburi, NULL); - } else if (!strcmp (item->filename, "(none)")) { + pixbuf = NULL; + if (!strcmp (item->filename, "(none)")) { return bgpixbuf; } else { - gchar * escaped_path; + gchar * escaped_path, * thumbnail_filename; escaped_path = gnome_vfs_escape_path_string (item->filename); + thumbnail_filename = gnome_thumbnail_factory_lookup (thumbs, + escaped_path, + item->fileinfo->mtime); + if (thumbnail_filename == NULL) { pixbuf = gnome_thumbnail_factory_generate_thumbnail (thumbs, escaped_path, item->fileinfo->mime_type); gnome_thumbnail_factory_save_thumbnail (thumbs, pixbuf, escaped_path, item->fileinfo->mtime); + g_object_unref (pixbuf); + pixbuf = NULL; + + thumbnail_filename = gnome_thumbnail_factory_lookup (thumbs, + escaped_path, + item->fileinfo->mtime); + } + + if (thumbnail_filename != NULL) { + + pixbuf = gdk_pixbuf_new_from_file (thumbnail_filename, NULL); + + if (pixbuf != NULL) { + item->fileinfo->thumburi = thumbnail_filename; + thumbnail_filename = NULL; + } + } + g_free (escaped_path); } @@ -274,16 +293,12 @@ GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item, gchar ** keys = NULL; gchar ** vals = NULL; - tmpbuf = gdk_pixbuf_new_from_file (item->filename, NULL); - - item->width = gdk_pixbuf_get_width (tmpbuf); - item->height = gdk_pixbuf_get_height (tmpbuf); - + gdk_pixbuf_get_file_info (item->filename, + &item->width, &item->height); collect_save_options (pixbuf, &keys, &vals, item->width, item->height); gdk_pixbuf_savev (pixbuf, item->fileinfo->thumburi, "png", keys, vals, NULL); - g_object_unref (tmpbuf); g_strfreev (keys); g_strfreev (vals); } @@ -323,9 +338,10 @@ GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item, } scaled = gnome_wp_pixbuf_center (pixbuf, bgpixbuf, tw, th); } + + g_object_unref (pixbuf); } - g_object_unref (pixbuf); g_object_unref (bgpixbuf); return scaled;