=== modified file 'gvfs/monitor/hal/ghalmount.c'
--- gvfs/monitor/hal/ghalmount.c	2008-09-02 18:36:29 +0000
+++ gvfs/monitor/hal/ghalmount.c	2009-02-06 23:48:06 +0000
@@ -285,6 +285,125 @@ _g_find_mount_icon (GHalMount *m)
                                   search_data);
 }
 
+static void
+on_xdginfo_loaded (GObject *source_object, GAsyncResult *res,
+                   gpointer user_data)
+{
+  gchar *content, *icon_name = NULL, *vol_name = NULL;
+  gsize content_length;
+  GIcon *icon;
+  MountIconSearchData *data = (MountIconSearchData *) (user_data);
+  
+  if (g_file_load_contents_finish (G_FILE (source_object), res, &content,
+                                   &content_length, NULL, NULL))
+    {
+      /* Scan through for an "icon=" line. Can't use GKeyFile,
+       * because .inf files aren't always valid key files
+       **/
+      GRegex *icon_regex;
+      GRegex *vol_regex;
+      GMatchInfo *match_info;
+      
+      icon_regex = g_regex_new ("icon=([^\\n]+)",
+                                G_REGEX_CASELESS, 0, NULL);
+      g_regex_match (icon_regex, content, 0,
+                     &match_info);
+      
+      /* Even if there are multiple matches, pick only the
+       * first.
+       **/
+      if (g_match_info_matches (match_info))
+        {
+          gchar *word = g_match_info_fetch (match_info, 1);
+          
+          /* If the file name's not valid UTF-8,
+           * don't even try to load it
+           **/
+          if (g_utf8_validate (word, -1, NULL))
+            icon_name = word;
+          else
+            g_free (word);
+        }
+      
+      g_match_info_free (match_info);
+      
+      vol_regex = g_regex_new ("name=([^\\n]+)",
+                                G_REGEX_CASELESS, 0, NULL);
+      g_regex_match (vol_regex, content, 0,
+                     &match_info);
+      
+      /* Even if there are multiple matches, pick only the
+       * first.
+       **/
+      if (g_match_info_matches (match_info))
+        {
+          gchar *word = g_match_info_fetch (match_info, 1);
+          
+          /* If the file name's not valid UTF-8,
+           * don't even try to load it
+           **/
+          if (g_utf8_validate (word, -1, NULL))
+            vol_name = word;
+          else
+            g_free (word);
+        }
+      
+      g_match_info_free (match_info);
+
+      g_regex_unref (vol_regex);
+      g_regex_unref (icon_regex);
+      g_free (content);
+    }
+
+  if (icon_name)
+    {
+      icon = get_themed_icon_with_fallbacks (icon_name, "drive-harddisk");
+
+      data->mount->icon = g_object_ref (icon);
+      g_object_unref (icon);
+
+    }
+
+  if (vol_name)
+    data->mount->name = g_strdup (vol_name);
+
+  clear_icon_search_data (data);
+}
+
+static void
+on_xdginfo_located (GObject *source_object, GAsyncResult *res,
+                    gpointer user_data)
+{
+  GFile *xdginfo_path;
+  MountIconSearchData *data = (MountIconSearchData *) (user_data);
+  
+  xdginfo_path = _g_find_file_insensitive_finish (G_FILE (source_object),
+                                                  res, NULL);
+  if (xdginfo_path)
+    g_file_load_contents_async (xdginfo_path, NULL, on_xdginfo_loaded, data);
+  else
+    clear_icon_search_data (data);
+  
+  g_object_unref (xdginfo_path);
+}
+
+static void
+_g_find_xdg_volume_info (GHalMount *m)
+{
+  MountIconSearchData *search_data;
+  
+  m->searched_for_icon = TRUE;
+	
+  search_data = g_new0 (MountIconSearchData, 1);
+  search_data->mount = g_object_ref (m);
+  search_data->root = get_root (m);
+  
+  _g_find_file_insensitive_async (search_data->root,
+                                  ".xdg-volume-info",
+                                  NULL, on_xdginfo_located,
+                                  search_data);
+}
+
 #define KILOBYTE_FACTOR 1000.0
 #define MEGABYTE_FACTOR (1000.0 * 1000.0)
 #define GIGABYTE_FACTOR (1000.0 * 1000.0 * 1000.0)
@@ -617,7 +736,7 @@ g_hal_mount_override_icon (GHalMount *mo
     mount->override_icon = NULL;
 
   G_UNLOCK (hal_mount);
-  
+
   update_from_hal (mount, TRUE);
 }
 
@@ -692,6 +811,9 @@ g_hal_mount_new (GVolumeMonitor       *v
   mount->name = g_unix_mount_guess_name (mount_entry);
   mount->icon = g_unix_mount_guess_icon (mount_entry);
 
+  if (!mount->searched_for_icon)
+    _g_find_xdg_volume_info (mount);
+
  was_hal:
 
   /* need to do this last */

