summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Sullivan <sullivan@src.gnome.org>2001-02-06 23:17:30 +0000
committerJohn Sullivan <sullivan@src.gnome.org>2001-02-06 23:17:30 +0000
commitb450cc9ef5c252dece99007a4e91550e991f8ba3 (patch)
treeecbf8acbcf45ab8aae1a6193a1ad676e671b2dc8
parent55a708f1e5065f95673d8e9026f90c3ce0ccef14 (diff)
downloadnautilus-b450cc9ef5c252dece99007a4e91550e991f8ba3.tar.gz
reviewed by: Pavel Cisler <pavel@eazel.com>
Fixed bug 5157 (Nautilus won't display directories for which it thinks it doesn't have permissions) I removed the code that prevented Nautilus from even trying to load a location for which the perceived permissions didn't allow reading (because the perceived permissions can be wrong with some file systems). Now it always tries, and puts up an error dialog only if it gets an error while actually loading the directory. * src/file-manager/fm-error-reporting.h: * src/file-manager/fm-error-reporting.c: (fm_report_error_loading_directory): New function, currently only handles GNOME_VFS_ERROR_ACCESS_DENIED and a fallback default case. (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions), (rename_callback): All the report_error functions now take a parent-window parameter (which is often NULL). Also, they now all use gnome_vfs_error_result_to_string when whining about unhandled cases. * src/file-manager/fm-directory-view.h: Changed comments and copyright notice only. * src/file-manager/fm-directory-view.c: (real_load_error): New function, calls fm_report_error_loading_directory unless an error has already been reported for the current directory load operation. (fm_directory_view_initialize_class): Wire up real_load_error as default handler for LOAD_ERROR signal. (activate_callback): Pass parent window to error-reporting call. (load_directory): Reset the reported_load_error boolean since we're about to load anew. * src/file-manager/fm-properties-window.c: (rename_callback), (group_change_callback), (owner_change_callback), (permission_change_callback): Pass parent window to error-reporting-calls. I just passed NULL if it was not trivial to pass a good window. * src/nautilus-window-manage-views.c: (handle_unreadable_location), (open_location): Remove code that was preventing "unreadable" locations from being loaded.
-rw-r--r--ChangeLog49
-rw-r--r--src/file-manager/fm-directory-view.c31
-rw-r--r--src/file-manager/fm-directory-view.h17
-rw-r--r--src/file-manager/fm-error-reporting.c67
-rw-r--r--src/file-manager/fm-error-reporting.h16
-rw-r--r--src/file-manager/fm-properties-window.c9
-rw-r--r--src/nautilus-window-manage-views.c42
7 files changed, 160 insertions, 71 deletions
diff --git a/ChangeLog b/ChangeLog
index a93934c72..74fc46358 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,52 @@
+2001-02-06 John Sullivan <sullivan@eazel.com>
+
+ reviewed by: <delete if not using a buddy>
+
+ Fixed bug 5157 (Nautilus won't display directories for
+ which it thinks it doesn't have permissions)
+
+ I removed the code that prevented Nautilus from even
+ trying to load a location for which the perceived
+ permissions didn't allow reading (because the perceived
+ permissions can be wrong with some file systems). Now
+ it always tries, and puts up an error dialog only if
+ it gets an error while actually loading the directory.
+
+ * src/file-manager/fm-error-reporting.h:
+ * src/file-manager/fm-error-reporting.c:
+ (fm_report_error_loading_directory): New function, currently
+ only handles GNOME_VFS_ERROR_ACCESS_DENIED and a fallback
+ default case.
+ (fm_report_error_renaming_file), (fm_report_error_setting_group),
+ (fm_report_error_setting_owner),
+ (fm_report_error_setting_permissions), (rename_callback):
+ All the report_error functions now take a parent-window
+ parameter (which is often NULL). Also, they now all use
+ gnome_vfs_error_result_to_string when whining about
+ unhandled cases.
+
+ * src/file-manager/fm-directory-view.h: Changed comments
+ and copyright notice only.
+ * src/file-manager/fm-directory-view.c:
+ (real_load_error): New function, calls
+ fm_report_error_loading_directory unless an error has already
+ been reported for the current directory load operation.
+ (fm_directory_view_initialize_class): Wire up real_load_error
+ as default handler for LOAD_ERROR signal.
+ (activate_callback): Pass parent window to error-reporting call.
+ (load_directory): Reset the reported_load_error boolean since
+ we're about to load anew.
+
+ * src/file-manager/fm-properties-window.c: (rename_callback),
+ (group_change_callback), (owner_change_callback),
+ (permission_change_callback):
+ Pass parent window to error-reporting-calls. I just passed NULL
+ if it was not trivial to pass a good window.
+
+ * src/nautilus-window-manage-views.c:
+ (handle_unreadable_location), (open_location): Remove code that
+ was preventing "unreadable" locations from being loaded.
+
2001-02-06 Gene Z. Ragan <gzr@eazel.com>
Fixed bug 6375, Certain menu shortcuts don't work when
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 901a14e6f..cc4898f57 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -3,7 +3,7 @@
/* fm-directory-view.c
*
* Copyright (C) 1999, 2000 Free Software Foundaton
- * Copyright (C) 2000 Eazel, Inc.
+ * Copyright (C) 2000, 2001 Eazel, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -30,6 +30,7 @@
#include "fm-directory-view.h"
#include "fm-desktop-icon-view.h"
+#include "fm-error-reporting.h"
#include "fm-properties-window.h"
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-zoomable.h>
@@ -140,6 +141,7 @@ struct FMDirectoryViewDetails
gboolean loading;
gboolean menus_merged;
gboolean menu_states_untrustworthy;
+ gboolean reported_load_error;
gboolean show_hidden_files;
gboolean show_backup_files;
@@ -199,6 +201,8 @@ static void load_directory
gboolean force_reload);
static void fm_directory_view_merge_menus (FMDirectoryView *view);
static void real_file_limit_reached (FMDirectoryView *view);
+static void real_load_error (FMDirectoryView *view,
+ GnomeVFSResult result);
static void real_merge_menus (FMDirectoryView *view);
static void real_update_menus (FMDirectoryView *view);
static gboolean real_is_read_only (FMDirectoryView *view);
@@ -346,6 +350,7 @@ fm_directory_view_initialize_class (FMDirectoryViewClass *klass)
klass->supports_zooming = real_supports_zooming;
klass->supports_properties = real_supports_properties;
klass->file_limit_reached = real_file_limit_reached;
+ klass->load_error = real_load_error;
klass->reveal_selection = NULL;
/* Function pointers that subclasses must override */
@@ -1990,6 +1995,26 @@ load_error_callback (NautilusDirectory *directory,
gtk_signal_emit (GTK_OBJECT (view), signals[LOAD_ERROR], load_error_code);
}
+static void
+real_load_error (FMDirectoryView *view, GnomeVFSResult result)
+{
+ g_assert (result != GNOME_VFS_OK);
+
+ /* Report only one error per failed directory load (from the UI
+ * point of view, not from the NautilusDirectory point of view).
+ * Otherwise you can get multiple identical errors caused by
+ * unrelated code that just happens to try to iterate this
+ * directory.
+ */
+ if (!view->details->reported_load_error) {
+ fm_report_error_loading_directory
+ (fm_directory_view_get_directory_as_file (view),
+ result,
+ fm_directory_view_get_containing_window (view));
+ }
+ view->details->reported_load_error = TRUE;
+}
+
/**
* fm_directory_queue_notice_file_change
*
@@ -3497,7 +3522,8 @@ activate_callback (NautilusFile *file, gpointer callback_data)
* the security risk of executing arbitrary commands. */
if (!nautilus_file_is_local (file)) {
nautilus_show_error_dialog (_("Sorry, but you can't execute commands from a remote site due to security considerations."),
- _("Can't execute remote links"), NULL);
+ _("Can't execute remote links"),
+ fm_directory_view_get_containing_window (view));
action = ACTIVATION_ACTION_DO_NOTHING;
} else {
/* as an additional security precaution, we only execute commands without
@@ -3733,6 +3759,7 @@ load_directory (FMDirectoryView *view,
nautilus_file_unref (old_file);
view->details->force_reload = force_reload;
+ view->details->reported_load_error = FALSE;
/* FIXME bugzilla.eazel.com 5062: In theory, we also need to monitor metadata here (as
* well as doing a call when ready), in case external forces
diff --git a/src/file-manager/fm-directory-view.h b/src/file-manager/fm-directory-view.h
index 93dd810a3..83a9404cf 100644
--- a/src/file-manager/fm-directory-view.h
+++ b/src/file-manager/fm-directory-view.h
@@ -2,7 +2,7 @@
/* fm-directory-view.h
*
* Copyright (C) 1999, 2000 Free Software Foundaton
- * Copyright (C) 2000 Eazel, Inc.
+ * Copyright (C) 2000, 2001 Eazel, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -19,7 +19,10 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * Author: Ettore Perazzoli
+ * Authors: Ettore Perazzoli
+ * Darin Adler <darin@eazel.com>
+ * John Sullivan <sullivan@eazel.com>
+ * Pavel Cisler <pavel@eazel.com>
*/
#ifndef FM_DIRECTORY_VIEW_H
@@ -125,10 +128,12 @@ struct FMDirectoryViewClass {
void (* end_loading) (FMDirectoryView *view);
/* The 'load_error' signal is emitted when the directory model
- reports an error in the process of monitoring the directory's
- contents. The load error indicates that the process of
- load the contents has ended, but the directory is still
- being monitored*/
+ * reports an error in the process of monitoring the directory's
+ * contents. The load error indicates that the process of
+ * loading the contents has ended, but the directory is still
+ * being monitored. The default implementation handles common
+ * load failures like ACCESS_DENIED.
+ */
void (* load_error) (FMDirectoryView *view,
GnomeVFSResult result);
diff --git a/src/file-manager/fm-error-reporting.c b/src/file-manager/fm-error-reporting.c
index 184a4b027..2b6acfa39 100644
--- a/src/file-manager/fm-error-reporting.c
+++ b/src/file-manager/fm-error-reporting.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
+#include <libgnomevfs/gnome-vfs-result.h>
#include <libnautilus-extensions/nautilus-file.h>
#include <libnautilus-extensions/nautilus-stock-dialogs.h>
@@ -37,9 +38,42 @@
static void cancel_rename (NautilusFile *file);
void
+fm_report_error_loading_directory (NautilusFile *file,
+ GnomeVFSResult error,
+ GtkWindow *parent_window)
+{
+ char *file_name;
+ char *message;
+
+ if (error == GNOME_VFS_OK) {
+ return;
+ }
+
+ file_name = nautilus_file_get_name (file);
+
+ switch (error) {
+ case GNOME_VFS_ERROR_ACCESS_DENIED:
+ message = g_strdup_printf (_("You do not have the permissions necessary to view the contents of \"%s\"."),
+ file_name);
+ break;
+ default:
+ /* We should invent decent error messages for every case we actually experience. */
+ g_warning ("Hit unhandled case %d (%s) in fm_report_error_loading_directory, tell sullivan@eazel.com",
+ error, gnome_vfs_result_to_string (error));
+ message = g_strdup_printf (_("Sorry, couldn't display all the contents of \"%s\"."), file_name);
+ }
+
+ nautilus_show_error_dialog (message, _("Error Displaying Folder"), parent_window);
+
+ g_free (file_name);
+ g_free (message);
+}
+
+void
fm_report_error_renaming_file (NautilusFile *file,
const char *new_name,
- GnomeVFSResult error)
+ GnomeVFSResult error,
+ GtkWindow *parent_window)
{
char *original_name;
char *message;
@@ -82,7 +116,8 @@ fm_report_error_renaming_file (NautilusFile *file,
break;
default:
/* We should invent decent error messages for every case we actually experience. */
- g_warning ("Hit unhandled case %d in fm_report_error_renaming_file, tell sullivan@eazel.com", error);
+ g_warning ("Hit unhandled case %d (%s) in fm_report_error_renaming_file, tell sullivan@eazel.com",
+ error, gnome_vfs_result_to_string (error));
/* fall through */
message = g_strdup_printf (_("Sorry, couldn't rename \"%s\" to \"%s\"."),
original_name, new_name);
@@ -90,13 +125,14 @@ fm_report_error_renaming_file (NautilusFile *file,
g_free (original_name);
- nautilus_show_error_dialog (message, _("Renaming Error"), NULL);
+ nautilus_show_error_dialog (message, _("Renaming Error"), parent_window);
g_free (message);
}
void
fm_report_error_setting_group (NautilusFile *file,
- GnomeVFSResult error)
+ GnomeVFSResult error,
+ GtkWindow *parent_window)
{
char *file_name;
char *message;
@@ -118,13 +154,14 @@ fm_report_error_setting_group (NautilusFile *file,
break;
default:
/* We should invent decent error messages for every case we actually experience. */
- g_warning ("Hit unhandled case %d in fm_report_error_setting_group, tell sullivan@eazel.com", error);
+ g_warning ("Hit unhandled case %d (%s) in fm_report_error_setting_group, tell sullivan@eazel.com",
+ error, gnome_vfs_result_to_string (error));
file_name = nautilus_file_get_name (file);
message = g_strdup_printf (_("Sorry, couldn't change the group of \"%s\"."), file_name);
g_free (file_name);
}
- nautilus_show_error_dialog (message, _("Error Setting Group"), NULL);
+ nautilus_show_error_dialog (message, _("Error Setting Group"), parent_window);
g_free (file_name);
g_free (message);
@@ -132,7 +169,8 @@ fm_report_error_setting_group (NautilusFile *file,
void
fm_report_error_setting_owner (NautilusFile *file,
- GnomeVFSResult error)
+ GnomeVFSResult error,
+ GtkWindow *parent_window)
{
char *file_name;
char *message;
@@ -150,11 +188,12 @@ fm_report_error_setting_owner (NautilusFile *file,
break;
default:
/* We should invent decent error messages for every case we actually experience. */
- g_warning ("Hit unhandled case %d in fm_report_error_setting_owner, tell sullivan@eazel.com", error);
+ g_warning ("Hit unhandled case %d (%s) in fm_report_error_setting_owner, tell sullivan@eazel.com",
+ error, gnome_vfs_result_to_string (error));
message = g_strdup_printf (_("Sorry, couldn't change the owner of \"%s\"."), file_name);
}
- nautilus_show_error_dialog (message, _("Error Setting Owner"), NULL);
+ nautilus_show_error_dialog (message, _("Error Setting Owner"), parent_window);
g_free (file_name);
g_free (message);
@@ -162,7 +201,8 @@ fm_report_error_setting_owner (NautilusFile *file,
void
fm_report_error_setting_permissions (NautilusFile *file,
- GnomeVFSResult error)
+ GnomeVFSResult error,
+ GtkWindow *parent_window)
{
char *file_name;
char *message;
@@ -180,11 +220,12 @@ fm_report_error_setting_permissions (NautilusFile *file,
break;
default:
/* We should invent decent error messages for every case we actually experience. */
- g_warning ("Hit unhandled case %d in fm_report_error_setting_permissions, tell sullivan@eazel.com", error);
+ g_warning ("Hit unhandled case %d (%s) in fm_report_error_setting_permissions, tell sullivan@eazel.com",
+ error, gnome_vfs_result_to_string (error));
message = g_strdup_printf (_("Sorry, couldn't change the permissions of \"%s\"."), file_name);
}
- nautilus_show_error_dialog (message, _("Error Setting Permissions"), NULL);
+ nautilus_show_error_dialog (message, _("Error Setting Permissions"), parent_window);
g_free (file_name);
g_free (message);
@@ -201,7 +242,7 @@ rename_callback (NautilusFile *file, GnomeVFSResult result, gpointer callback_da
g_assert (name != NULL);
/* If rename failed, notify the user. */
- fm_report_error_renaming_file (file, name, result);
+ fm_report_error_renaming_file (file, name, result, NULL);
cancel_rename (file);
}
diff --git a/src/file-manager/fm-error-reporting.h b/src/file-manager/fm-error-reporting.h
index ed90e867c..5002700d5 100644
--- a/src/file-manager/fm-error-reporting.h
+++ b/src/file-manager/fm-error-reporting.h
@@ -27,18 +27,26 @@
#define FM_ERROR_REPORTING_H
#include <glib.h>
+#include <gtk/gtkwindow.h>
#include <libgnomevfs/gnome-vfs-types.h>
#include <libnautilus-extensions/nautilus-file.h>
+void fm_report_error_loading_directory (NautilusFile *file,
+ GnomeVFSResult error_code,
+ GtkWindow *parent_window);
void fm_report_error_renaming_file (NautilusFile *file,
const char *new_name,
- GnomeVFSResult error_code);
+ GnomeVFSResult error_code,
+ GtkWindow *parent_window);
void fm_report_error_setting_permissions (NautilusFile *file,
- GnomeVFSResult error_code);
+ GnomeVFSResult error_code,
+ GtkWindow *parent_window);
void fm_report_error_setting_owner (NautilusFile *file,
- GnomeVFSResult error_code);
+ GnomeVFSResult error_code,
+ GtkWindow *parent_window);
void fm_report_error_setting_group (NautilusFile *file,
- GnomeVFSResult error_code);
+ GnomeVFSResult error_code,
+ GtkWindow *parent_window);
/* FIXME bugzilla.eazel.com 2394: Should this file be renamed or should these be moved? */
void fm_rename_file (NautilusFile *file,
diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c
index e7fc5f59f..c5e22c0b0 100644
--- a/src/file-manager/fm-properties-window.c
+++ b/src/file-manager/fm-properties-window.c
@@ -355,7 +355,8 @@ rename_callback (NautilusFile *file, GnomeVFSResult result, gpointer callback_da
new_name = window->details->pending_name;
fm_report_error_renaming_file (file,
window->details->pending_name,
- result);
+ result,
+ GTK_WINDOW (window));
/* This can trigger after window destroy, before finalize. */
if (!GTK_OBJECT_DESTROYED (window)) {
name_field_restore_original_name (window->details->name_field);
@@ -667,7 +668,7 @@ group_change_callback (NautilusFile *file, GnomeVFSResult result, gpointer callb
/* Report the error if it's an error. */
nautilus_timed_wait_stop (cancel_group_change_callback, file);
- fm_report_error_setting_group (file, result);
+ fm_report_error_setting_group (file, result, NULL);
nautilus_file_unref (file);
}
@@ -826,7 +827,7 @@ owner_change_callback (NautilusFile *file, GnomeVFSResult result, gpointer callb
/* Report the error if it's an error. */
nautilus_timed_wait_stop (cancel_owner_change_callback, file);
- fm_report_error_setting_owner (file, result);
+ fm_report_error_setting_owner (file, result, NULL);
nautilus_file_unref (file);
}
@@ -1705,7 +1706,7 @@ permission_change_callback (NautilusFile *file, GnomeVFSResult result, gpointer
g_assert (callback_data == NULL);
/* Report the error if it's an error. */
- fm_report_error_setting_permissions (file, result);
+ fm_report_error_setting_permissions (file, result, NULL);
}
static void
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 5298d309e..fec1a5166 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -614,44 +614,6 @@ location_has_really_changed (NautilusWindow *window)
update_title (window);
}
-static gboolean
-handle_unreadable_location (NautilusWindow *window, const char *location)
-{
- NautilusFile *file;
- gboolean unreadable;
- char *file_name;
- char *message;
-
- /* An empty location doesn't jibe with our logic. It will
- * work if there are any characters (even just one space).
- */
- if (location[0] == '\0') {
- return TRUE;
- }
-
- /* FIXME bugzilla.eazel.com 866: Can't expect to read the
- * permissions instantly here. We might need to wait for
- * a stat first.
- */
- file = nautilus_file_get (location);
-
- /* If it's gone, it doesn't count as unreadable, and will be handled
- * by the normal missing-uri mechanism.
- */
- unreadable = !nautilus_file_is_gone (file) && !nautilus_file_can_read (file);
-
- if (unreadable) {
- file_name = nautilus_file_get_name (file);
- message = g_strdup_printf (_("You do not have the permissions necessary to view \"%s\"."), file_name);
- g_free (file_name);
- nautilus_show_error_dialog (message, _("Inadequate Permissions"), GTK_WINDOW (window));
- g_free (message);
- }
-
- nautilus_file_unref (file);
-
- return unreadable;
-}
static NautilusWindow *
get_topmost_nautilus_window (void)
@@ -683,10 +645,6 @@ open_location (NautilusWindow *window,
NautilusWindow *target_window;
gboolean create_new_window;
- if (handle_unreadable_location (window, location)) {
- return;
- }
-
target_window = window;
create_new_window = force_new_window;