Allow to disable thumbnailing per directory



Hello!
For some time, I've been looking for an answer to question: How do I
disable thumbnailing in scope of one directory in Nautilus? I've got few
directories I just don't want to be thumbnailed (privacy, lots of files,
etc.). I found no answer, so I decided to hack around a bit.

Simplest possible solution I found was: change nautilus_can_thumbnail
function to look for some specific file ('.nautilus-no-thumbnailing') in
a directory, which would turn thumbnailing off in it's scope.

Please note, that this doesn't disable loading thumbnails (just their
creation).

I'm pretty sure that Windows provides such an option (implemented in
other way, I suppose), so hey, why wouldn't we?
If this patch gets accepted, maybe there should be an option in
directory properties, which would turn thumbnailing on and off?


I've created Bugzilla report:
https://bugzilla.gnome.org/show_bug.cgi?id=648110

There are 3 patches, I wasn't good enough at glib when writing first
one. Second fixes first, and third one (with description "Complete
patch") is a mashup of both patches (I cloned nautilus again and changed
nautilus-thumbnails.c to look just how it was supposed to look after
applying first and second patch). It's also attached to this mail.
So, if you want to apply this to source code, you should just forget
about first and second and patch it with the third one.

Sorry for messing up so much, it's my very first contribution to this
kind of projects (and I'm sure not last one - it's just... cool).
-- 
Maciej Małecki <maciej malecki hotmail com>
>From 917b6c982c002b1a97292f72dcc91d78883cb400 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= <maciej malecki hotmail com>
Date: Tue, 19 Apr 2011 18:26:16 +0200
Subject: [PATCH] thumbnails: Allow to disable thumbnailing per directory

Allow to disable thumbnailing in a scope of a directory if
.nautilus-no-thumbnailing exists in this directory.
---
 libnautilus-private/nautilus-thumbnails.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/libnautilus-private/nautilus-thumbnails.c b/libnautilus-private/nautilus-thumbnails.c
index b11e875..eabc7d3 100644
--- a/libnautilus-private/nautilus-thumbnails.c
+++ b/libnautilus-private/nautilus-thumbnails.c
@@ -59,6 +59,9 @@
 /* Cool-off period between last file modification time and thumbnail creation */
 #define THUMBNAIL_CREATION_DELAY_SECS 3
 
+/* Name of file which disables thumbnails creation in a scope of folder */
+#define NO_THUMBNAILING_FILE_NAME ".nautilus-no-thumbnailing"
+
 static gpointer thumbnail_thread_start (gpointer data);
 
 /* structure used for making thumbnails, associating a uri with where the thumbnail is to be stored */
@@ -535,8 +538,25 @@ nautilus_can_thumbnail (NautilusFile *file)
 	char *uri;
 	time_t mtime;
 	char *mime_type;
+	char *nt_path;
+	GFile *nt_file;
 		
 	uri = nautilus_file_get_uri (file);
+	
+	/* check if .nautilus-no-thumbnailing (NO_THUMBNAILING_FILE_NAME) exists
+	   in parent directory of file, if yes, return false */
+	nt_path = g_path_get_dirname (uri);
+	nt_path = g_build_filename (nt_path, NO_THUMBNAILING_FILE_NAME, NULL);
+	
+	nt_file = g_file_new_for_uri (nt_path);
+	res = g_file_query_exists (nt_file, NULL); 
+	g_object_unref (nt_file);
+	g_free (nt_path);
+	if (res) {
+		return FALSE;
+	}
+	
+		
 	mime_type = nautilus_file_get_mime_type (file);
 	mtime = nautilus_file_get_mtime (file);
 	
-- 
1.7.4.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]