diff options
author | Andy Hertzfeld <andy@src.gnome.org> | 2000-10-31 06:09:18 +0000 |
---|---|---|
committer | Andy Hertzfeld <andy@src.gnome.org> | 2000-10-31 06:09:18 +0000 |
commit | f7f655c0c5ef9c54989af62bcf6215e3b0178646 (patch) | |
tree | 1e36969c46b713167b8937a1f6d2bbc057417711 /libnautilus-extensions | |
parent | fd020b577e374b4460143a1d10debe154d9eb232 (diff) | |
download | nautilus-f7f655c0c5ef9c54989af62bcf6215e3b0178646.tar.gz |
made thumbnailing work remotely for all images, by treating small remote
made thumbnailing work remotely for all images, by treating
small remote files like large ones and keeping a local thumbnail
for them.
* libnautilus-extensions/nautilus-icon-factory-private.h:
moved SELF_THUMBNAIL_SIZE_THRESHOLD constant into private,
so it could be shared with nautilus-thumbnails.
* libnautilus-extensions/nautilus-icon-factory.c:
(nautilus_icon_factory_get_icon_for_file):
if a file is remote, make a thumbnail even if it's smaller
than the size threshold.
* libnautilus-extensions/nautilus-thumbnails.c: (make_thumbnails):
don't use a frame for files smaller than the size threshold.
Diffstat (limited to 'libnautilus-extensions')
-rw-r--r-- | libnautilus-extensions/nautilus-icon-factory-private.h | 6 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-icon-factory.c | 4 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-thumbnails.c | 33 |
3 files changed, 29 insertions, 14 deletions
diff --git a/libnautilus-extensions/nautilus-icon-factory-private.h b/libnautilus-extensions/nautilus-icon-factory-private.h index 475758eff..5b57b12e2 100644 --- a/libnautilus-extensions/nautilus-icon-factory-private.h +++ b/libnautilus-extensions/nautilus-icon-factory-private.h @@ -28,6 +28,12 @@ #include "nautilus-icon-factory.h" +/* For now, images are used themselves as thumbnails when they are + * below this threshold size. Later we might have to have a more + * complex rule about when to use an image for itself. + */ +#define SELF_THUMBNAIL_SIZE_THRESHOLD 16384 + void nautilus_icon_factory_remove_by_uri (const char *uri); #endif /* NAUTILUS_ICON_FACTORY_PRIVATE_H */ diff --git a/libnautilus-extensions/nautilus-icon-factory.c b/libnautilus-extensions/nautilus-icon-factory.c index fb8297383..6f54cea3c 100644 --- a/libnautilus-extensions/nautilus-icon-factory.c +++ b/libnautilus-extensions/nautilus-icon-factory.c @@ -1276,6 +1276,7 @@ NautilusScalableIcon * nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char* modifier, gboolean anti_aliased) { char *uri, *file_uri, *file_path, *image_uri, *icon_name, *mime_type, *top_left_text; + gboolean is_local; int file_size; NautilusScalableIcon *scalable_icon; @@ -1286,6 +1287,7 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char* modifie /* if there is a custom image in the metadata, use that. */ uri = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL); file_uri = nautilus_file_get_uri (file); + is_local = nautilus_file_is_local (file); /* if the file is an image, either use the image itself as the icon if it's small enough, or use a thumbnail if one exists. If it's too large, don't try to thumbnail it at all. @@ -1298,7 +1300,7 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char* modifie file_size = nautilus_file_get_size (file); if (nautilus_istr_has_prefix (mime_type, "image/") && should_display_image_file_as_itself (file)) { - if (file_size < SELF_THUMBNAIL_SIZE_THRESHOLD) { + if (file_size < SELF_THUMBNAIL_SIZE_THRESHOLD && is_local) { uri = nautilus_file_get_uri (file); } else if (strstr (file_uri, "/.thumbnails/") == NULL && file_size < INHIBIT_THUMBNAIL_SIZE_THRESHOLD) { uri = nautilus_get_thumbnail_uri (file, anti_aliased); diff --git a/libnautilus-extensions/nautilus-thumbnails.c b/libnautilus-extensions/nautilus-thumbnails.c index 36c659274..4cc71c6c0 100644 --- a/libnautilus-extensions/nautilus-thumbnails.c +++ b/libnautilus-extensions/nautilus-thumbnails.c @@ -456,9 +456,11 @@ make_thumbnails (gpointer data) if (!(info->thumbnail_task = fork())) { GdkPixbuf* full_size_image; NautilusFile *file; + GnomeVFSFileSize file_size; char *thumbnail_path; file = nautilus_file_get (info->thumbnail_uri); + file_size = nautilus_file_get_size (file); full_size_image = NULL; if (nautilus_file_is_mime_type (file, "image/svg")) { @@ -483,22 +485,27 @@ make_thumbnails (gpointer data) scaled_image = nautilus_gdk_pixbuf_scale_down_to_fit(full_size_image, 96, 96); gdk_pixbuf_unref (full_size_image); - /* embed the content image in the frame */ - frame_offset_str = nautilus_theme_get_theme_data ("thumbnails", "FRAME_OFFSETS"); - if (frame_offset_str != NULL) { - sscanf (frame_offset_str," %d , %d , %d , %d %*s", &left_offset, &top_offset, &right_offset, &bottom_offset); - } else { - /* use nominal values since the info in the theme couldn't be found */ - left_offset = 3; top_offset = 3; - right_offset = 6; bottom_offset = 6; - } + /* embed the content image in the frame, if necessary */ + if (file_size > SELF_THUMBNAIL_SIZE_THRESHOLD) { + + frame_offset_str = nautilus_theme_get_theme_data ("thumbnails", "FRAME_OFFSETS"); + if (frame_offset_str != NULL) { + sscanf (frame_offset_str," %d , %d , %d , %d %*s", &left_offset, &top_offset, &right_offset, &bottom_offset); + } else { + /* use nominal values since the info in the theme couldn't be found */ + left_offset = 3; top_offset = 3; + right_offset = 6; bottom_offset = 6; + } - framed_image = nautilus_embed_image_in_frame (scaled_image, thumbnail_image_frame, + framed_image = nautilus_embed_image_in_frame (scaled_image, thumbnail_image_frame, left_offset, top_offset, right_offset, bottom_offset); - g_free (frame_offset_str); + g_free (frame_offset_str); - gdk_pixbuf_unref (scaled_image); - gdk_pixbuf_unref (thumbnail_image_frame); + gdk_pixbuf_unref (scaled_image); + gdk_pixbuf_unref (thumbnail_image_frame); + } else { + framed_image = scaled_image; + } thumbnail_path = gnome_vfs_get_local_path_from_uri (new_thumbnail_path); if (!nautilus_gdk_pixbuf_save_to_file (framed_image, thumbnail_path)) { |