Index: nautilus-2.20.0/libnautilus-private/nautilus-icon-factory.c
===================================================================
--- nautilus-2.20.0.orig/libnautilus-private/nautilus-icon-factory.c	2008-06-30 23:24:47.000000000 -0400
+++ nautilus-2.20.0/libnautilus-private/nautilus-icon-factory.c	2008-07-12 16:27:47.000000000 -0400
@@ -66,6 +66,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <VisualIDs/paths.h>
+
 #define CACHE_SELF_CHECKS 0
 
 #define ICON_NAME_THUMBNAIL_LOADING     "gnome-fs-loading-icon"
@@ -995,6 +997,7 @@
 	GnomeThumbnailFactory *thumb_factory;
 	gboolean show_thumb;
 	GnomeIconLookupFlags lookup_flags;
+	struct stat visualid_stat;
 	
 	if (file == NULL) {
 		return NULL;
@@ -1044,7 +1047,6 @@
 				       lookup_flags,
 				       &lookup_result);
 
-
 	/* 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 (show_thumb &&
@@ -1054,9 +1056,37 @@
 						   file_uri,
 						   mime_type,
 						   file_info->mtime)) {
-		nautilus_create_thumbnail (file);
+		nautilus_create_thumbnail (file, NAUTILUS_TNTYPE_THUMBNAIL);
 		g_free (icon_name);
 		icon_name = g_strdup (ICON_NAME_THUMBNAIL_LOADING);
+	} else if (stat (visualid_cachedir (), &visualid_stat) == 0 &&
+		   !custom_icon &&
+		   !(show_thumb && lookup_result & GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL) &&
+		   icon_name[0] != '/') {
+		struct stat statbuf;
+		char *icon_path;
+		icon_path = visualid_path_for_file (file_uri);
+
+		if (stat (icon_path, &statbuf) != 0) {
+			nautilus_create_thumbnail (file,
+						   NAUTILUS_TNTYPE_VISUALID);
+
+			/* Do not reset icon_name--use the default
+			   (type-indicator) icon until the VisualID is ready. */
+		} else {
+			/* Apparently, we need to return an absolute
+			   path to the `thumbnail' icon (when the
+			   file-update event triggers the rescan),
+			   because that's what Nautilus assumes is
+			   going to come out--no attempt is made to
+			   resolve a [relative] icon-name, under these
+			   specific circumstances. */
+
+			g_free (icon_name);
+			icon_name = g_strdup (icon_path);
+		}
+
+		g_free (icon_path);
 	}
 	
         g_free (file_uri);
@@ -1134,6 +1164,9 @@
 	char *icon;
 	gboolean file_is_trash;
 
+	char *visualid_path;
+	struct stat statbuf;
+
 	icons = NULL;
 
 	emblem_names = nautilus_file_get_emblem_names (file);
@@ -1157,6 +1190,38 @@
 		icon = nautilus_icon_factory_get_emblem_icon_by_name (name);
 		icons = g_list_prepend (icons, icon);
 	}
+
+	/* VisualID `branding'--file-type is auxiliary info,
+	   show type-indicators as emblems:  */
+
+	uri = nautilus_file_get_uri (file);
+	visualid_path = visualid_path_for_file (uri);
+	g_free (uri);
+
+	if (!get_special_icon_for_file (file)
+	    && !nautilus_file_get_custom_icon (file)
+	    && visualid_path && stat (visualid_path, &statbuf) == 0) {
+		/* Only if the VisualID icon is ready */
+		/* XXX: how do we make the folder-icon `open' when
+		   it's prelit as a drop-target? */
+
+		icons = g_list_prepend
+			(icons,
+			 gnome_icon_lookup (get_icon_factory ()->icon_theme,
+					    NULL,
+					    nautilus_file_get_uri (file),
+					    NULL,
+					    nautilus_file_peek_vfs_file_info
+					    (file),
+					    nautilus_file_get_mime_type (file),
+	  /* no small-image, text-icons: */ GNOME_ICON_LOOKUP_FLAGS_NONE,
+					    NULL));
+	}
+
+	if (visualid_path) {
+		g_free (visualid_path);
+	}
+
 	eel_g_list_free_deep (emblem_names);
 
 	return g_list_reverse (icons);
Index: nautilus-2.20.0/libnautilus-private/nautilus-thumbnails.c
===================================================================
--- nautilus-2.20.0.orig/libnautilus-private/nautilus-thumbnails.c	2008-06-30 23:24:40.000000000 -0400
+++ nautilus-2.20.0/libnautilus-private/nautilus-thumbnails.c	2008-07-11 23:47:48.000000000 -0400
@@ -48,6 +48,8 @@
 
 #include "nautilus-file-private.h"
 
+#include <VisualIDs/paths.h>
+
 /* turn this on to see messages about thumbnail creation */
 #if 0
 #define DEBUG_THUMBNAILS
