summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Sullivan <sullivan@src.gnome.org>2000-12-18 21:39:31 +0000
committerJohn Sullivan <sullivan@src.gnome.org>2000-12-18 21:39:31 +0000
commitcd707d47ba3d9f46fd6479bd37938ef9b564df67 (patch)
treeddc974fb9441fd16835abf9130bf04ad56f733e7
parent7c8d453b1d74b0a9f2f4585012e18a900f0444f1 (diff)
downloadnautilus-cd707d47ba3d9f46fd6479bd37938ef9b564df67.tar.gz
reviewed by: Darin Adler <darin@eazel.com>
Fixed bug 4037 (Error dialog every time on launch when permissions are set strangely) Fixed bug 1115 (Need better name for "User Directory" and "User Data Directory") * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_get_user_main_directory): Removed g_warning when Nautilus fails to create ~/Nautilus directory, improved FIXME comments. (nautilus_get_user_directory), (nautilus_get_desktop_directory): Added FIXME comments. * src/nautilus-application.c: (check_required_directories): Renamed from nautilus_application_ check_user_directories; now returns FALSE if any required directories were not created. Reworded error dialog to mention directories by path rather than using confusing invented symbolic names, and to tell the user to address the problem by creating specified directories or setting permissions such that Nautilus can create specified directories. (It used to say "restart Nautilus", which was pretty much guaranteed to have no effect.) (nautilus_application_startup): Now returns if check_required_directories fails. The user has to address the problem described in the error message before Nautilus will launch.
-rw-r--r--ChangeLog31
-rw-r--r--libnautilus-extensions/nautilus-file-utilities.c31
-rw-r--r--libnautilus-private/nautilus-file-utilities.c31
-rw-r--r--src/nautilus-application.c55
4 files changed, 115 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index 565d5766c..ab73c4507 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2000-12-18 John Sullivan <sullivan@eazel.com>
+
+ reviewed by: Darin Adler <darin@eazel.com>
+
+ Fixed bug 4037 (Error dialog every time on launch when
+ permissions are set strangely)
+
+ Fixed bug 1115 (Need better name for "User Directory"
+ and "User Data Directory")
+
+ * libnautilus-extensions/nautilus-file-utilities.c:
+ (nautilus_get_user_main_directory): Removed g_warning when
+ Nautilus fails to create ~/Nautilus directory, improved
+ FIXME comments.
+ (nautilus_get_user_directory), (nautilus_get_desktop_directory):
+ Added FIXME comments.
+
+ * src/nautilus-application.c:
+ (check_required_directories): Renamed from nautilus_application_
+ check_user_directories; now returns FALSE if any required
+ directories were not created. Reworded error dialog to mention
+ directories by path rather than using confusing invented symbolic
+ names, and to tell the user to address the problem by creating
+ specified directories or setting permissions such that Nautilus
+ can create specified directories. (It used to say "restart
+ Nautilus", which was pretty much guaranteed to have no effect.)
+ (nautilus_application_startup): Now returns if
+ check_required_directories fails. The user has to address the
+ problem described in the error message before Nautilus will
+ launch.
+
2000-12-18 Gene Z. Ragan <gzr@eazel.com>
Fixed an unused variable error.
diff --git a/libnautilus-extensions/nautilus-file-utilities.c b/libnautilus-extensions/nautilus-file-utilities.c
index dca503d23..defa8120b 100644
--- a/libnautilus-extensions/nautilus-file-utilities.c
+++ b/libnautilus-extensions/nautilus-file-utilities.c
@@ -443,6 +443,13 @@ nautilus_get_user_directory (void)
if (!g_file_exists (user_directory)) {
mkdir (user_directory, DEFAULT_NAUTILUS_DIRECTORY_MODE);
+ /* FIXME bugzilla.eazel.com 1286:
+ * How should we handle the case where this mkdir fails?
+ * Note that nautilus_application_startup will refuse to launch if this
+ * directory doesn't get created, so that case is OK. But the directory
+ * could be deleted after Nautilus was launched, and perhaps
+ * there is some bad side-effect of not handling that case.
+ */
}
return user_directory;
@@ -466,6 +473,13 @@ nautilus_get_desktop_directory (void)
if (!g_file_exists (desktop_directory)) {
mkdir (desktop_directory, DEFAULT_DESKTOP_DIRECTORY_MODE);
+ /* FIXME bugzilla.eazel.com 1286:
+ * How should we handle the case where this mkdir fails?
+ * Note that nautilus_application_startup will refuse to launch if this
+ * directory doesn't get created, so that case is OK. But the directory
+ * could be deleted after Nautilus was launched, and perhaps
+ * there is some bad side-effect of not handling that case.
+ */
}
return desktop_directory;
@@ -535,15 +549,20 @@ nautilus_get_user_main_directory (void)
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
NULL, NULL);
+ /* FIXME bugzilla.eazel.com 1286:
+ * How should we handle error codes returned from gnome_vfs_xfer_uri?
+ * Note that nautilus_application_startup will refuse to launch if this
+ * directory doesn't get created, so that case is OK. But the directory
+ * could be deleted after Nautilus was launched, and perhaps
+ * there is some bad side-effect of not handling that case.
+ */
+
gnome_vfs_uri_unref (source_uri);
gnome_vfs_uri_unref (destination_uri);
-
- /* FIXME bugzilla.eazel.com 1286:
- * Is a g_warning good enough here? This seems like a big problem.
+
+ /* If this fails to create the directory, nautilus_application_startup will
+ * notice and refuse to launch.
*/
- if (result != GNOME_VFS_OK) {
- g_warning ("could not install the novice home directory. Make sure you typed 'make install'");
- }
/* assign a custom image for the directory icon */
file_uri = gnome_vfs_get_uri_from_local_path (user_main_directory);
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index dca503d23..defa8120b 100644
--- a/libnautilus-private/nautilus-file-utilities.c
+++ b/libnautilus-private/nautilus-file-utilities.c
@@ -443,6 +443,13 @@ nautilus_get_user_directory (void)
if (!g_file_exists (user_directory)) {
mkdir (user_directory, DEFAULT_NAUTILUS_DIRECTORY_MODE);
+ /* FIXME bugzilla.eazel.com 1286:
+ * How should we handle the case where this mkdir fails?
+ * Note that nautilus_application_startup will refuse to launch if this
+ * directory doesn't get created, so that case is OK. But the directory
+ * could be deleted after Nautilus was launched, and perhaps
+ * there is some bad side-effect of not handling that case.
+ */
}
return user_directory;
@@ -466,6 +473,13 @@ nautilus_get_desktop_directory (void)
if (!g_file_exists (desktop_directory)) {
mkdir (desktop_directory, DEFAULT_DESKTOP_DIRECTORY_MODE);
+ /* FIXME bugzilla.eazel.com 1286:
+ * How should we handle the case where this mkdir fails?
+ * Note that nautilus_application_startup will refuse to launch if this
+ * directory doesn't get created, so that case is OK. But the directory
+ * could be deleted after Nautilus was launched, and perhaps
+ * there is some bad side-effect of not handling that case.
+ */
}
return desktop_directory;
@@ -535,15 +549,20 @@ nautilus_get_user_main_directory (void)
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
NULL, NULL);
+ /* FIXME bugzilla.eazel.com 1286:
+ * How should we handle error codes returned from gnome_vfs_xfer_uri?
+ * Note that nautilus_application_startup will refuse to launch if this
+ * directory doesn't get created, so that case is OK. But the directory
+ * could be deleted after Nautilus was launched, and perhaps
+ * there is some bad side-effect of not handling that case.
+ */
+
gnome_vfs_uri_unref (source_uri);
gnome_vfs_uri_unref (destination_uri);
-
- /* FIXME bugzilla.eazel.com 1286:
- * Is a g_warning good enough here? This seems like a big problem.
+
+ /* If this fails to create the directory, nautilus_application_startup will
+ * notice and refuse to launch.
*/
- if (result != GNOME_VFS_OK) {
- g_warning ("could not install the novice home directory. Make sure you typed 'make install'");
- }
/* assign a custom image for the directory icon */
file_uri = gnome_vfs_get_uri_from_local_path (user_main_directory);
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 096f8e9e6..f6247b0a8 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -69,7 +69,6 @@ static CORBA_Object create_object (PortableServer
static void nautilus_application_initialize (NautilusApplication *application);
static void nautilus_application_initialize_class (NautilusApplicationClass *klass);
static void nautilus_application_destroy (GtkObject *object);
-static void nautilus_application_check_user_directories (NautilusApplication *application);
static gboolean check_for_and_run_as_super_user (void);
static gboolean need_to_show_first_time_druid (void);
static void desktop_changed_callback (gpointer user_data);
@@ -209,13 +208,18 @@ nautilus_application_destroy (GtkObject *object)
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
-static void
-nautilus_application_check_user_directories (NautilusApplication *application)
+static gboolean
+check_required_directories (NautilusApplication *application)
{
char *user_directory;
char *user_main_directory;
char *desktop_directory;
NautilusStringList *dir_list;
+ char *dir_list_concatenated;
+ char *error_string;
+ char *dialog_title;
+ GnomeDialog *dialog;
+ int failed_count;
g_assert (NAUTILUS_IS_APPLICATION (application));
@@ -225,44 +229,51 @@ nautilus_application_check_user_directories (NautilusApplication *application)
dir_list = nautilus_string_list_new (TRUE);
- /* FIXME bugzilla.eazel.com 1115: Need better name for "User Directory"
- * and "User Data Directory". Perhaps it's OK to use the word "directory"
- * instead of "folder" in this technical error case.
- */
-
if (!g_file_test (user_directory, G_FILE_TEST_ISDIR)) {
- nautilus_string_list_insert (dir_list, _("User Directory"));
+ nautilus_string_list_insert (dir_list, user_directory);
}
g_free (user_directory);
if (!g_file_test (user_main_directory, G_FILE_TEST_ISDIR)) {
- nautilus_string_list_insert (dir_list, _("User Main Directory"));
+ nautilus_string_list_insert (dir_list, user_main_directory);
}
g_free (user_main_directory);
if (!g_file_test (desktop_directory, G_FILE_TEST_ISDIR)) {
- nautilus_string_list_insert (dir_list, _("Desktop Directory"));
+ nautilus_string_list_insert (dir_list, desktop_directory);
}
g_free (desktop_directory);
- if (nautilus_string_list_get_length (dir_list) > 0) {
- char *dir_list_concatenated;
- char *error_string;
+ failed_count = nautilus_string_list_get_length (dir_list);
+ if (failed_count != 0) {
dir_list_concatenated = nautilus_string_list_as_concatenated_string (dir_list, "\n");
-
- error_string = g_strdup_printf ("%s\n\n%s\n\n%s",
- "The following directories are missing:",
- dir_list_concatenated,
- "Please restart Nautilus to fix this problem.");
- nautilus_error_dialog (error_string, _("Missing Directories"), NULL);
+ if (failed_count == 1) {
+ dialog_title = g_strdup (_("Couldn't Create Required Folder"));
+ error_string = g_strdup_printf ("Nautilus could not create the required folder \"%s\". "
+ "Before running Nautilus, please create this folder, or "
+ "set permissions such that Nautilus can create it.", dir_list_concatenated);
+ } else {
+ dialog_title = g_strdup (_("Couldn't Create Required Folders"));
+ error_string = g_strdup_printf ("Nautilus could not create the following required folders:\n\n"
+ "%s\n\n"
+ "Before running Nautilus, please create these folders, or "
+ "set permissions such that Nautilus can create them.", dir_list_concatenated);
+ }
+
+ dialog = nautilus_error_dialog (error_string, dialog_title, NULL);
+ /* We need the main event loop so the user has a chance to see the dialog. */
+ nautilus_main_event_loop_register (GTK_OBJECT (dialog));
g_free (dir_list_concatenated);
g_free (error_string);
+ g_free (dialog_title);
}
nautilus_string_list_free (dir_list);
+
+ return failed_count == 0;
}
static int
@@ -323,7 +334,9 @@ nautilus_application_startup (NautilusApplication *application,
/* Check the user's ~/.nautilus directories and post warnings
* if there are problems.
*/
- nautilus_application_check_user_directories (application);
+ if (!check_required_directories (application)) {
+ return;
+ }
/* initialize the sound machinery */
nautilus_sound_initialize ();