Index: nautilus-file-management-properties.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-file-management-properties.c,v
retrieving revision 1.16
diff -u -p -r1.16 nautilus-file-management-properties.c
--- nautilus-file-management-properties.c	16 Jul 2004 12:04:29 -0000	1.16
+++ nautilus-file-management-properties.c	15 Jan 2005 01:50:30 -0000
@@ -20,6 +20,7 @@
    Boston, MA 02111-1307, USA.
 
    Authors: Jan Arne Petersen <jpetersen@uni-bonn.de>
+            John Spray <spray_john@users.sourceforge.net>
 */
 
 #include <config.h>
@@ -36,6 +37,13 @@
 #include <gtk/gtkicontheme.h>
 #include <gtk/gtkoptionmenu.h>
 #include <gtk/gtksizegroup.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkstock.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkprogressbar.h>
+
+#include <libgnomevfs/gnome-vfs.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include <libgnome/gnome-help.h>
 #include <libgnome/gnome-i18n.h>
@@ -161,6 +169,308 @@ static const char *icon_captions_compone
 	NULL
 };
 
+static int thumb_filesprocessed = 0;
+static int thumb_filesunlinked = 0;
+static int thumb_totalfiles = 0;
+static GtkWidget *thumbprogress = NULL;
+static gboolean thumb_cancelflag;
+
+
+/*Read the PNG metadata of a file, look for tEXt:Thumb:URI field
+ *and return TRUE if the field is not found or the file that
+ *it points to is not found.*/
+static gboolean
+thumb_is_stale (GnomeVFSURI *uri)
+{
+	GdkPixbuf *pixbuf;
+	gchar *thumb_targetstring;
+	gchar *filename;
+	const gchar *scheme;
+	GnomeVFSURI *target_uri;
+	gboolean is_stale = FALSE;
+	static int notagcount = 5;
+
+	filename = g_strdup (uri->text);
+	pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+	g_free (filename);
+
+	if (pixbuf) {
+		thumb_targetstring = g_strdup (gdk_pixbuf_get_option(pixbuf,
+		                               "tEXt::Thumb::URI"));
+
+		if (!thumb_targetstring) {
+			if( notagcount > 0 ) {
+				g_warning ("%s does not have property text::thumb::uri"\
+					"\n\tAssuming stale, deleting anyway!", uri->text);
+				notagcount--;
+			} else if (notagcount == 0) {
+				g_warning ("Suppressing further warnings about thumbs"\
+					"with no text::thumb::uri metadata.\n");
+				notagcount = -1;
+			}
+			return TRUE;
+		}
+
+		target_uri = gnome_vfs_uri_new (thumb_targetstring);
+
+		scheme = gnome_vfs_uri_get_scheme (target_uri);
+
+		if (g_strstr_len (scheme, strlen (scheme), "file"))
+			if (!gnome_vfs_uri_exists (target_uri))
+				is_stale = TRUE;
+
+		gnome_vfs_uri_unref (target_uri);
+
+		g_object_unref (pixbuf);
+
+		g_free (thumb_targetstring);
+	}
+	else
+		g_warning ("Failed to open %s to check for staleness\n", filename);
+
+	return is_stale;
+}
+
+/*Act on each file examined in the recursion.
+ *	-If it's a png, judge it
+ *	-If it's a directory, descend into it*/
+static gboolean
+thumb_recurseclean (const gchar *rel_path,
+                    GnomeVFSFileInfo *info,
+                    gboolean recursing_will_loop,
+                    gpointer data,
+                    gboolean *recurse)
+{
+	gchar *basedir=data;
+	gchar *fullname;
+	GnomeVFSURI *uri;
+	static int eventscounter = 0;
+	const int eventscountermax = 20;
+
+	fullname = g_build_filename (basedir, info->name, NULL);
+	if (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+		gnome_vfs_directory_visit (fullname,
+			GNOME_VFS_FILE_INFO_GET_MIME_TYPE,
+			GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK,
+			thumb_recurseclean, fullname);
+	} else {
+		thumb_filesprocessed++;
+		if (g_strrstr (info->mime_type, "image/png")) {
+			uri = gnome_vfs_uri_new (fullname);
+			if (thumb_is_stale (uri)) {
+				gnome_vfs_unlink_from_uri (uri);
+				thumb_filesunlinked++;
+			}
+			gnome_vfs_uri_unref (uri);
+		}
+		else {
+			/* What about these .info files I see in my .thumbnails?
+			 * Don't know who makes them.  Would be nice to tidy
+			 * them away, but they don't take up much space so
+			 * might as well let them stay*/
+		}
+	}
+	g_free (fullname);
+
+	eventscounter++;
+	if (eventscounter == eventscountermax) {
+		eventscounter = 0;
+		gtk_progress_bar_set_fraction (
+			GTK_PROGRESS_BAR (thumbprogress),
+			(double)thumb_filesprocessed / (double)thumb_totalfiles);
+		gchar *progresstext = g_strdup_printf (
+			_("%d of %d thumbnails checked"),
+			thumb_filesprocessed,
+			thumb_totalfiles);
+		gtk_progress_bar_set_text (
+			GTK_PROGRESS_BAR (thumbprogress),
+			progresstext);
+		g_free (progresstext);
+		while (gtk_events_pending ())
+			gtk_main_iteration ();
+	}
+
+
+	return !thumb_cancelflag;
+}
+
+/*Act on each file examined in the recursion.
+ *	-If it's a png file, unlink it
+ *	-If it's a directory, descend into it*/
+static gboolean
+thumb_recurseempty (const gchar *rel_path,
+                    GnomeVFSFileInfo *info,
+                    gboolean recursing_will_loop,
+                    gpointer data,
+                    gboolean *recurse)
+{
+	gchar *basedir = data;
+	gchar *fullname;
+	GnomeVFSURI *uri;
+
+	fullname = g_build_filename (basedir, info->name, NULL);
+	if (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+		gnome_vfs_directory_visit (fullname,
+			GNOME_VFS_FILE_INFO_GET_MIME_TYPE,
+			GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK,
+			thumb_recurseempty, fullname);
+	}
+	else {
+		if (g_strrstr (info->mime_type, "image/png")) {
+			uri = gnome_vfs_uri_new (fullname);
+			gnome_vfs_unlink_from_uri (uri);
+			thumb_filesunlinked++;
+			gnome_vfs_uri_unref (uri);
+		}
+	}
+	g_free (fullname);
+
+	return TRUE;
+}
+
+/*Act on each file examined in the recursion.
+ *	-If it's a file, increment thumb_totalfiles
+ *	-If it's a directory, descend into it*/
+static gboolean
+thumb_recursecount (const gchar *rel_path,
+                    GnomeVFSFileInfo *info,
+                    gboolean recursing_will_loop,
+                    gpointer data,
+                    gboolean *recurse)
+{
+	gchar *basedir = data;
+	gchar *fullname;
+
+	fullname = g_build_filename (basedir, info->name, NULL);
+	if (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+		gnome_vfs_directory_visit (fullname,
+			GNOME_VFS_FILE_INFO_GET_MIME_TYPE,
+			GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK,
+			thumb_recursecount, fullname);
+	}
+	else {
+		++thumb_totalfiles;
+	}
+	return TRUE;
+}
+
+/* Callback for the delete signal of the thumb_cleanup progress dialog,
+ * and the clicked signal of the dialog's cancel button */
+static void
+thumb_cancel_cb (GtkWidget *widget, gpointer data)
+{
+	thumb_cancelflag = TRUE;
+}
+
+/* Recurse through ~/.thumbnails and delete all png files that
+ * do not have a Thumb:URI metadata field that points to an
+ * existing file.*/
+static void
+thumb_cleanup (gpointer widget,gpointer data)
+{
+	gchar *thumb_dir;
+	gchar *thumb_dir_uristr;
+
+	thumb_dir = g_build_filename (g_get_home_dir(), ".thumbnails", NULL);
+	thumb_dir_uristr = g_strdup_printf ("file://%s", thumb_dir);
+
+	g_free (thumb_dir);
+
+	/* A modal dialog to update the user on progress as we 
+	 * go through .thumbnails, which takes a while */
+	GtkWidget *dialog = gtk_dialog_new_with_buttons (
+		_("Cleaning up thumbnails"),
+		NULL,
+		GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
+		NULL);
+	g_signal_connect (G_OBJECT (dialog),
+	                  "delete-event",
+	                  G_CALLBACK (thumb_cancel_cb),
+	                  NULL);
+
+	GtkWidget *cancelbutton = gtk_dialog_add_button (
+		GTK_DIALOG (dialog),
+		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+	g_signal_connect (G_OBJECT (cancelbutton),
+	                  "clicked",
+	                  G_CALLBACK (thumb_cancel_cb),
+	                  NULL);
+
+	GtkWidget *vbox = GTK_DIALOG (dialog)->vbox;
+	// This call needed to set border width because widget not yet realized
+	gtk_widget_ensure_style(dialog);
+	gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+	GtkWidget *label = gtk_label_new ("");
+	// Keeping translatable and non-translatable separate
+	gchar *maintext = g_strconcat (
+		"<span size=\"larger\" weight=\"bold\">",
+		_("Cleaning up thumbnails"),
+		"</span>\n\n",
+		_("The thumbnail cache is now being examined, and unneeded\n"
+		"thumbnails are being deleted.  You may cancel this process\n"
+		"at any time."), "\n", NULL);
+	gtk_label_set_markup (GTK_LABEL (label), maintext);
+	g_free (maintext);
+	gtk_box_pack_start_defaults (GTK_BOX (vbox), label);
+
+	GtkWidget *progress = gtk_progress_bar_new ();
+	gtk_box_pack_start_defaults (GTK_BOX (vbox), progress);
+	thumbprogress = progress;
+
+	gtk_widget_show_all (dialog);
+	while (gtk_events_pending ())
+		gtk_main_iteration ();
+		
+	thumb_totalfiles = 0;
+
+	// Count the files in ~/.thumbnails, so that we can show the user
+	// our progress
+	gnome_vfs_directory_visit (thumb_dir_uristr,
+		GNOME_VFS_FILE_INFO_GET_MIME_TYPE,
+		GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK,
+		thumb_recursecount, thumb_dir_uristr);
+
+	thumb_cancelflag = FALSE;
+
+	gnome_vfs_directory_visit (thumb_dir_uristr,
+		GNOME_VFS_FILE_INFO_GET_MIME_TYPE,
+		GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK,
+		thumb_recurseclean, thumb_dir_uristr);
+
+	gtk_widget_destroy (dialog);
+
+	g_free (thumb_dir_uristr);
+
+	g_message ("%d thumbnail files checked for staleness, %d deleted.",
+		thumb_filesprocessed, thumb_filesunlinked);
+	thumb_filesprocessed = thumb_filesunlinked = 0;
+}
+
+/* Recurse through ~/.thumbnails and delete all png files*/
+static void
+thumb_empty (gpointer widget, gpointer data)
+{
+	gchar *thumb_dir;
+	gchar *thumb_dir_uristr;
+
+	thumb_dir = g_build_filename (g_get_home_dir (), ".thumbnails", NULL);
+	thumb_dir_uristr = g_strdup_printf ("file://%s", thumb_dir);
+
+	g_free (thumb_dir);
+
+	// This should take <1s, so no progress ui needed
+	gnome_vfs_directory_visit (thumb_dir_uristr,
+		GNOME_VFS_FILE_INFO_GET_MIME_TYPE,
+		GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK,
+		thumb_recurseempty, thumb_dir_uristr);
+
+	g_free (thumb_dir_uristr);
+
+	g_message ("%d files deleted.", thumb_filesunlinked);
+	thumb_filesunlinked = 0;
+}
+
 static GladeXML *
 nautilus_file_management_properties_dialog_create (void)
 {
@@ -665,6 +975,12 @@ nautilus_file_management_properties_dial
 	g_signal_connect (G_OBJECT (dialog), "response",
 			  G_CALLBACK (nautilus_file_management_properties_dialog_response_cb),
 			  xml_dialog);
+
+	g_signal_connect (G_OBJECT (glade_xml_get_widget (xml_dialog, "preview_cleanup_button")),
+	  "clicked", G_CALLBACK(thumb_cleanup), glade_xml_get_widget (xml_dialog, "file_management_dialog"));
+
+ 	g_signal_connect (G_OBJECT (glade_xml_get_widget (xml_dialog, "preview_empty_button")),
+	  "clicked", G_CALLBACK(thumb_empty), glade_xml_get_widget (xml_dialog, "file_management_dialog"));
 
 	nautilus_file_management_properties_dialog_set_icons (GTK_WINDOW (dialog));
 
Index: nautilus-file-management-properties.glade
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-file-management-properties.glade,v
retrieving revision 1.14
diff -u -p -r1.14 nautilus-file-management-properties.glade
--- nautilus-file-management-properties.glade	12 Oct 2004 21:54:28 -0000	1.14
+++ nautilus-file-management-properties.glade	15 Jan 2005 01:50:31 -0000
@@ -2315,15 +2315,15 @@
 	      </child>
 
 	      <child>
-		<widget class="GtkVBox" id="vbox11">
+		<widget class="GtkVBox" id="vbox12">
 		  <property name="visible">True</property>
 		  <property name="homogeneous">False</property>
 		  <property name="spacing">6</property>
 
 		  <child>
-		    <widget class="GtkLabel" id="label18">
+		    <widget class="GtkLabel" id="label20">
 		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot;&gt;Other Previewable Files&lt;/span&gt;</property>
+		      <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot;&gt;Sound Files&lt;/span&gt;</property>
 		      <property name="use_underline">False</property>
 		      <property name="use_markup">True</property>
 		      <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -2342,13 +2342,13 @@
 		  </child>
 
 		  <child>
-		    <widget class="GtkHBox" id="hbox8">
+		    <widget class="GtkHBox" id="hbox9">
 		      <property name="visible">True</property>
 		      <property name="homogeneous">False</property>
 		      <property name="spacing">0</property>
 
 		      <child>
-			<widget class="GtkLabel" id="label19">
+			<widget class="GtkLabel" id="label21">
 			  <property name="visible">True</property>
 			  <property name="label" translatable="yes">    </property>
 			  <property name="use_underline">False</property>
@@ -2369,21 +2369,21 @@
 		      </child>
 
 		      <child>
-			<widget class="GtkVBox" id="vbox21">
+			<widget class="GtkVBox" id="vbox22">
 			  <property name="visible">True</property>
 			  <property name="homogeneous">False</property>
 			  <property name="spacing">6</property>
 
 			  <child>
-			    <widget class="GtkHBox" id="hbox20">
+			    <widget class="GtkHBox" id="hbox22">
 			      <property name="visible">True</property>
 			      <property name="homogeneous">False</property>
 			      <property name="spacing">12</property>
 
 			      <child>
-				<widget class="GtkLabel" id="preview_label_1">
+				<widget class="GtkLabel" id="preview_label_3">
 				  <property name="visible">True</property>
-				  <property name="label" translatable="yes">Show _thumbnails:</property>
+				  <property name="label" translatable="yes">Preview _sound files:</property>
 				  <property name="use_underline">True</property>
 				  <property name="use_markup">False</property>
 				  <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -2393,7 +2393,7 @@
 				  <property name="yalign">0.5</property>
 				  <property name="xpad">0</property>
 				  <property name="ypad">0</property>
-				  <property name="mnemonic_widget">preview_image_optionmenu</property>
+				  <property name="mnemonic_widget">preview_sound_optionmenu</property>
 				</widget>
 				<packing>
 				  <property name="padding">0</property>
@@ -2403,16 +2403,16 @@
 			      </child>
 
 			      <child>
-				<widget class="GtkOptionMenu" id="preview_image_optionmenu">
+				<widget class="GtkOptionMenu" id="preview_sound_optionmenu">
 				  <property name="visible">True</property>
 				  <property name="can_focus">True</property>
 				  <property name="history">0</property>
 
 				  <child>
-				    <widget class="GtkMenu" id="menu10">
+				    <widget class="GtkMenu" id="menu12">
 
 				      <child>
-					<widget class="GtkMenuItem" id="always2">
+					<widget class="GtkMenuItem" id="always3">
 					  <property name="visible">True</property>
 					  <property name="label" translatable="yes">Always</property>
 					  <property name="use_underline">True</property>
@@ -2420,7 +2420,7 @@
 				      </child>
 
 				      <child>
-					<widget class="GtkMenuItem" id="local_files_only2">
+					<widget class="GtkMenuItem" id="local_files_only3">
 					  <property name="visible">True</property>
 					  <property name="label" translatable="yes">Local Files Only</property>
 					  <property name="use_underline">True</property>
@@ -2428,7 +2428,7 @@
 				      </child>
 
 				      <child>
-					<widget class="GtkMenuItem" id="never2">
+					<widget class="GtkMenuItem" id="never3">
 					  <property name="visible">True</property>
 					  <property name="label" translatable="yes">Never</property>
 					  <property name="use_underline">True</property>
@@ -2450,123 +2450,6 @@
 			      <property name="fill">True</property>
 			    </packing>
 			  </child>
-
-			  <child>
-			    <widget class="GtkHBox" id="hbox21">
-			      <property name="visible">True</property>
-			      <property name="homogeneous">False</property>
-			      <property name="spacing">12</property>
-
-			      <child>
-				<widget class="GtkLabel" id="preview_label_2">
-				  <property name="visible">True</property>
-				  <property name="label" translatable="yes">_Only for files smaller than:</property>
-				  <property name="use_underline">True</property>
-				  <property name="use_markup">False</property>
-				  <property name="justify">GTK_JUSTIFY_LEFT</property>
-				  <property name="wrap">False</property>
-				  <property name="selectable">False</property>
-				  <property name="xalign">0</property>
-				  <property name="yalign">0.5</property>
-				  <property name="xpad">0</property>
-				  <property name="ypad">0</property>
-				  <property name="mnemonic_widget">preview_image_size_optionmenu</property>
-				</widget>
-				<packing>
-				  <property name="padding">0</property>
-				  <property name="expand">False</property>
-				  <property name="fill">False</property>
-				</packing>
-			      </child>
-
-			      <child>
-				<widget class="GtkOptionMenu" id="preview_image_size_optionmenu">
-				  <property name="visible">True</property>
-				  <property name="can_focus">True</property>
-				  <property name="history">0</property>
-
-				  <child>
-				    <widget class="GtkMenu" id="menu11">
-
-				      <child>
-					<widget class="GtkMenuItem" id="100_k1">
-					  <property name="visible">True</property>
-					  <property name="label" translatable="yes">100 KB</property>
-					  <property name="use_underline">True</property>
-					</widget>
-				      </child>
-
-				      <child>
-					<widget class="GtkMenuItem" id="500_k1">
-					  <property name="visible">True</property>
-					  <property name="label" translatable="yes">500 KB</property>
-					  <property name="use_underline">True</property>
-					</widget>
-				      </child>
-
-				      <child>
-					<widget class="GtkMenuItem" id="1_mb1">
-					  <property name="visible">True</property>
-					  <property name="label" translatable="yes">1 MB</property>
-					  <property name="use_underline">True</property>
-					</widget>
-				      </child>
-
-				      <child>
-					<widget class="GtkMenuItem" id="3_mb1">
-					  <property name="visible">True</property>
-					  <property name="label" translatable="yes">3 MB</property>
-					  <property name="use_underline">True</property>
-					</widget>
-				      </child>
-
-				      <child>
-					<widget class="GtkMenuItem" id="5_mb1">
-					  <property name="visible">True</property>
-					  <property name="label" translatable="yes">5 MB</property>
-					  <property name="use_underline">True</property>
-					</widget>
-				      </child>
-
-				      <child>
-					<widget class="GtkMenuItem" id="10_mb1">
-					  <property name="visible">True</property>
-					  <property name="label" translatable="yes">10 MB</property>
-					  <property name="use_underline">True</property>
-					</widget>
-				      </child>
-
-				      <child>
-					<widget class="GtkMenuItem" id="100_mb1">
-					  <property name="visible">True</property>
-					  <property name="label" translatable="yes">100 MB</property>
-					  <property name="use_underline">True</property>
-					</widget>
-				      </child>
-
-				      <child>
-					<widget class="GtkMenuItem" id="1_gb1">
-					  <property name="visible">True</property>
-					  <property name="label" translatable="yes">1 GB</property>
-					  <property name="use_underline">True</property>
-					</widget>
-				      </child>
-				    </widget>
-				  </child>
-				</widget>
-				<packing>
-				  <property name="padding">0</property>
-				  <property name="expand">True</property>
-				  <property name="fill">True</property>
-				</packing>
-			      </child>
-			    </widget>
-			    <packing>
-			      <property name="padding">0</property>
-			      <property name="expand">True</property>
-			      <property name="fill">True</property>
-			    </packing>
-			  </child>
 			</widget>
 			<packing>
 			  <property name="padding">0</property>
@@ -2590,15 +2473,15 @@
 	      </child>
 
 	      <child>
-		<widget class="GtkVBox" id="vbox12">
+		<widget class="GtkVBox" id="vbox13">
 		  <property name="visible">True</property>
 		  <property name="homogeneous">False</property>
 		  <property name="spacing">6</property>
 
 		  <child>
-		    <widget class="GtkLabel" id="label20">
+		    <widget class="GtkLabel" id="label22">
 		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot;&gt;Sound Files&lt;/span&gt;</property>
+		      <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot;&gt;Folders&lt;/span&gt;</property>
 		      <property name="use_underline">False</property>
 		      <property name="use_markup">True</property>
 		      <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -2617,13 +2500,13 @@
 		  </child>
 
 		  <child>
-		    <widget class="GtkHBox" id="hbox9">
+		    <widget class="GtkHBox" id="hbox10">
 		      <property name="visible">True</property>
 		      <property name="homogeneous">False</property>
 		      <property name="spacing">0</property>
 
 		      <child>
-			<widget class="GtkLabel" id="label21">
+			<widget class="GtkLabel" id="label23">
 			  <property name="visible">True</property>
 			  <property name="label" translatable="yes">    </property>
 			  <property name="use_underline">False</property>
@@ -2644,21 +2527,21 @@
 		      </child>
 
 		      <child>
-			<widget class="GtkVBox" id="vbox22">
+			<widget class="GtkVBox" id="vbox23">
 			  <property name="visible">True</property>
 			  <property name="homogeneous">False</property>
 			  <property name="spacing">6</property>
 
 			  <child>
-			    <widget class="GtkHBox" id="hbox22">
+			    <widget class="GtkHBox" id="hbox23">
 			      <property name="visible">True</property>
 			      <property name="homogeneous">False</property>
 			      <property name="spacing">12</property>
 
 			      <child>
-				<widget class="GtkLabel" id="preview_label_3">
+				<widget class="GtkLabel" id="preview_label_4">
 				  <property name="visible">True</property>
-				  <property name="label" translatable="yes">Preview _sound files:</property>
+				  <property name="label" translatable="yes">Count _number of items:</property>
 				  <property name="use_underline">True</property>
 				  <property name="use_markup">False</property>
 				  <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -2668,7 +2551,7 @@
 				  <property name="yalign">0.5</property>
 				  <property name="xpad">0</property>
 				  <property name="ypad">0</property>
-				  <property name="mnemonic_widget">preview_sound_optionmenu</property>
+				  <property name="mnemonic_widget">preview_folder_optionmenu</property>
 				</widget>
 				<packing>
 				  <property name="padding">0</property>
@@ -2678,16 +2561,16 @@
 			      </child>
 
 			      <child>
-				<widget class="GtkOptionMenu" id="preview_sound_optionmenu">
+				<widget class="GtkOptionMenu" id="preview_folder_optionmenu">
 				  <property name="visible">True</property>
 				  <property name="can_focus">True</property>
 				  <property name="history">0</property>
 
 				  <child>
-				    <widget class="GtkMenu" id="menu12">
+				    <widget class="GtkMenu" id="menu13">
 
 				      <child>
-					<widget class="GtkMenuItem" id="always3">
+					<widget class="GtkMenuItem" id="always4">
 					  <property name="visible">True</property>
 					  <property name="label" translatable="yes">Always</property>
 					  <property name="use_underline">True</property>
@@ -2695,7 +2578,7 @@
 				      </child>
 
 				      <child>
-					<widget class="GtkMenuItem" id="local_files_only3">
+					<widget class="GtkMenuItem" id="local_files_only4">
 					  <property name="visible">True</property>
 					  <property name="label" translatable="yes">Local Files Only</property>
 					  <property name="use_underline">True</property>
@@ -2703,7 +2586,7 @@
 				      </child>
 
 				      <child>
-					<widget class="GtkMenuItem" id="never3">
+					<widget class="GtkMenuItem" id="never4">
 					  <property name="visible">True</property>
 					  <property name="label" translatable="yes">Never</property>
 					  <property name="use_underline">True</property>
@@ -2748,15 +2631,15 @@
 	      </child>
 
 	      <child>
-		<widget class="GtkVBox" id="vbox13">
+		<widget class="GtkVBox" id="vbox11">
 		  <property name="visible">True</property>
 		  <property name="homogeneous">False</property>
 		  <property name="spacing">6</property>
 
 		  <child>
-		    <widget class="GtkLabel" id="label22">
+		    <widget class="GtkLabel" id="label18">
 		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot;&gt;Folders&lt;/span&gt;</property>
+		      <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot;&gt;Other Previewable Files&lt;/span&gt;</property>
 		      <property name="use_underline">False</property>
 		      <property name="use_markup">True</property>
 		      <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -2775,13 +2658,13 @@
 		  </child>
 
 		  <child>
-		    <widget class="GtkHBox" id="hbox10">
+		    <widget class="GtkHBox" id="hbox8">
 		      <property name="visible">True</property>
 		      <property name="homogeneous">False</property>
 		      <property name="spacing">0</property>
 
 		      <child>
-			<widget class="GtkLabel" id="label23">
+			<widget class="GtkLabel" id="label19">
 			  <property name="visible">True</property>
 			  <property name="label" translatable="yes">    </property>
 			  <property name="use_underline">False</property>
@@ -2802,21 +2685,21 @@
 		      </child>
 
 		      <child>
-			<widget class="GtkVBox" id="vbox23">
+			<widget class="GtkVBox" id="vbox21">
 			  <property name="visible">True</property>
 			  <property name="homogeneous">False</property>
 			  <property name="spacing">6</property>
 
 			  <child>
-			    <widget class="GtkHBox" id="hbox23">
+			    <widget class="GtkHBox" id="hbox20">
 			      <property name="visible">True</property>
 			      <property name="homogeneous">False</property>
 			      <property name="spacing">12</property>
 
 			      <child>
-				<widget class="GtkLabel" id="preview_label_4">
+				<widget class="GtkLabel" id="preview_label_1">
 				  <property name="visible">True</property>
-				  <property name="label" translatable="yes">Count _number of items:</property>
+				  <property name="label" translatable="yes">Show _thumbnails:</property>
 				  <property name="use_underline">True</property>
 				  <property name="use_markup">False</property>
 				  <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -2826,7 +2709,7 @@
 				  <property name="yalign">0.5</property>
 				  <property name="xpad">0</property>
 				  <property name="ypad">0</property>
-				  <property name="mnemonic_widget">preview_folder_optionmenu</property>
+				  <property name="mnemonic_widget">preview_image_optionmenu</property>
 				</widget>
 				<packing>
 				  <property name="padding">0</property>
@@ -2836,16 +2719,16 @@
 			      </child>
 
 			      <child>
-				<widget class="GtkOptionMenu" id="preview_folder_optionmenu">
+				<widget class="GtkOptionMenu" id="preview_image_optionmenu">
 				  <property name="visible">True</property>
 				  <property name="can_focus">True</property>
 				  <property name="history">0</property>
 
 				  <child>
-				    <widget class="GtkMenu" id="menu13">
+				    <widget class="GtkMenu" id="menu10">
 
 				      <child>
-					<widget class="GtkMenuItem" id="always4">
+					<widget class="GtkMenuItem" id="always2">
 					  <property name="visible">True</property>
 					  <property name="label" translatable="yes">Always</property>
 					  <property name="use_underline">True</property>
@@ -2853,7 +2736,7 @@
 				      </child>
 
 				      <child>
-					<widget class="GtkMenuItem" id="local_files_only4">
+					<widget class="GtkMenuItem" id="local_files_only2">
 					  <property name="visible">True</property>
 					  <property name="label" translatable="yes">Local Files Only</property>
 					  <property name="use_underline">True</property>
@@ -2861,7 +2744,7 @@
 				      </child>
 
 				      <child>
-					<widget class="GtkMenuItem" id="never4">
+					<widget class="GtkMenuItem" id="never2">
 					  <property name="visible">True</property>
 					  <property name="label" translatable="yes">Never</property>
 					  <property name="use_underline">True</property>
@@ -2874,6 +2757,342 @@
 				  <property name="padding">0</property>
 				  <property name="expand">True</property>
 				  <property name="fill">True</property>
+				</packing>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">True</property>
+			      <property name="fill">True</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GtkHBox" id="hbox21">
+			      <property name="visible">True</property>
+			      <property name="homogeneous">False</property>
+			      <property name="spacing">12</property>
+
+			      <child>
+				<widget class="GtkLabel" id="preview_label_2">
+				  <property name="visible">True</property>
+				  <property name="label" translatable="yes">_Only for files smaller than:</property>
+				  <property name="use_underline">True</property>
+				  <property name="use_markup">False</property>
+				  <property name="justify">GTK_JUSTIFY_LEFT</property>
+				  <property name="wrap">False</property>
+				  <property name="selectable">False</property>
+				  <property name="xalign">0</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xpad">0</property>
+				  <property name="ypad">0</property>
+				  <property name="mnemonic_widget">preview_image_size_optionmenu</property>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">False</property>
+				  <property name="fill">False</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkOptionMenu" id="preview_image_size_optionmenu">
+				  <property name="visible">True</property>
+				  <property name="can_focus">True</property>
+				  <property name="history">0</property>
+
+				  <child>
+				    <widget class="GtkMenu" id="menu11">
+
+				      <child>
+					<widget class="GtkMenuItem" id="100_k1">
+					  <property name="visible">True</property>
+					  <property name="label" translatable="yes">100 KB</property>
+					  <property name="use_underline">True</property>
+					</widget>
+				      </child>
+
+				      <child>
+					<widget class="GtkMenuItem" id="500_k1">
+					  <property name="visible">True</property>
+					  <property name="label" translatable="yes">500 KB</property>
+					  <property name="use_underline">True</property>
+					</widget>
+				      </child>
+
+				      <child>
+					<widget class="GtkMenuItem" id="1_mb1">
+					  <property name="visible">True</property>
+					  <property name="label" translatable="yes">1 MB</property>
+					  <property name="use_underline">True</property>
+					</widget>
+				      </child>
+
+				      <child>
+					<widget class="GtkMenuItem" id="3_mb1">
+					  <property name="visible">True</property>
+					  <property name="label" translatable="yes">3 MB</property>
+					  <property name="use_underline">True</property>
+					</widget>
+				      </child>
+
+				      <child>
+					<widget class="GtkMenuItem" id="5_mb1">
+					  <property name="visible">True</property>
+					  <property name="label" translatable="yes">5 MB</property>
+					  <property name="use_underline">True</property>
+					</widget>
+				      </child>
+
+				      <child>
+					<widget class="GtkMenuItem" id="10_mb1">
+					  <property name="visible">True</property>
+					  <property name="label" translatable="yes">10 MB</property>
+					  <property name="use_underline">True</property>
+					</widget>
+				      </child>
+
+				      <child>
+					<widget class="GtkMenuItem" id="100_mb1">
+					  <property name="visible">True</property>
+					  <property name="label" translatable="yes">100 MB</property>
+					  <property name="use_underline">True</property>
+					</widget>
+				      </child>
+
+				      <child>
+					<widget class="GtkMenuItem" id="1_gb1">
+					  <property name="visible">True</property>
+					  <property name="label" translatable="yes">1 GB</property>
+					  <property name="use_underline">True</property>
+					</widget>
+				      </child>
+				    </widget>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">True</property>
+				  <property name="fill">True</property>
+				</packing>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">True</property>
+			      <property name="fill">True</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GtkHBox" id="hbox32">
+			      <property name="visible">True</property>
+			      <property name="homogeneous">False</property>
+			      <property name="spacing">0</property>
+
+			      <child>
+				<widget class="GtkLabel" id="label34">
+				  <property name="visible">True</property>
+				  <property name="label" translatable="yes"></property>
+				  <property name="use_underline">False</property>
+				  <property name="use_markup">False</property>
+				  <property name="justify">GTK_JUSTIFY_LEFT</property>
+				  <property name="wrap">False</property>
+				  <property name="selectable">False</property>
+				  <property name="xalign">0.5</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xpad">0</property>
+				  <property name="ypad">0</property>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">True</property>
+				  <property name="fill">False</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkButton" id="preview_cleanup_button">
+				  <property name="visible">True</property>
+				  <property name="tooltip" translatable="yes">Delete cached thumbnails which are no longer needed</property>
+				  <property name="can_focus">True</property>
+				  <property name="relief">GTK_RELIEF_NORMAL</property>
+				  <property name="focus_on_click">True</property>
+
+				  <child>
+				    <widget class="GtkAlignment" id="alignment2">
+				      <property name="visible">True</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xscale">0</property>
+				      <property name="yscale">0</property>
+				      <property name="top_padding">0</property>
+				      <property name="bottom_padding">0</property>
+				      <property name="left_padding">0</property>
+				      <property name="right_padding">0</property>
+
+				      <child>
+					<widget class="GtkHBox" id="hbox35">
+					  <property name="visible">True</property>
+					  <property name="homogeneous">False</property>
+					  <property name="spacing">2</property>
+
+					  <child>
+					    <widget class="GtkImage" id="image2">
+					      <property name="visible">True</property>
+					      <property name="stock">gtk-clear</property>
+					      <property name="icon_size">4</property>
+					      <property name="xalign">0.5</property>
+					      <property name="yalign">0.5</property>
+					      <property name="xpad">0</property>
+					      <property name="ypad">0</property>
+					    </widget>
+					    <packing>
+					      <property name="padding">0</property>
+					      <property name="expand">False</property>
+					      <property name="fill">False</property>
+					    </packing>
+					  </child>
+
+					  <child>
+					    <widget class="GtkLabel" id="label37">
+					      <property name="visible">True</property>
+					      <property name="label" translatable="yes">C_lean Up Thumbnail Cache</property>
+					      <property name="use_underline">True</property>
+					      <property name="use_markup">False</property>
+					      <property name="justify">GTK_JUSTIFY_LEFT</property>
+					      <property name="wrap">False</property>
+					      <property name="selectable">False</property>
+					      <property name="xalign">0.5</property>
+					      <property name="yalign">0.5</property>
+					      <property name="xpad">0</property>
+					      <property name="ypad">0</property>
+					    </widget>
+					    <packing>
+					      <property name="padding">0</property>
+					      <property name="expand">False</property>
+					      <property name="fill">False</property>
+					    </packing>
+					  </child>
+					</widget>
+				      </child>
+				    </widget>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">False</property>
+				  <property name="fill">False</property>
+				</packing>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">True</property>
+			      <property name="fill">True</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GtkHBox" id="hbox33">
+			      <property name="visible">True</property>
+			      <property name="homogeneous">False</property>
+			      <property name="spacing">0</property>
+
+			      <child>
+				<widget class="GtkLabel" id="label35">
+				  <property name="visible">True</property>
+				  <property name="label" translatable="yes"></property>
+				  <property name="use_underline">False</property>
+				  <property name="use_markup">False</property>
+				  <property name="justify">GTK_JUSTIFY_LEFT</property>
+				  <property name="wrap">False</property>
+				  <property name="selectable">False</property>
+				  <property name="xalign">0.5</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xpad">0</property>
+				  <property name="ypad">0</property>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">False</property>
+				  <property name="fill">False</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkButton" id="preview_empty_button">
+				  <property name="visible">True</property>
+				  <property name="tooltip" translatable="yes">Delete all cached thumbnails</property>
+				  <property name="can_focus">True</property>
+				  <property name="relief">GTK_RELIEF_NORMAL</property>
+				  <property name="focus_on_click">True</property>
+
+				  <child>
+				    <widget class="GtkAlignment" id="alignment1">
+				      <property name="visible">True</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xscale">0</property>
+				      <property name="yscale">0</property>
+				      <property name="top_padding">0</property>
+				      <property name="bottom_padding">0</property>
+				      <property name="left_padding">0</property>
+				      <property name="right_padding">0</property>
+
+				      <child>
+					<widget class="GtkHBox" id="hbox34">
+					  <property name="visible">True</property>
+					  <property name="homogeneous">False</property>
+					  <property name="spacing">2</property>
+
+					  <child>
+					    <widget class="GtkImage" id="image1">
+					      <property name="visible">True</property>
+					      <property name="stock">gtk-delete</property>
+					      <property name="icon_size">4</property>
+					      <property name="xalign">0.5</property>
+					      <property name="yalign">0.5</property>
+					      <property name="xpad">0</property>
+					      <property name="ypad">0</property>
+					    </widget>
+					    <packing>
+					      <property name="padding">0</property>
+					      <property name="expand">False</property>
+					      <property name="fill">False</property>
+					    </packing>
+					  </child>
+
+					  <child>
+					    <widget class="GtkLabel" id="label36">
+					      <property name="visible">True</property>
+					      <property name="label" translatable="yes">_Empty Thumbnail Cache</property>
+					      <property name="use_underline">True</property>
+					      <property name="use_markup">False</property>
+					      <property name="justify">GTK_JUSTIFY_LEFT</property>
+					      <property name="wrap">False</property>
+					      <property name="selectable">False</property>
+					      <property name="xalign">0.5</property>
+					      <property name="yalign">0.5</property>
+					      <property name="xpad">0</property>
+					      <property name="ypad">0</property>
+					    </widget>
+					    <packing>
+					      <property name="padding">0</property>
+					      <property name="expand">False</property>
+					      <property name="fill">False</property>
+					    </packing>
+					  </child>
+					</widget>
+				      </child>
+				    </widget>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">False</property>
+				  <property name="fill">False</property>
+				  <property name="pack_type">GTK_PACK_END</property>
 				</packing>
 			      </child>
 			    </widget>