@@ -67,6 +69,7 @@
 	char *image_uri;
 	char *mime_type;
 	time_t original_file_mtime;
+	NautilusThumbnailType thumbnail_type;
 } NautilusThumbnailInfo;
 
 struct NautilusThumbnailAsyncLoadHandle {
@@ -660,18 +663,21 @@
 }
 
 void
-nautilus_create_thumbnail (NautilusFile *file)
+nautilus_create_thumbnail (NautilusFile *file, NautilusThumbnailType type)
 {
 	time_t file_mtime = 0;
 	NautilusThumbnailInfo *info;
 	NautilusThumbnailInfo *existing_info;
 	GList *existing;
 
-	nautilus_file_set_is_thumbnailing (file, TRUE);
+	if (type == NAUTILUS_TNTYPE_THUMBNAIL) {
+		nautilus_file_set_is_thumbnailing (file, TRUE);
+	}
 
 	info = g_new0 (NautilusThumbnailInfo, 1);
 	info->image_uri = nautilus_file_get_uri (file);
 	info->mime_type = nautilus_file_get_mime_type (file);
+	info->thumbnail_type = type;
 	
 	/* Hopefully the NautilusFile will already have the image file mtime,
 	   so we can just use that. Otherwise we have to get it ourselves. */
@@ -831,6 +837,22 @@
 			   info->image_uri);
 #endif
 
+		if (info->thumbnail_type == NAUTILUS_TNTYPE_VISUALID) {
+
+			pid_t mkvisualid = fork ();
+			if (mkvisualid == 0) {
+				execlp ("mkvisualid", "mkvisualid",
+						      "--cache",
+						      info->image_uri,
+						      NULL);
+				sleep (2);
+				exit (1);
+			}
+
+			waitpid (mkvisualid, NULL, 0);
+		}
+		else {
+
 		pixbuf = gnome_thumbnail_factory_generate_thumbnail (thumbnail_factory,
 								     info->image_uri,
 								     info->mime_type);
@@ -846,6 +868,7 @@
 									 info->image_uri,
 									 current_orig_mtime);
 		}
+		}
 		/* We need to call nautilus_file_changed(), but I don't think that is
 		   thread safe. So add an idle handler and do it from the main loop. */
 		g_idle_add_full (G_PRIORITY_HIGH_IDLE,
Index: nautilus-2.20.0/libnautilus-private/nautilus-thumbnails.h
===================================================================
--- nautilus-2.20.0.orig/libnautilus-private/nautilus-thumbnails.h	2008-06-30 23:24:40.000000000 -0400
+++ nautilus-2.20.0/libnautilus-private/nautilus-thumbnails.h	2008-06-30 23:24:47.000000000 -0400
@@ -37,8 +37,15 @@
 						 double      scale_y,
 						 gpointer    user_data);
 
+typedef enum {
+	NAUTILUS_TNTYPE_THUMBNAIL,
+	NAUTILUS_TNTYPE_VISUALID
+} NautilusThumbnailType;
+
+
 /* Returns NULL if there's no thumbnail yet. */
-void       nautilus_create_thumbnail                (NautilusFile *file);
+void       nautilus_create_thumbnail                (NautilusFile *file,
+						     NautilusThumbnailType type);
 void       nautilus_thumbnail_frame_image           (GdkPixbuf **pixbuf);
 GdkPixbuf *nautilus_thumbnail_load_image            (const char *path,
 						     guint       base_size,
Index: nautilus-2.20.0/libnautilus-private/Makefile.am
===================================================================
--- nautilus-2.20.0.orig/libnautilus-private/Makefile.am	2008-06-30 23:24:40.000000000 -0400
+++ nautilus-2.20.0/libnautilus-private/Makefile.am	2008-06-30 23:24:47.000000000 -0400
@@ -33,6 +33,7 @@
 	$(TRACKER_LIBS)			\
 	$(top_builddir)/libnautilus-extension/libnautilus-extension.la \
 	$(CORE_LIBS)			\
+	-lvisualid			\
 	$(NULL)
 
 nautilus_metafile_server_idl_sources = \
Index: nautilus-2.20.0/libnautilus-private/Makefile.in
===================================================================
--- nautilus-2.20.0.orig/libnautilus-private/Makefile.in	2008-06-30 23:24:40.000000000 -0400
+++ nautilus-2.20.0/libnautilus-private/Makefile.in	2008-06-30 23:24:47.000000000 -0400
@@ -464,6 +464,7 @@
 	$(TRACKER_LIBS)			\
 	$(top_builddir)/libnautilus-extension/libnautilus-extension.la \
 	$(CORE_LIBS)			\
+	-lvisualid			\
 	$(NULL)
 
 nautilus_metafile_server_idl_sources = \
