Fixes #351991
2007-01-08 Ray Strode <rstrode@redhat.com> 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. svn path=/trunk/; revision=7104
This commit is contained in:
parent
9a20027755
commit
1062b38bba
3 changed files with 40 additions and 39 deletions
|
@ -1,3 +1,14 @@
|
||||||
|
2007-01-08 Ray Strode <rstrode@redhat.com>
|
||||||
|
|
||||||
|
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 <thos@gnome.org>
|
2007-01-07 Thomas Wood <thos@gnome.org>
|
||||||
|
|
||||||
Patch by: Jens Granseuer <jensgr@gmx.net>
|
Patch by: Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
|
@ -38,24 +38,11 @@ GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
|
||||||
GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
|
GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
|
||||||
if (info == NULL || info->mime_type == NULL || result != GNOME_VFS_OK) {
|
if (info == NULL || info->mime_type == NULL || result != GNOME_VFS_OK) {
|
||||||
if (!strcmp (uri, "(none)")) {
|
if (!strcmp (uri, "(none)")) {
|
||||||
gchar * md5sum;
|
|
||||||
|
|
||||||
new = g_new0 (GnomeWPInfo, 1);
|
new = g_new0 (GnomeWPInfo, 1);
|
||||||
|
|
||||||
new->mime_type = g_strdup ("image/x-no-data");
|
new->mime_type = g_strdup ("image/x-no-data");
|
||||||
new->uri = g_strdup (uri);
|
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->name = g_strdup (_("No Wallpaper"));
|
||||||
|
|
||||||
new->size = 0;
|
new->size = 0;
|
||||||
} else {
|
} else {
|
||||||
new = NULL;
|
new = NULL;
|
||||||
|
@ -68,19 +55,6 @@ GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
|
||||||
new->thumburi = gnome_thumbnail_factory_lookup (thumbs,
|
new->thumburi = gnome_thumbnail_factory_lookup (thumbs,
|
||||||
escaped_path,
|
escaped_path,
|
||||||
info->mtime);
|
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->name = g_strdup (info->name);
|
||||||
new->mime_type = g_strdup (info->mime_type);
|
new->mime_type = g_strdup (info->mime_type);
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,6 @@ static void collect_save_options (GdkPixbuf * pixbuf,
|
||||||
GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
|
GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
|
||||||
GnomeThumbnailFactory * thumbs) {
|
GnomeThumbnailFactory * thumbs) {
|
||||||
GdkPixbuf * pixbuf, * bgpixbuf;
|
GdkPixbuf * pixbuf, * bgpixbuf;
|
||||||
GdkPixbuf * tmpbuf;
|
|
||||||
GdkPixbuf * scaled = NULL;
|
GdkPixbuf * scaled = NULL;
|
||||||
gint sw, sh, bw, bh, pw, ph, tw, th;
|
gint sw, sh, bw, bh, pw, ph, tw, th;
|
||||||
gdouble ratio;
|
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
|
If we are creating the thumbnail for "No Wallpaper", then we just copy
|
||||||
the background colors pixbuf we created above, here
|
the background colors pixbuf we created above, here
|
||||||
*/
|
*/
|
||||||
if (item->fileinfo->thumburi != NULL &&
|
pixbuf = NULL;
|
||||||
g_file_test (item->fileinfo->thumburi, G_FILE_TEST_EXISTS)) {
|
if (!strcmp (item->filename, "(none)")) {
|
||||||
pixbuf = gdk_pixbuf_new_from_file (item->fileinfo->thumburi, NULL);
|
|
||||||
} else if (!strcmp (item->filename, "(none)")) {
|
|
||||||
return bgpixbuf;
|
return bgpixbuf;
|
||||||
} else {
|
} else {
|
||||||
gchar * escaped_path;
|
gchar * escaped_path, * thumbnail_filename;
|
||||||
|
|
||||||
escaped_path = gnome_vfs_escape_path_string (item->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,
|
pixbuf = gnome_thumbnail_factory_generate_thumbnail (thumbs,
|
||||||
escaped_path,
|
escaped_path,
|
||||||
item->fileinfo->mime_type);
|
item->fileinfo->mime_type);
|
||||||
gnome_thumbnail_factory_save_thumbnail (thumbs, pixbuf,
|
gnome_thumbnail_factory_save_thumbnail (thumbs, pixbuf,
|
||||||
escaped_path,
|
escaped_path,
|
||||||
item->fileinfo->mtime);
|
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);
|
g_free (escaped_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,16 +293,12 @@ GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
|
||||||
gchar ** keys = NULL;
|
gchar ** keys = NULL;
|
||||||
gchar ** vals = NULL;
|
gchar ** vals = NULL;
|
||||||
|
|
||||||
tmpbuf = gdk_pixbuf_new_from_file (item->filename, NULL);
|
gdk_pixbuf_get_file_info (item->filename,
|
||||||
|
&item->width, &item->height);
|
||||||
item->width = gdk_pixbuf_get_width (tmpbuf);
|
|
||||||
item->height = gdk_pixbuf_get_height (tmpbuf);
|
|
||||||
|
|
||||||
collect_save_options (pixbuf, &keys, &vals, item->width, item->height);
|
collect_save_options (pixbuf, &keys, &vals, item->width, item->height);
|
||||||
gdk_pixbuf_savev (pixbuf, item->fileinfo->thumburi, "png",
|
gdk_pixbuf_savev (pixbuf, item->fileinfo->thumburi, "png",
|
||||||
keys, vals, NULL);
|
keys, vals, NULL);
|
||||||
|
|
||||||
g_object_unref (tmpbuf);
|
|
||||||
g_strfreev (keys);
|
g_strfreev (keys);
|
||||||
g_strfreev (vals);
|
g_strfreev (vals);
|
||||||
}
|
}
|
||||||
|
@ -323,9 +338,10 @@ GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
|
||||||
}
|
}
|
||||||
scaled = gnome_wp_pixbuf_center (pixbuf, bgpixbuf, tw, th);
|
scaled = gnome_wp_pixbuf_center (pixbuf, bgpixbuf, tw, th);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (pixbuf);
|
|
||||||
g_object_unref (bgpixbuf);
|
g_object_unref (bgpixbuf);
|
||||||
|
|
||||||
return scaled;
|
return scaled;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue