Index: gnome-settings-font.c
===================================================================
--- gnome-settings-font.c	(revision 7328)
+++ gnome-settings-font.c	(working copy)
@@ -49,41 +49,16 @@ static void
 load_cursor (GConfClient *client)
 {
   DIR *dir;
-  gchar *font_dir_name;
   gchar *dir_name;
+  gchar *quoted_dir_name;
   struct dirent *file_dirent;
   gchar *cursor_font;
   gchar **font_path;
-  gchar **new_font_path;
   gint n_fonts;
-  gint new_n_fonts;
   gint i;
   gchar *mkfontdir_cmd;
 
   /* setting up the dir */
-  font_dir_name = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2/share/fonts", NULL);
-  if (! g_file_test (font_dir_name, G_FILE_TEST_EXISTS))
-    {
-      if (g_mkdir_with_parents (font_dir_name, 0755) != 0)
-        {
-          GtkWidget *dialog;
-
-	  dialog = gtk_message_dialog_new (NULL,
-					   0,
-					   GTK_MESSAGE_ERROR,
-					   GTK_BUTTONS_CLOSE,
-					   _("Cannot create the directory \"%s\".\n"\
-					     "This is needed to allow changing the mouse pointer theme."),
-					   font_dir_name);
-	  g_signal_connect (dialog, "response",
-			    G_CALLBACK (gtk_widget_destroy), NULL);
-	  gnome_settings_delayed_show_dialog (dialog);
-	  g_free (font_dir_name);
-
-	  return;
-	}
-    }
-
   dir_name = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2/share/cursor-fonts", NULL);
   if (! g_file_test (dir_name, G_FILE_TEST_EXISTS))
     {
@@ -146,53 +121,34 @@ load_cursor (GConfClient *client)
     }
   g_free (cursor_font);
 
-
   /* run mkfontdir */
-  mkfontdir_cmd = g_strdup_printf ("mkfontdir %s %s", dir_name, font_dir_name);
-  /* maybe check for error...
-   * also, it's not going to like that if there are spaces in dir_name/font_dir_name.
-   */
+  quoted_dir_name = g_shell_quote (dir_name);
+  mkfontdir_cmd = g_strdup_printf ("mkfontdir %s", quoted_dir_name);
+  g_free (quoted_dir_name);
+  /* maybe check for error... */
   g_spawn_command_line_sync (mkfontdir_cmd, NULL, NULL, NULL, NULL);
   g_free (mkfontdir_cmd);
 
   /* Set the font path */
   font_path = XGetFontPath (gdk_x11_get_default_xdisplay (), &n_fonts);
-  new_n_fonts = n_fonts;
-  if (n_fonts == 0 || strcmp (font_path[0], dir_name))
-    new_n_fonts++;
-  if (n_fonts == 0 || strcmp (font_path[n_fonts-1], font_dir_name))
-    new_n_fonts++;
-
-  new_font_path = g_new0 (gchar*, new_n_fonts);
   if (n_fonts == 0 || strcmp (font_path[0], dir_name))
     {
+      gchar **new_font_path = g_new (gchar *, n_fonts + 1);
+
       new_font_path[0] = dir_name;
       for (i = 0; i < n_fonts; i++)
 	new_font_path [i+1] = font_path [i];
-    }
-  else
-    {
-      for (i = 0; i < n_fonts; i++)
-	new_font_path [i] = font_path [i];
-    }
 
-  if (n_fonts == 0 || strcmp (font_path[n_fonts-1], font_dir_name))
-    {
-      new_font_path[new_n_fonts-1] = font_dir_name;
+      gdk_error_trap_push ();
+      XSetFontPath (gdk_display, new_font_path, n_fonts + 1);
+      gdk_flush ();
+
+      /* if there was an error setting the new path, revert */
+      if (gdk_error_trap_pop ())
+        XSetFontPath (gdk_display, font_path, n_fonts); 
     }
 
-  gdk_error_trap_push ();
-  XSetFontPath (gdk_display, new_font_path, new_n_fonts);
-  gdk_flush ();
-
-  /* if there was an error setting the new path, revert */
-  if (gdk_error_trap_pop ())
-    XSetFontPath (gdk_display, font_path, n_fonts); 
-
   XFreeFontPath (font_path);
-
-  g_free (new_font_path);
-  g_free (font_dir_name);
   g_free (dir_name);
 }
 
