--- gnome-control-center/capplets/theme-switcher/theme-switcher.c	Wed Sep  3 04:00:17 2003
+++ gnome-control-center-new/capplets/theme-switcher/theme-switcher.c	Thu Sep  4 11:29:01 2003
@@ -5,6 +5,7 @@
 #include <config.h>
 
 #include <string.h>
+#include <unistd.h>
 #include <gtk/gtk.h>
 #include <gconf/gconf-client.h>
 #include <glade/glade.h>
@@ -548,7 +549,7 @@ install_dialog_response (GtkWidget *widg
 {
 	GladeXML *dialog = data;
 	GtkWidget *dlg;
-	gchar *filename, *path, *base;
+	gchar *filename, *dirpath, *path, *base;
 	GList *src, *target;
 	GnomeVFSURI *src_uri;
 	const gchar *raw;
@@ -575,26 +576,41 @@ install_dialog_response (GtkWidget *widg
 		src_uri = gnome_vfs_uri_new (filename);
 		base = gnome_vfs_uri_extract_short_name (src_uri);
 		src = g_list_append (NULL, src_uri);
+		dirpath = g_strconcat (g_get_home_dir (), "/.themes", NULL);
 		path = g_build_filename (g_get_home_dir (), ".themes",
 				         base, NULL);
-		target = g_list_append (NULL, gnome_vfs_uri_new (path));
+		if (access (dirpath, X_OK | W_OK) != 0) {
+                        GtkWidget *err_dlg;
+                                                         
+                        err_dlg = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+                                                          GTK_MESSAGE_ERROR,
+                                                          GTK_BUTTONS_OK,
+                                                          _("Could not install theme into %s,\nCheck the folder permissions"), dirpath);
+                        g_signal_connect (G_OBJECT (err_dlg), "response",
+                                          G_CALLBACK (gtk_widget_destroy), NULL);
+                        gtk_window_set_resizable (GTK_WINDOW (err_dlg), FALSE);
+                                                           
+                        gtk_widget_show (err_dlg);
+                } else {
+			target = g_list_append (NULL, gnome_vfs_uri_new (path));
 		
-		dlg = file_transfer_dialog_new ();
-		file_transfer_dialog_wrap_async_xfer (FILE_TRANSFER_DIALOG (dlg),
-						      src, target,
-						      GNOME_VFS_XFER_RECURSIVE,
-						      GNOME_VFS_XFER_ERROR_MODE_QUERY,
-						      GNOME_VFS_XFER_OVERWRITE_MODE_QUERY,
-						      GNOME_VFS_PRIORITY_DEFAULT);
-		gnome_vfs_uri_list_unref (src);
-		gnome_vfs_uri_list_unref (target);
+			dlg = file_transfer_dialog_new ();
+			file_transfer_dialog_wrap_async_xfer (FILE_TRANSFER_DIALOG (dlg),
+							      src, target,
+							      GNOME_VFS_XFER_RECURSIVE,
+							      GNOME_VFS_XFER_ERROR_MODE_QUERY,
+							      GNOME_VFS_XFER_OVERWRITE_MODE_QUERY,
+							      GNOME_VFS_PRIORITY_DEFAULT);
+			gnome_vfs_uri_list_unref (src);
+			gnome_vfs_uri_list_unref (target);
+			g_signal_connect (G_OBJECT (dlg), "cancel",
+					  G_CALLBACK (transfer_cancel_cb), path);
+			g_signal_connect (G_OBJECT (dlg), "done",
+					  G_CALLBACK (transfer_done_cb), path);
+			gtk_widget_show (dlg);
+		}
 		g_free (base);
 		g_free (filename);
-		g_signal_connect (G_OBJECT (dlg), "cancel",
-				  G_CALLBACK (transfer_cancel_cb), path);
-		g_signal_connect (G_OBJECT (dlg), "done",
-				  G_CALLBACK (transfer_done_cb), path);
-		gtk_widget_show (dlg);
 	}
 }
 
