fix for thumbnail prefs



Hi,

He's a fix for #96644 (respect thumbnailing prefs).

Thanks,
James
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5615
diff -u -r1.5615 ChangeLog
--- ChangeLog	8 Dec 2002 01:06:36 -0000	1.5615
+++ ChangeLog	8 Dec 2002 01:48:44 -0000
@@ -1,3 +1,13 @@
+2002-12-07  James Willcox  <jwillcox gnome org>
+
+	* libnautilus-private/nautilus-icon-factory.c:
+	(destroy_icon_factory), (get_icon_factory),
+	(show_thumbnails_changed_callback), (should_show_thumbnail),
+	(nautilus_icon_factory_get_icon_for_file):
+
+	Respond properly to prefs regarding when to show thumbnails.
+	Fixes #96644.
+
 2002-12-07  Dave Camp  <dave ximian com>
 
 	* libnautilus-private/nautilus-icon-container.c 
Index: libnautilus-private/nautilus-icon-factory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-factory.c,v
retrieving revision 1.283
diff -u -r1.283 nautilus-icon-factory.c
--- libnautilus-private/nautilus-icon-factory.c	5 Dec 2002 19:19:31 -0000	1.283
+++ libnautilus-private/nautilus-icon-factory.c	8 Dec 2002 01:48:51 -0000
@@ -164,6 +164,7 @@
 
 
 static int cached_thumbnail_limit;
+static int show_image_thumbs;
 
 /* forward declarations */
 
@@ -172,6 +173,7 @@
 static void       nautilus_icon_factory_instance_init    (NautilusIconFactory      *factory);
 static void       nautilus_icon_factory_finalize         (GObject                  *object);
 static void       thumbnail_limit_changed_callback       (gpointer                  user_data);
+static void       show_thumbnails_changed_callback       (gpointer                  user_data);
 static void       mime_type_data_changed_callback        (GnomeVFSMIMEMonitor	   *monitor,
 							  gpointer                  user_data);
 static guint      cache_key_hash                         (gconstpointer             p);
@@ -202,6 +204,9 @@
 	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT,
 					 thumbnail_limit_changed_callback,
 					 NULL);
+	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
+					 show_thumbnails_changed_callback,
+					 NULL);
 	g_object_unref (global_icon_factory);
 }
 
@@ -220,6 +225,11 @@
 					      thumbnail_limit_changed_callback,
 					      NULL);
 
+		show_thumbnails_changed_callback (NULL);
+		eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
+					      show_thumbnails_changed_callback,
+					      NULL);
+
 		g_signal_connect (gnome_vfs_mime_monitor_get (),
 				  "data_changed",
 				  G_CALLBACK (mime_type_data_changed_callback),
@@ -648,6 +658,16 @@
 			 signals[ICONS_CHANGED], 0);
 }
 
+static void
+show_thumbnails_changed_callback (gpointer user_data)
+{
+	show_image_thumbs = eel_preferences_get_enum (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS);
+
+	nautilus_icon_factory_clear ();
+	g_signal_emit (global_icon_factory,
+		       signals[ICONS_CHANGED], 0);
+}
+
 static void       
 mime_type_data_changed_callback (GnomeVFSMIMEMonitor *monitor, gpointer user_data)
 {
@@ -695,6 +715,26 @@
 	return NULL;
 }
 
+static gboolean
+should_show_thumbnail (NautilusFile *file)
+{
+	if (nautilus_file_get_size (file) >
+	    (unsigned int)cached_thumbnail_limit) {
+		return FALSE;
+	}
+	
+	if (show_image_thumbs == NAUTILUS_SPEED_TRADEOFF_ALWAYS) {
+		return TRUE;
+	} else if (show_image_thumbs == NAUTILUS_SPEED_TRADEOFF_NEVER) {
+		return FALSE;
+	} else {
+		/* only local files */
+		return nautilus_file_is_local (file);
+	}
+
+	return FALSE;
+}
+
 /* key routine to get the icon for a file */
 char *
 nautilus_icon_factory_get_icon_for_file (NautilusFile *file)
@@ -703,6 +743,8 @@
 	NautilusIconFactory *factory;
 	GnomeIconLookupResultFlags lookup_result;
 	GnomeVFSFileInfo *file_info;
+	GnomeThumbnailFactory *thumb_factory;
+	gboolean show_thumb;
 
 	if (file == NULL) {
 		return NULL;
@@ -731,9 +773,17 @@
 	mime_type = nautilus_file_get_mime_type (file);
 	
 	file_info = nautilus_file_peek_vfs_file_info (file);
-		
+	
+	show_thumb = should_show_thumbnail (file);	
+	
+	if (show_thumb) {
+		thumb_factory = factory->thumbnail_factory;
+	} else {
+		thumb_factory = NULL;
+	}
+	
 	icon_name = gnome_icon_lookup (factory->icon_theme,
-				       factory->thumbnail_factory,
+				       thumb_factory,
 				       file_uri,
 				       custom_icon,
 				       nautilus_file_peek_vfs_file_info (file),
@@ -745,7 +795,8 @@
 
 	/* Create thumbnails if we can, and if the looked up icon isn't a thumbnail
 	   or an absolute pathname (custom icon or image as itself) */
-	if (!(lookup_result & GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL) &&
+	if (show_thumb &&
+	    !(lookup_result & GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL) &&
 	    icon_name[0] != '/' && file_info &&
 	    gnome_thumbnail_factory_can_thumbnail (factory->thumbnail_factory,
 						   file_uri,


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