summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2001-04-27 01:19:07 +0000
committerDarin Adler <darin@src.gnome.org>2001-04-27 01:19:07 +0000
commitf290a4226d73b3975c8e24e3516747319a484157 (patch)
tree84519abbd7831018a3b91ab8459f23860d33689b
parent377cd43e9ab465abd875677fef34cc88bb126d52 (diff)
downloadnautilus-f290a4226d73b3975c8e24e3516747319a484157.tar.gz
Integrated a patch by Alexander Larsson <alla@lysator.liu.se> that
adds a JPEG-specific thumbnailing function that's faster than the exiting thumbnail code. This new code is only included if the libjpeg library is present at configure time. We still need RPM spec file changes to require this library if we are going to build RPMs on systems that have libjpeg. I fixed a few bugs in Alex's original patch and made some coding style tweaks as well. * acconfig.h: * configure.in: Added a check for libjpeg. * libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-thumbnails-jpeg.c: * libnautilus-extensions/nautilus-thumbnails-jpeg.h: Add new source files with JPEG thumbnailer. * libnautilus-extensions/nautilus-thumbnails.c: (make_thumbnails): Call the new function for JPEG files. Other changes. * libnautilus-extensions/nautilus-volume-monitor.c: Change interval back to 2 seconds. * libnautilus-extensions/nautilus-preferences.c: (preferences_set_storage_path): Fix storage leak. (nautilus_self_check_preferences): Added more checks. * libnautilus-extensions/nautilus-icon-factory.c: (nautilus_icon_factory_get_icon_for_file): Tiny code tweak.
-rw-r--r--ChangeLog37
-rw-r--r--acconfig.h1
-rw-r--r--configure.in23
-rw-r--r--libnautilus-extensions/Makefile.am3
-rw-r--r--libnautilus-extensions/nautilus-icon-factory.c3
-rw-r--r--libnautilus-extensions/nautilus-preferences.c9
-rw-r--r--libnautilus-extensions/nautilus-thumbnails-jpeg.c224
-rw-r--r--libnautilus-extensions/nautilus-thumbnails-jpeg.h34
-rw-r--r--libnautilus-extensions/nautilus-thumbnails.c22
-rw-r--r--libnautilus-extensions/nautilus-volume-monitor.c2
-rw-r--r--libnautilus-private/Makefile.am3
-rw-r--r--libnautilus-private/nautilus-icon-factory.c3
-rw-r--r--libnautilus-private/nautilus-preferences.c9
-rw-r--r--libnautilus-private/nautilus-thumbnails-jpeg.c224
-rw-r--r--libnautilus-private/nautilus-thumbnails-jpeg.h34
-rw-r--r--libnautilus-private/nautilus-thumbnails.c22
-rw-r--r--libnautilus-private/nautilus-volume-monitor.c2
17 files changed, 628 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 7f7332e30..fd9cc9f8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,43 @@
+2001-04-26 Darin Adler <darin@eazel.com>
+
+ Integrated a patch by Alexander Larsson <alla@lysator.liu.se> that
+ adds a JPEG-specific thumbnailing function that's faster than the
+ exiting thumbnail code. This new code is only included if the
+ libjpeg library is present at configure time. We still need RPM
+ spec file changes to require this library if we are going to build
+ RPMs on systems that have libjpeg. I fixed a few bugs in Alex's
+ original patch and made some coding style tweaks as well.
+
+ * acconfig.h:
+ * configure.in:
+ Added a check for libjpeg.
+
+ * libnautilus-extensions/Makefile.am:
+ * libnautilus-extensions/nautilus-thumbnails-jpeg.c:
+ * libnautilus-extensions/nautilus-thumbnails-jpeg.h:
+ Add new source files with JPEG thumbnailer.
+
+ * libnautilus-extensions/nautilus-thumbnails.c: (make_thumbnails):
+ Call the new function for JPEG files.
+
+ Other changes.
+
+ * libnautilus-extensions/nautilus-volume-monitor.c: Change
+ interval back to 2 seconds.
+
+ * libnautilus-extensions/nautilus-preferences.c:
+ (preferences_set_storage_path): Fix storage leak.
+ (nautilus_self_check_preferences): Added more checks.
+
+ * libnautilus-extensions/nautilus-icon-factory.c:
+ (nautilus_icon_factory_get_icon_for_file): Tiny code tweak.
+
2001-04-26 Rebecca Schulman <rebecka@eazel.com>
+
Fix bugzilla.eazel.com bug 7934, to remove the ability
to make an index using Nautilus.
- reviewed by: Darin Adler <darin@eazle.com>
+ reviewed by: Darin Adler <darin@eazel.com>
* src/file-manager/fm-list-view.c: (get_cell_text):
* src/file-manager/fm-search-list-view.c: (real_load_error),
diff --git a/acconfig.h b/acconfig.h
index b1eb96b22..d2efc960c 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -8,6 +8,7 @@
#undef HAVE_GETTEXT
#undef HAVE_LC_MESSAGES
#undef HAVE_MEDUSA
+#undef HAVE_LIBJPEG
#undef HAVE_STPCPY
#undef HAVE_LIBBZ2
#undef HAVE_AMMONITE
diff --git a/configure.in b/configure.in
index e90438da7..0dc976c21 100644
--- a/configure.in
+++ b/configure.in
@@ -793,6 +793,27 @@ dnl =======================
dnl = End tests for libpng
dnl =======================
+dnl ====================================
+dnl = Begin tests for libjpeg
+dnl ====================================
+ if test -z "$LIBJPEG"; then
+ AC_CHECK_LIB(jpeg, jpeg_start_decompress,
+ AC_CHECK_HEADER(jpeglib.h,
+ jpeg_ok=yes,
+ jpeg_ok=no),
+ AC_MSG_WARN(*** (jpeg library not found) ***), -lm)
+ if test "$jpeg_ok" = yes; then
+ JPEG='jpeg'; LIBJPEG='-ljpeg'
+ AC_DEFINE(HAVE_LIBJPEG)
+ else
+ AC_MSG_WARN(*** JPEG loader will not be built (jpeg header file not found) ***)
+ fi
+ fi
+
+AC_SUBST(LIBJPEG)
+dnl =======================
+dnl = End tests for libjpeg
+dnl =======================
dnl =======================
dnl = Set up for library directories
@@ -968,6 +989,8 @@ help/nautilus-quick-reference/sv/Makefile
help/nautilus-quick-reference/ko/Makefile
help/nautilus-release-notes/Makefile
help/nautilus-release-notes/C/Makefile
+help/nautilus-screenshot-guidelines/Makefile
+help/nautilus-screenshot-guidelines/C/Makefile
applets/Makefile
applets/launcher/Makefile
applets/preferences-applet/Makefile
diff --git a/libnautilus-extensions/Makefile.am b/libnautilus-extensions/Makefile.am
index 893350fcb..8446c4508 100644
--- a/libnautilus-extensions/Makefile.am
+++ b/libnautilus-extensions/Makefile.am
@@ -48,6 +48,7 @@ libnautilus_extensions_la_LDFLAGS = \
$(GNOMECANVASPIXBUF_LIBS) \
$(GNOME_LIBS) \
$(LIBPNG) \
+ $(LIBJPEG) \
$(MEDUSA_LIBS) \
$(OAF_LIBS) \
$(VFS_LIBS) \
@@ -117,6 +118,7 @@ libnautilus_extensions_la_SOURCES = \
nautilus-sound.c \
nautilus-theme.c \
nautilus-thumbnails.c \
+ nautilus-thumbnails-jpeg.c \
nautilus-trash-directory.c \
nautilus-trash-file.c \
nautilus-trash-monitor.c \
@@ -192,6 +194,7 @@ noinst_HEADERS = \
nautilus-sound.h \
nautilus-theme.h \
nautilus-thumbnails.h \
+ nautilus-thumbnails-jpeg.h \
nautilus-trash-directory.h \
nautilus-trash-file.h \
nautilus-trash-monitor.h \
diff --git a/libnautilus-extensions/nautilus-icon-factory.c b/libnautilus-extensions/nautilus-icon-factory.c
index 44bd72dae..372a86c8f 100644
--- a/libnautilus-extensions/nautilus-icon-factory.c
+++ b/libnautilus-extensions/nautilus-icon-factory.c
@@ -1429,7 +1429,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
}
g_free (file_path);
- file_path = NULL;
}
g_free (directory);
g_free (desktop_directory);
@@ -1478,7 +1477,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
}
}
g_free (file_path);
- file_path = NULL;
}
}
@@ -1493,7 +1491,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
gnome_desktop_entry_free (entry);
}
g_free (file_path);
- file_path = NULL;
}
}
diff --git a/libnautilus-extensions/nautilus-preferences.c b/libnautilus-extensions/nautilus-preferences.c
index cd5ea51f4..41d0e7155 100644
--- a/libnautilus-extensions/nautilus-preferences.c
+++ b/libnautilus-extensions/nautilus-preferences.c
@@ -162,6 +162,7 @@ preferences_set_storage_path (const char *new_storage_path)
/* Stop monitoring the old path */
nautilus_gconf_monitor_remove (storage_path);
+ g_free (storage_path);
storage_path = g_strdup (new_storage_path);
/* Start monitoring the new path */
@@ -1806,8 +1807,6 @@ nautilus_preferences_initialize (const char *path)
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
-#define CONSTANT_STORAGE_PATH "/apps/self-check-nautilus"
-
#define CHECK_BOOLEAN(name__, value__) \
G_STMT_START { \
nautilus_preferences_set_boolean ((name__), (value__)); \
@@ -1823,7 +1822,7 @@ G_STMT_START { \
#define CHECK_STRING(name__, value__) \
G_STMT_START { \
nautilus_preferences_set ((name__), (value__)); \
- EEL_CHECK_STRING_RESULT (nautilus_preferences_get (name__), (value__)); \
+ EEL_CHECK_STRING_RESULT (nautilus_preferences_get (name__), (value__)); \
} G_STMT_END
void
@@ -1839,8 +1838,12 @@ nautilus_self_check_preferences (void)
nautilus_preferences_set_user_level (0);
+ /* FIXME: Fails if you add the commented-out lines. */
+ /* CHECK_INTEGER ("self-check/i", 0); */
CHECK_INTEGER ("self-check/i", 666);
+ /* CHECK_BOOLEAN ("self-check/b", FALSE); */
CHECK_BOOLEAN ("self-check/b", TRUE);
+ /* CHECK_STRING ("self-check/s", ""); */
CHECK_STRING ("self-check/s", "foo");
/* Restore the original user level */
diff --git a/libnautilus-extensions/nautilus-thumbnails-jpeg.c b/libnautilus-extensions/nautilus-thumbnails-jpeg.c
new file mode 100644
index 000000000..fbe0ce036
--- /dev/null
+++ b/libnautilus-extensions/nautilus-thumbnails-jpeg.c
@@ -0,0 +1,224 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-thumbnails-jpeg.c: Fast loading of scaled jpeg images
+
+ Copyright (C) 2001 Red Hat Inc
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Alexander Larsson <alexl@redhat.com>
+*/
+
+#include <config.h>
+
+#ifdef HAVE_LIBJPEG
+
+#include "nautilus-thumbnails-jpeg.h"
+
+#include <eel/eel-glib-extensions.h>
+
+#include <stdio.h>
+#include <jpeglib.h>
+
+#include <libgnomevfs/gnome-vfs-types.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+
+#define BUFFER_SIZE 4096
+
+typedef struct {
+ struct jpeg_source_mgr pub; /* public fields */
+ GnomeVFSHandle *handle;
+ JOCTET buffer[BUFFER_SIZE];
+} Source;
+
+static void
+init_source (j_decompress_ptr cinfo)
+{
+}
+
+static gboolean
+fill_input_buffer (j_decompress_ptr cinfo)
+{
+ Source *src;
+ GnomeVFSFileSize nbytes;
+ GnomeVFSResult result;
+
+ src = (Source *) cinfo->src;
+ result = gnome_vfs_read (src->handle,
+ src->buffer,
+ EEL_N_ELEMENTS (src->buffer),
+ &nbytes);
+
+ if (result != GNOME_VFS_OK || nbytes == 0) {
+ /* return a fake EOI marker so we will eventually terminate */
+ src->buffer[0] = (JOCTET) 0xFF;
+ src->buffer[1] = (JOCTET) JPEG_EOI;
+ nbytes = 2;
+ }
+
+ src->pub.next_input_byte = src->buffer;
+ src->pub.bytes_in_buffer = nbytes;
+
+ return TRUE;
+}
+
+static void
+skip_input_data (j_decompress_ptr cinfo, long num_bytes)
+{
+ Source *src;
+
+ src = (Source *) cinfo->src;
+ if (num_bytes > 0) {
+ while (num_bytes > (long) src->pub.bytes_in_buffer) {
+ num_bytes -= (long) src->pub.bytes_in_buffer;
+ fill_input_buffer (cinfo);
+ }
+ src->pub.next_input_byte += (size_t) num_bytes;
+ src->pub.bytes_in_buffer -= (size_t) num_bytes;
+ }
+}
+
+static void
+term_source (j_decompress_ptr cinfo)
+{
+}
+
+static void
+vfs_src (j_decompress_ptr cinfo, GnomeVFSHandle *handle)
+{
+ Source *src;
+
+ if (cinfo->src == NULL) { /* first time for this JPEG object? */
+ cinfo->src = &(g_new (Source, 1))->pub;
+ }
+
+ src = (Source *) cinfo->src;
+ src->pub.init_source = init_source;
+ src->pub.fill_input_buffer = fill_input_buffer;
+ src->pub.skip_input_data = skip_input_data;
+ src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
+ src->pub.term_source = term_source;
+ src->handle = handle;
+ src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */
+ src->pub.next_input_byte = NULL; /* until buffer loaded */
+}
+
+static int
+calculate_divisor (int width,
+ int height,
+ int target_width,
+ int target_height)
+{
+ if (width/8 > target_width && height/8 > target_height) {
+ return 8;
+ }
+ if (width/4 > target_width && height/4 > target_height) {
+ return 4;
+ }
+ if (width/2 > target_width && height/2 > target_height) {
+ return 2;
+ }
+ return 1;
+}
+
+static void
+free_buffer (guchar *pixels, gpointer data)
+{
+ g_free (pixels);
+}
+
+GdkPixbuf *
+nautilus_thumbnail_load_scaled_jpeg (const char *uri,
+ int target_width,
+ int target_height)
+{
+ struct jpeg_decompress_struct cinfo;
+ struct jpeg_error_mgr jerr;
+ GnomeVFSHandle *handle;
+ unsigned char *lines[1];
+ guchar *buffer;
+ guchar *pixels, *ptr;
+ GnomeVFSResult result;
+ unsigned int i;
+
+ result = gnome_vfs_open (&handle,
+ uri,
+ GNOME_VFS_OPEN_READ);
+ if (result != GNOME_VFS_OK) {
+ return NULL;
+ }
+
+ cinfo.err = jpeg_std_error (&jerr);
+ jpeg_create_decompress (&cinfo);
+
+ vfs_src (&cinfo, handle);
+
+ jpeg_read_header (&cinfo, TRUE);
+
+ cinfo.scale_num = 1;
+ cinfo.scale_denom = calculate_divisor (cinfo.image_width,
+ cinfo.image_height,
+ target_width,
+ target_height);
+ cinfo.dct_method = JDCT_FASTEST;
+ cinfo.do_fancy_upsampling = FALSE;
+
+ jpeg_start_decompress (&cinfo);
+
+ pixels = g_malloc (cinfo.output_width * cinfo.output_height * 3);
+
+ ptr = pixels;
+ if (cinfo.num_components == 1) {
+ /* Allocate extra buffer for grayscale data */
+ buffer = g_malloc (cinfo.output_width);
+ lines[0] = buffer;
+ } else {
+ buffer = NULL;
+ lines[0] = pixels;
+ }
+
+ while (cinfo.output_scanline < cinfo.output_height) {
+ jpeg_read_scanlines (&cinfo, lines, 1);
+
+ if (cinfo.num_components == 1) {
+ /* Convert grayscale to rgb */
+ for (i = 0; i < cinfo.output_width; i++) {
+ ptr[i*3] = buffer[i];
+ ptr[i*3+1] = buffer[i];
+ ptr[i*3+2] = buffer[i];
+ }
+ ptr += cinfo.output_width * 3;
+ } else {
+ lines[0] += cinfo.output_width * 3;
+ }
+ }
+
+ g_free (buffer);
+
+ jpeg_finish_decompress (&cinfo);
+ jpeg_destroy_decompress (&cinfo);
+
+ gnome_vfs_close (handle);
+
+ return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, FALSE, 8,
+ cinfo.output_width,
+ cinfo.output_height,
+ cinfo.output_width * 3,
+ free_buffer, NULL);
+}
+
+#endif /* HAVE_LIBJPEG */
diff --git a/libnautilus-extensions/nautilus-thumbnails-jpeg.h b/libnautilus-extensions/nautilus-thumbnails-jpeg.h
new file mode 100644
index 000000000..a298b43e4
--- /dev/null
+++ b/libnautilus-extensions/nautilus-thumbnails-jpeg.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-thumbnails-jpeg.h: Fast loading of scaled jpeg images
+
+ Copyright (C) 2001 Red Hat, Inc
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Alexander Larsson <alexl@redhat.com>
+*/
+
+#ifndef NAUTILUS_THUMBNAILS_JPEG_H
+#define NAUTILUS_THUMBNAILS_JPEG_H
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+GdkPixbuf *nautilus_thumbnail_load_scaled_jpeg (const char *uri,
+ int target_width,
+ int target_heigh);
+
+#endif /* NAUTILUS_THUMBNAILS_JPEG_H */
diff --git a/libnautilus-extensions/nautilus-thumbnails.c b/libnautilus-extensions/nautilus-thumbnails.c
index 3ae99e7aa..7ef9e44c1 100644
--- a/libnautilus-extensions/nautilus-thumbnails.c
+++ b/libnautilus-extensions/nautilus-thumbnails.c
@@ -28,6 +28,7 @@
#include "nautilus-directory-notify.h"
#include "nautilus-icon-factory-private.h"
#include "nautilus-theme.h"
+#include "nautilus-thumbnails-jpeg.h"
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-graphic-effects.h>
#include <eel/eel-string.h>
@@ -593,9 +594,17 @@ make_thumbnails (gpointer data)
fclose (f);
}
}
+#ifdef HAVE_LIBJPEG
+ } else if (nautilus_file_is_mime_type (file, "image/jpeg")) {
+ if (info->thumbnail_uri != NULL) {
+ full_size_image = nautilus_thumbnail_load_scaled_jpeg
+ (info->thumbnail_uri, 96, 96);
+ }
+#endif
} else {
- if (info->thumbnail_uri != NULL)
- full_size_image = eel_gdk_pixbuf_load (info->thumbnail_uri);
+ if (info->thumbnail_uri != NULL) {
+ full_size_image = eel_gdk_pixbuf_load (info->thumbnail_uri);
+ }
}
nautilus_file_unref (file);
@@ -603,7 +612,7 @@ make_thumbnails (gpointer data)
thumbnail_image_frame = load_thumbnail_frame (info->anti_aliased);
/* scale the content image as necessary */
- scaled_image = eel_gdk_pixbuf_scale_down_to_fit(full_size_image, 96, 96);
+ scaled_image = eel_gdk_pixbuf_scale_down_to_fit (full_size_image, 96, 96);
gdk_pixbuf_unref (full_size_image);
/* embed the content image in the frame, if necessary */
@@ -611,15 +620,16 @@ make_thumbnails (gpointer data)
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);
+ 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 = eel_embed_image_in_frame (scaled_image, thumbnail_image_frame,
- left_offset, top_offset, right_offset, bottom_offset);
+ left_offset, top_offset, right_offset, bottom_offset);
g_free (frame_offset_str);
gdk_pixbuf_unref (scaled_image);
diff --git a/libnautilus-extensions/nautilus-volume-monitor.c b/libnautilus-extensions/nautilus-volume-monitor.c
index 21a557447..be73c78e5 100644
--- a/libnautilus-extensions/nautilus-volume-monitor.c
+++ b/libnautilus-extensions/nautilus-volume-monitor.c
@@ -113,7 +113,7 @@ char **broken_cdda_interface_h_workaround = strerror_tr;
#endif
-#define CHECK_STATUS_INTERVAL 4000
+#define CHECK_STATUS_INTERVAL 2000
#define FLOPPY_MOUNT_PATH_PREFIX "/mnt/fd"
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am
index 893350fcb..8446c4508 100644
--- a/libnautilus-private/Makefile.am
+++ b/libnautilus-private/Makefile.am
@@ -48,6 +48,7 @@ libnautilus_extensions_la_LDFLAGS = \
$(GNOMECANVASPIXBUF_LIBS) \
$(GNOME_LIBS) \
$(LIBPNG) \
+ $(LIBJPEG) \
$(MEDUSA_LIBS) \
$(OAF_LIBS) \
$(VFS_LIBS) \
@@ -117,6 +118,7 @@ libnautilus_extensions_la_SOURCES = \
nautilus-sound.c \
nautilus-theme.c \
nautilus-thumbnails.c \
+ nautilus-thumbnails-jpeg.c \
nautilus-trash-directory.c \
nautilus-trash-file.c \
nautilus-trash-monitor.c \
@@ -192,6 +194,7 @@ noinst_HEADERS = \
nautilus-sound.h \
nautilus-theme.h \
nautilus-thumbnails.h \
+ nautilus-thumbnails-jpeg.h \
nautilus-trash-directory.h \
nautilus-trash-file.h \
nautilus-trash-monitor.h \
diff --git a/libnautilus-private/nautilus-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c
index 44bd72dae..372a86c8f 100644
--- a/libnautilus-private/nautilus-icon-factory.c
+++ b/libnautilus-private/nautilus-icon-factory.c
@@ -1429,7 +1429,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
}
g_free (file_path);
- file_path = NULL;
}
g_free (directory);
g_free (desktop_directory);
@@ -1478,7 +1477,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
}
}
g_free (file_path);
- file_path = NULL;
}
}
@@ -1493,7 +1491,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
gnome_desktop_entry_free (entry);
}
g_free (file_path);
- file_path = NULL;
}
}
diff --git a/libnautilus-private/nautilus-preferences.c b/libnautilus-private/nautilus-preferences.c
index cd5ea51f4..41d0e7155 100644
--- a/libnautilus-private/nautilus-preferences.c
+++ b/libnautilus-private/nautilus-preferences.c
@@ -162,6 +162,7 @@ preferences_set_storage_path (const char *new_storage_path)
/* Stop monitoring the old path */
nautilus_gconf_monitor_remove (storage_path);
+ g_free (storage_path);
storage_path = g_strdup (new_storage_path);
/* Start monitoring the new path */
@@ -1806,8 +1807,6 @@ nautilus_preferences_initialize (const char *path)
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
-#define CONSTANT_STORAGE_PATH "/apps/self-check-nautilus"
-
#define CHECK_BOOLEAN(name__, value__) \
G_STMT_START { \
nautilus_preferences_set_boolean ((name__), (value__)); \
@@ -1823,7 +1822,7 @@ G_STMT_START { \
#define CHECK_STRING(name__, value__) \
G_STMT_START { \
nautilus_preferences_set ((name__), (value__)); \
- EEL_CHECK_STRING_RESULT (nautilus_preferences_get (name__), (value__)); \
+ EEL_CHECK_STRING_RESULT (nautilus_preferences_get (name__), (value__)); \
} G_STMT_END
void
@@ -1839,8 +1838,12 @@ nautilus_self_check_preferences (void)
nautilus_preferences_set_user_level (0);
+ /* FIXME: Fails if you add the commented-out lines. */
+ /* CHECK_INTEGER ("self-check/i", 0); */
CHECK_INTEGER ("self-check/i", 666);
+ /* CHECK_BOOLEAN ("self-check/b", FALSE); */
CHECK_BOOLEAN ("self-check/b", TRUE);
+ /* CHECK_STRING ("self-check/s", ""); */
CHECK_STRING ("self-check/s", "foo");
/* Restore the original user level */
diff --git a/libnautilus-private/nautilus-thumbnails-jpeg.c b/libnautilus-private/nautilus-thumbnails-jpeg.c
new file mode 100644
index 000000000..fbe0ce036
--- /dev/null
+++ b/libnautilus-private/nautilus-thumbnails-jpeg.c
@@ -0,0 +1,224 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-thumbnails-jpeg.c: Fast loading of scaled jpeg images
+
+ Copyright (C) 2001 Red Hat Inc
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Alexander Larsson <alexl@redhat.com>
+*/
+
+#include <config.h>
+
+#ifdef HAVE_LIBJPEG
+
+#include "nautilus-thumbnails-jpeg.h"
+
+#include <eel/eel-glib-extensions.h>
+
+#include <stdio.h>
+#include <jpeglib.h>
+
+#include <libgnomevfs/gnome-vfs-types.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+
+#define BUFFER_SIZE 4096
+
+typedef struct {
+ struct jpeg_source_mgr pub; /* public fields */
+ GnomeVFSHandle *handle;
+ JOCTET buffer[BUFFER_SIZE];
+} Source;
+
+static void
+init_source (j_decompress_ptr cinfo)
+{
+}
+
+static gboolean
+fill_input_buffer (j_decompress_ptr cinfo)
+{
+ Source *src;
+ GnomeVFSFileSize nbytes;
+ GnomeVFSResult result;
+
+ src = (Source *) cinfo->src;
+ result = gnome_vfs_read (src->handle,
+ src->buffer,
+ EEL_N_ELEMENTS (src->buffer),
+ &nbytes);
+
+ if (result != GNOME_VFS_OK || nbytes == 0) {
+ /* return a fake EOI marker so we will eventually terminate */
+ src->buffer[0] = (JOCTET) 0xFF;
+ src->buffer[1] = (JOCTET) JPEG_EOI;
+ nbytes = 2;
+ }
+
+ src->pub.next_input_byte = src->buffer;
+ src->pub.bytes_in_buffer = nbytes;
+
+ return TRUE;
+}
+
+static void
+skip_input_data (j_decompress_ptr cinfo, long num_bytes)
+{
+ Source *src;
+
+ src = (Source *) cinfo->src;
+ if (num_bytes > 0) {
+ while (num_bytes > (long) src->pub.bytes_in_buffer) {
+ num_bytes -= (long) src->pub.bytes_in_buffer;
+ fill_input_buffer (cinfo);
+ }
+ src->pub.next_input_byte += (size_t) num_bytes;
+ src->pub.bytes_in_buffer -= (size_t) num_bytes;
+ }
+}
+
+static void
+term_source (j_decompress_ptr cinfo)
+{
+}
+
+static void
+vfs_src (j_decompress_ptr cinfo, GnomeVFSHandle *handle)
+{
+ Source *src;
+
+ if (cinfo->src == NULL) { /* first time for this JPEG object? */
+ cinfo->src = &(g_new (Source, 1))->pub;
+ }
+
+ src = (Source *) cinfo->src;
+ src->pub.init_source = init_source;
+ src->pub.fill_input_buffer = fill_input_buffer;
+ src->pub.skip_input_data = skip_input_data;
+ src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
+ src->pub.term_source = term_source;
+ src->handle = handle;
+ src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */
+ src->pub.next_input_byte = NULL; /* until buffer loaded */
+}
+
+static int
+calculate_divisor (int width,
+ int height,
+ int target_width,
+ int target_height)
+{
+ if (width/8 > target_width && height/8 > target_height) {
+ return 8;
+ }
+ if (width/4 > target_width && height/4 > target_height) {
+ return 4;
+ }
+ if (width/2 > target_width && height/2 > target_height) {
+ return 2;
+ }
+ return 1;
+}
+
+static void
+free_buffer (guchar *pixels, gpointer data)
+{
+ g_free (pixels);
+}
+
+GdkPixbuf *
+nautilus_thumbnail_load_scaled_jpeg (const char *uri,
+ int target_width,
+ int target_height)
+{
+ struct jpeg_decompress_struct cinfo;
+ struct jpeg_error_mgr jerr;
+ GnomeVFSHandle *handle;
+ unsigned char *lines[1];
+ guchar *buffer;
+ guchar *pixels, *ptr;
+ GnomeVFSResult result;
+ unsigned int i;
+
+ result = gnome_vfs_open (&handle,
+ uri,
+ GNOME_VFS_OPEN_READ);
+ if (result != GNOME_VFS_OK) {
+ return NULL;
+ }
+
+ cinfo.err = jpeg_std_error (&jerr);
+ jpeg_create_decompress (&cinfo);
+
+ vfs_src (&cinfo, handle);
+
+ jpeg_read_header (&cinfo, TRUE);
+
+ cinfo.scale_num = 1;
+ cinfo.scale_denom = calculate_divisor (cinfo.image_width,
+ cinfo.image_height,
+ target_width,
+ target_height);
+ cinfo.dct_method = JDCT_FASTEST;
+ cinfo.do_fancy_upsampling = FALSE;
+
+ jpeg_start_decompress (&cinfo);
+
+ pixels = g_malloc (cinfo.output_width * cinfo.output_height * 3);
+
+ ptr = pixels;
+ if (cinfo.num_components == 1) {
+ /* Allocate extra buffer for grayscale data */
+ buffer = g_malloc (cinfo.output_width);
+ lines[0] = buffer;
+ } else {
+ buffer = NULL;
+ lines[0] = pixels;
+ }
+
+ while (cinfo.output_scanline < cinfo.output_height) {
+ jpeg_read_scanlines (&cinfo, lines, 1);
+
+ if (cinfo.num_components == 1) {
+ /* Convert grayscale to rgb */
+ for (i = 0; i < cinfo.output_width; i++) {
+ ptr[i*3] = buffer[i];
+ ptr[i*3+1] = buffer[i];
+ ptr[i*3+2] = buffer[i];
+ }
+ ptr += cinfo.output_width * 3;
+ } else {
+ lines[0] += cinfo.output_width * 3;
+ }
+ }
+
+ g_free (buffer);
+
+ jpeg_finish_decompress (&cinfo);
+ jpeg_destroy_decompress (&cinfo);
+
+ gnome_vfs_close (handle);
+
+ return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, FALSE, 8,
+ cinfo.output_width,
+ cinfo.output_height,
+ cinfo.output_width * 3,
+ free_buffer, NULL);
+}
+
+#endif /* HAVE_LIBJPEG */
diff --git a/libnautilus-private/nautilus-thumbnails-jpeg.h b/libnautilus-private/nautilus-thumbnails-jpeg.h
new file mode 100644
index 000000000..a298b43e4
--- /dev/null
+++ b/libnautilus-private/nautilus-thumbnails-jpeg.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-thumbnails-jpeg.h: Fast loading of scaled jpeg images
+
+ Copyright (C) 2001 Red Hat, Inc
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Alexander Larsson <alexl@redhat.com>
+*/
+
+#ifndef NAUTILUS_THUMBNAILS_JPEG_H
+#define NAUTILUS_THUMBNAILS_JPEG_H
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+GdkPixbuf *nautilus_thumbnail_load_scaled_jpeg (const char *uri,
+ int target_width,
+ int target_heigh);
+
+#endif /* NAUTILUS_THUMBNAILS_JPEG_H */
diff --git a/libnautilus-private/nautilus-thumbnails.c b/libnautilus-private/nautilus-thumbnails.c
index 3ae99e7aa..7ef9e44c1 100644
--- a/libnautilus-private/nautilus-thumbnails.c
+++ b/libnautilus-private/nautilus-thumbnails.c
@@ -28,6 +28,7 @@
#include "nautilus-directory-notify.h"
#include "nautilus-icon-factory-private.h"
#include "nautilus-theme.h"
+#include "nautilus-thumbnails-jpeg.h"
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-graphic-effects.h>
#include <eel/eel-string.h>
@@ -593,9 +594,17 @@ make_thumbnails (gpointer data)
fclose (f);
}
}
+#ifdef HAVE_LIBJPEG
+ } else if (nautilus_file_is_mime_type (file, "image/jpeg")) {
+ if (info->thumbnail_uri != NULL) {
+ full_size_image = nautilus_thumbnail_load_scaled_jpeg
+ (info->thumbnail_uri, 96, 96);
+ }
+#endif
} else {
- if (info->thumbnail_uri != NULL)
- full_size_image = eel_gdk_pixbuf_load (info->thumbnail_uri);
+ if (info->thumbnail_uri != NULL) {
+ full_size_image = eel_gdk_pixbuf_load (info->thumbnail_uri);
+ }
}
nautilus_file_unref (file);
@@ -603,7 +612,7 @@ make_thumbnails (gpointer data)
thumbnail_image_frame = load_thumbnail_frame (info->anti_aliased);
/* scale the content image as necessary */
- scaled_image = eel_gdk_pixbuf_scale_down_to_fit(full_size_image, 96, 96);
+ scaled_image = eel_gdk_pixbuf_scale_down_to_fit (full_size_image, 96, 96);
gdk_pixbuf_unref (full_size_image);
/* embed the content image in the frame, if necessary */
@@ -611,15 +620,16 @@ make_thumbnails (gpointer data)
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);
+ 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 = eel_embed_image_in_frame (scaled_image, thumbnail_image_frame,
- left_offset, top_offset, right_offset, bottom_offset);
+ left_offset, top_offset, right_offset, bottom_offset);
g_free (frame_offset_str);
gdk_pixbuf_unref (scaled_image);
diff --git a/libnautilus-private/nautilus-volume-monitor.c b/libnautilus-private/nautilus-volume-monitor.c
index 21a557447..be73c78e5 100644
--- a/libnautilus-private/nautilus-volume-monitor.c
+++ b/libnautilus-private/nautilus-volume-monitor.c
@@ -113,7 +113,7 @@ char **broken_cdda_interface_h_workaround = strerror_tr;
#endif
-#define CHECK_STATUS_INTERVAL 4000
+#define CHECK_STATUS_INTERVAL 2000
#define FLOPPY_MOUNT_PATH_PREFIX "/mnt/fd"