summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog58
-rw-r--r--idl/Makefile.am5
-rw-r--r--idl/fsextension.idl49
-rw-r--r--libnautilus-extensions/.cvsignore10
-rw-r--r--libnautilus-extensions/Makefile.am20
-rw-r--r--libnautilus-extensions/nautilus-directory-private.h4
-rw-r--r--libnautilus-extensions/nautilus-file.c265
-rw-r--r--libnautilus-extensions/nautilus-metadata.h1
-rw-r--r--libnautilus-private/.cvsignore10
-rw-r--r--libnautilus-private/Makefile.am20
-rw-r--r--libnautilus-private/nautilus-directory-private.h4
-rw-r--r--libnautilus-private/nautilus-file.c265
-rw-r--r--libnautilus-private/nautilus-metadata.h1
-rw-r--r--libnautilus/.cvsignore18
14 files changed, 461 insertions, 269 deletions
diff --git a/ChangeLog b/ChangeLog
index d161932e9..9f1177c14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2000-05-11 Darin Adler <darin@eazel.com>
+
+ * idl/Makefile.am:
+ * idl/fsextension.idl:
+ * libnautilus-extensions/Makefile.am:
+ * libnautilus-extensions/.cvsignore:
+ Removed the fsextension IDL, which was a work in progress that no
+ one is working on.
+
+ * libnautilus/.cvsignore:
+ Added the undo manager stuff.
+
+ * libnautilus-extensions/.cvsignore:
+ Removed the undo manager stuff.
+
+ * libnautilus-extensions/nautilus-directory-private.h:
+ * libnautilus-extensions/nautilus-file.c:
+ (nautilus_file_denies_access_permission): Handle deleted file case.
+ (nautilus_file_can_rename): Handle deleted file case.
+ (file_operation_state_new), (file_operation_state_free),
+ (file_operation_state_complete),
+ (rename_update_info_and_metafile), (rename_callback),
+ (nautilus_file_rename): Put in a basic framework for file
+ operations that can take a while. Used it to make renaming async.
+ (nautilus_file_can_get_permissions): Handle deleted file case.
+ (nautilus_file_set_permissions): Handle case where you can't get
+ permissions properly. I inadvertently delete this last time.
+
+ * libnautilus-extensions/nautilus-metadata.h:
+ Added a metadata key for the icon view sort. Still need to write
+ the code to save this.
+
Thu May 11 16:52:14 2000 Raph Levien <raph@acm.org>
* librsvg/rsvg.c (rsvg_render_bpath): Added a check to avoid
@@ -105,31 +137,29 @@ Thu May 11 16:52:14 2000 Raph Levien <raph@acm.org>
2000-05-10 Gene Z. Ragan <gzr@eazel.com>
- *libnautilus/nautilus-undo-manager-component.idl
- *libnautilus/nautilus-undo-manager-private.h
- *libnautilus/nautilus-undo-manager.c
- *libnautilus/nautilus-undo-manager.h
- *libnautilus/nautilus-undo-transaction.c
- *libnautilus/nautilus-undo-transaction.h
- *libnautilus/nautilus-undoable.c
- *libnautilus/nautilus-undoable.h
-
+ * libnautilus/nautilus-undo-manager-component.idl:
+ * libnautilus/nautilus-undo-manager-private.h:
+ * libnautilus/nautilus-undo-manager.c:
+ * libnautilus/nautilus-undo-manager.h:
+ * libnautilus/nautilus-undo-transaction.c:
+ * libnautilus/nautilus-undo-transaction.h:
+ * libnautilus/nautilus-undoable.c:
+ * libnautilus/nautilus-undoable.h:
Moved files to libnautilus so IDL compilation would work properly
and at the suggestion of mjs.
- *libnautilus-extensions/Makefile.am
+ * libnautilus-extensions/Makefile.am:
Removed undo files.
- *libnautilus/Makefile.am
+ * libnautilus/Makefile.am:
Added undo files.
- *libnautilus/nautilus-undo-manager-component.idl
+ * libnautilus/nautilus-undo-manager-component.idl:
Additional fixes so a clean build would occuer properly.
2000-05-10 J Shane Culpepper <pepper@eazel.com>
- *libnautilus-extensions/nautilus-undo-manger-component.idl
-
+ * libnautilus-extensions/nautilus-undo-manger-component.idl:
Moved the includes to top of the file so that the idl would compile
correctly.
diff --git a/idl/Makefile.am b/idl/Makefile.am
index c3ad1b097..3ee9f27bb 100644
--- a/idl/Makefile.am
+++ b/idl/Makefile.am
@@ -1,3 +1,2 @@
-EXTRA_DIST= \
- GNOME_Desktop_FileOperationService.idl \
- fsextension.idl
+EXTRA_DIST = \
+ GNOME_Desktop_FileOperationService.idl
diff --git a/idl/fsextension.idl b/idl/fsextension.idl
deleted file mode 100644
index ba94f77b3..000000000
--- a/idl/fsextension.idl
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- Three types of extensions:
- Adding directories
- Adding files to a directory
- Adding operations to a file
- */
-module FileManagement {
- enum DirectoryEntryType { DENT_FILE, DENT_DIRECTORY, DENT_LINK };
- union DirectoryEntrySpecifics switch(DirectoryEntryType) {
- case DENT_LINK:
- string target;
- };
- struct Metadatum {
- string key;
- sequence<octet> value;
- };
- struct Action {
- string name, ident;
- };
- struct DirectoryEntry {
- /* Elements:
- 1. Basic file info
- 2. Metadata
- 3. Actions */
-
- /* 1. */
- string name, mime_type;
- long uid, gid, permissions;
- long size;
- long ctime, mtime, atime;
- DirectoryEntrySpecifics info;
-
- /* 2. */
- sequence<Metadatum> metadata;
-
- /* 3. */
- sequence<Action> actions;
- };
- typedef sequence<DirectoryEntry> DirectoryEntryList;
-
- interface VirtualDirectoryReceiver {
- oneway void add_entries(in DirectoryEntryList list, in boolean end_of_listing);
- };
-
- interface VirtualDirectory {
- void request_listing(in string uri, in VirtualDirectoryReceiver vdr);
- oneway void invoke(in string uri, in string action_ident);
- };
-};
diff --git a/libnautilus-extensions/.cvsignore b/libnautilus-extensions/.cvsignore
index 1ab2604c4..9e497d981 100644
--- a/libnautilus-extensions/.cvsignore
+++ b/libnautilus-extensions/.cvsignore
@@ -3,14 +3,4 @@
*.lo
Makefile
Makefile.in
-fsextension-common.c
-fsextension.h
-fsextension_idl_stamp
-fsextension-skels.c
-fsextension-stubs.c
libnautilus-extensions.la
-nautilus-undo-manager-component-common.c
-nautilus-undo-manager-component-skels.c
-nautilus-undo-manager-component-stubs.c
-nautilus-undo-manager-component.h
-nautilus_undo_manager_component_idl_stamp
diff --git a/libnautilus-extensions/Makefile.am b/libnautilus-extensions/Makefile.am
index c29e81e76..557f6a195 100644
--- a/libnautilus-extensions/Makefile.am
+++ b/libnautilus-extensions/Makefile.am
@@ -19,17 +19,9 @@ libnautilus_extensions_la_LDFLAGS=\
$(GNOMECANVASPIXBUF_LIBS) \
$(VFS_LIBS) \
$(XML_LIBS) \
- $(LIBPNG) \
+ $(LIBPNG) \
$(top_src_dir)/libnautilus/.libs/libnautilus.so
-fsextension_idl_sources = \
- fsextension-stubs.c \
- fsextension-skels.c \
- fsextension-common.c \
- fsextension.h
-
-BUILT_SOURCES = $(fsextension_idl_sources)
-
libnautilus_extensionsincludedir=$(includedir)/libnautilus-extensions
libnautilus_extensionsinclude_HEADERS= \
@@ -118,14 +110,4 @@ libnautilus_extensions_la_SOURCES = \
nautilus-string-list.c \
nautilus-string.c \
nautilus-xml-extensions.c \
- $(fsextension_idl_sources) \
$(NULL)
-
-$(fsextension_idl_sources): fsextension_idl_stamp
-fsextension_idl_stamp: $(top_srcdir)/idl/fsextension.idl
- orbit-idl -I${datadir}/idl `gnome-config --cflags idl` $(top_srcdir)/idl/fsextension.idl
- touch fsextension_idl_stamp
-
-CLEANFILES = fsextension_idl_stamp
-
-EXTRA_DIST = $(top_srcdir)/idl/fsextension.idl $(top_srcdir)/idl/GNOME_Desktop_FileOperationService.idl
diff --git a/libnautilus-extensions/nautilus-directory-private.h b/libnautilus-extensions/nautilus-directory-private.h
index 7c2f4d351..74184399b 100644
--- a/libnautilus-extensions/nautilus-directory-private.h
+++ b/libnautilus-extensions/nautilus-directory-private.h
@@ -70,12 +70,14 @@ struct NautilusDirectoryDetails
GList *pending_file_info; /* list of GnomeVFSFileInfo's that are pending */
guint dequeue_pending_idle_id;
- GList *get_file_infos_in_progress; /* list of GnomeVFSAsyncHandle* */
+ GList *get_file_infos_in_progress; /* list of GnomeVFSAsyncHandle * */
GnomeVFSAsyncHandle *count_in_progress;
NautilusFile *count_file;
TopLeftTextReadState *top_left_read_state;
+
+ GList *file_operations_in_progress; /* list of FileOperation * */
};
typedef struct {
diff --git a/libnautilus-extensions/nautilus-file.c b/libnautilus-extensions/nautilus-file.c
index 34cbf06b2..ccc186b7c 100644
--- a/libnautilus-extensions/nautilus-file.c
+++ b/libnautilus-extensions/nautilus-file.c
@@ -317,6 +317,11 @@ nautilus_file_denies_access_permission (NautilusFile *file,
{
g_assert (NAUTILUS_IS_FILE (file));
+ /* Once the file is gone, you can't do much of anything. */
+ if (nautilus_file_is_gone (file)) {
+ return TRUE;
+ }
+
if (!nautilus_file_can_get_permissions (file)) {
/*
* File's permissions field is not valid.
@@ -442,6 +447,11 @@ nautilus_file_can_rename (NautilusFile *file)
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
+ /* Nonexistent files can't be renamed. */
+ if (nautilus_file_is_gone (file)) {
+ return FALSE;
+ }
+
/* User must have write permissions for the parent directory. */
parent = get_file_for_parent_directory (file);
@@ -460,24 +470,143 @@ nautilus_file_can_rename (NautilusFile *file)
return result;
}
+typedef struct {
+ NautilusFile *file;
+ GnomeVFSAsyncHandle *handle;
+ NautilusFileOperationCallback callback;
+ gpointer callback_data;
+
+ /* Operation-specific data. */
+ char *new_name; /* rename */
+} FileOperationState;
+
+static FileOperationState *
+file_operation_state_new (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data)
+{
+ FileOperationState *state;
+
+ nautilus_file_ref (file);
+
+ state = g_new0 (FileOperationState, 1);
+ state->file = file;
+ state->callback = callback;
+ state->callback_data = callback_data;
+
+ return state;
+}
+
+static void
+file_operation_state_free (FileOperationState *state)
+{
+ nautilus_file_unref (state->file);
+ g_free (state->new_name);
+ g_free (state);
+}
+
+static void
+file_operation_state_complete (FileOperationState *state,
+ GnomeVFSResult result)
+{
+ /* Claim that something changed even if the operation failed.
+ * This makes it easier for some clients who see the "reverting"
+ * as "changing back".
+ */
+ nautilus_file_changed (state->file);
+ (* state->callback) (state->file, result, state->callback_data);
+ file_operation_state_free (state);
+}
+
+static void
+rename_update_info_and_metafile (FileOperationState *state)
+{
+ xmlNode *file_node;
+
+ file_node = nautilus_directory_get_file_metadata_node
+ (state->file->details->directory,
+ state->file->details->info->name,
+ FALSE);
+
+ if (file_node != NULL) {
+ xmlSetProp (file_node,
+ METADATA_NODE_NAME_FOR_FILE_NAME,
+ state->new_name);
+ nautilus_directory_request_write_metafile
+ (state->file->details->directory);
+ }
+
+ g_free (state->file->details->info->name);
+ state->file->details->info->name = g_strdup (state->new_name);
+}
+
+static int
+rename_callback (GnomeVFSAsyncHandle *handle,
+ GnomeVFSXferProgressInfo *info,
+ gpointer callback_data)
+{
+ FileOperationState *state;
+
+ state = callback_data;
+ g_assert (handle == state->handle);
+ g_assert (info != NULL);
+
+ /* We aren't really interested in progress, but we do need to see
+ * when the transfer is done or fails.
+ */
+
+ switch (info->status) {
+ case GNOME_VFS_XFER_PROGRESS_STATUS_OK:
+ if (info->phase == GNOME_VFS_XFER_PHASE_COMPLETED) {
+ /* Here's the case where we are done renaming and we succeed. */
+ rename_update_info_and_metafile (state);
+ file_operation_state_complete (state, GNOME_VFS_OK);
+ }
+ break;
+ case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR:
+ /* Here's the case where we are done renaming and we fail. */
+ file_operation_state_complete (state, info->vfs_status);
+ return GNOME_VFS_XFER_ERROR_ACTION_ABORT;
+ default:
+ break;
+ }
+
+ /* FIXME: Pavel says I should return this, but he promises
+ * he will fix the API.
+ */
+ return 1;
+}
+
void
nautilus_file_rename (NautilusFile *file,
const char *new_name,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
- GnomeVFSURI *new_uri;
- char *old_uri_text;
- char *new_uri_text;
+ char *directory_uri_text;
+ GList *source_name_list, *target_name_list;
GnomeVFSResult result;
- xmlNode *file_node;
+ FileOperationState *state;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (new_name != NULL);
g_return_if_fail (callback != NULL);
- /* Can't rename a file that's already gone. */
+ /* FIXME bugzilla.eazel.com 645:
+ * Make sure this returns an error for incoming names
+ * containing path separators.
+ */
+
+ /* Can't rename a file that's already gone.
+ * We need to check this here because there may be a new
+ * file with the same name.
+ */
if (nautilus_file_is_gone (file)) {
+ /* Claim that something changed even if the rename failed.
+ * This makes it easier for some clients who see the "reverting"
+ * to the old name as "changing back".
+ */
+ nautilus_file_changed (file);
(* callback) (file, GNOME_VFS_ERROR_NOTFOUND, callback_data);
return;
}
@@ -491,45 +620,36 @@ nautilus_file_rename (NautilusFile *file,
return;
}
- old_uri_text = nautilus_file_get_uri (file);
- new_uri = gnome_vfs_uri_append_path
- (file->details->directory->details->uri, new_name);
- new_uri_text = gnome_vfs_uri_to_string (new_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (new_uri);
+ state = file_operation_state_new (file, callback, callback_data);
+ state->new_name = g_strdup (new_name);
+
+ directory_uri_text = nautilus_directory_get_uri (file->details->directory);
+ source_name_list = g_list_prepend (NULL, file->details->info->name);
+ target_name_list = g_list_prepend (NULL, (char *) new_name);
+ result = gnome_vfs_async_xfer
+ (&state->handle,
+ directory_uri_text, source_name_list,
+ directory_uri_text, target_name_list,
+ GNOME_VFS_XFER_SAMEFS | GNOME_VFS_XFER_REMOVESOURCE,
+ GNOME_VFS_XFER_ERROR_MODE_QUERY,
+ GNOME_VFS_XFER_OVERWRITE_MODE_ABORT,
+ rename_callback, state,
+ NULL, NULL);
+ g_free (directory_uri_text);
+ g_list_free (source_name_list);
+ g_list_free (target_name_list);
- /* FIXME bugzilla.eazel.com 435:
- * Should handle possibility of slow asynch call here.
- */
- result = gnome_vfs_move (old_uri_text, new_uri_text, FALSE);
- if (result == GNOME_VFS_OK) {
- file_node = nautilus_directory_get_file_metadata_node
- (file->details->directory,
- file->details->info->name,
- FALSE);
-
- if (file_node != NULL) {
- xmlSetProp (file_node, METADATA_NODE_NAME_FOR_FILE_NAME, new_name);
- nautilus_directory_request_write_metafile (file->details->directory);
- }
-
- /* FIXME bugzilla.eazel.com 645:
- * Make sure this does something sensible with incoming names
- * containing path separators.
+ if (result != GNOME_VFS_OK) {
+ file_operation_state_free (state);
+
+ /* Claim that something changed even if the rename failed.
+ * This makes it easier for some clients who see the "reverting"
+ * to the old name as "changing back".
*/
- g_free (file->details->info->name);
- file->details->info->name = g_strdup (new_name);
+ nautilus_file_changed (file);
+ (* callback) (file, result, callback_data);
+ return;
}
-
- g_free (old_uri_text);
- g_free (new_uri_text);
-
- /* Claim that something changed even if the rename failed.
- * This makes it easier for some clients who see the "reverting"
- * to the old name as "changing back".
- */
- nautilus_file_changed (file);
-
- (* callback) (file, result, callback_data);
}
gboolean
@@ -563,8 +683,9 @@ nautilus_file_matches_uri (NautilusFile *file, const char *uri_string)
gboolean
nautilus_file_update (NautilusFile *file, GnomeVFSFileInfo *info)
{
- if (gnome_vfs_file_info_matches (file->details->info, info))
+ if (gnome_vfs_file_info_matches (file->details->info, info)) {
return FALSE;
+ }
gnome_vfs_file_info_unref (file->details->info);
gnome_vfs_file_info_ref (info);
@@ -827,13 +948,11 @@ nautilus_file_compare_for_sort_internal (NautilusFile *file_1,
}
if (reversed) {
- return gnome_vfs_file_info_compare_for_sort_reversed (file_1->details->info,
- file_2->details->info,
- rules);
+ return gnome_vfs_file_info_compare_for_sort_reversed
+ (file_1->details->info, file_2->details->info, rules);
} else {
- return gnome_vfs_file_info_compare_for_sort (file_1->details->info,
- file_2->details->info,
- rules);
+ return gnome_vfs_file_info_compare_for_sort
+ (file_1->details->info, file_2->details->info, rules);
}
}
@@ -967,9 +1086,8 @@ nautilus_file_monitor_remove (NautilusFile *file,
/* return the uri associated with the passed-in file, which may not be the actual uri if
the file is an old-style gmc link or a nautilus xml file */
-
char *
-nautilus_file_get_mapped_uri(NautilusFile *file)
+nautilus_file_get_mapped_uri (NautilusFile *file)
{
char* actual_uri;
GnomeVFSResult result;
@@ -978,26 +1096,26 @@ nautilus_file_get_mapped_uri(NautilusFile *file)
GnomeVFSFileSize bytes_read;
/* first get the actual uri */
-
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- actual_uri = nautilus_file_get_uri(file);
- if (actual_uri == NULL)
+ actual_uri = nautilus_file_get_uri (file);
+ if (actual_uri == NULL) {
return NULL;
+ }
+ /* FIXME: Need to use async. I/O. */
/* see if it's a gmc style URI by reading the first part of the file */
-
result = gnome_vfs_open (&handle, actual_uri, GNOME_VFS_OPEN_READ);
if (result == GNOME_VFS_OK) {
result = gnome_vfs_read (handle, buffer, sizeof (buffer), &bytes_read);
if (result == GNOME_VFS_OK || result == GNOME_VFS_ERROR_EOF) {
- if (nautilus_str_has_prefix(buffer, "URL: ")) {
- char *eol = strchr(buffer, '\n');
+ if (nautilus_str_has_prefix (buffer, "URL: ")) {
+ char *eol = strchr (buffer, '\n');
if (eol)
*eol = '\0';
- if (strlen(buffer) <= bytes_read) {
- g_free(actual_uri);
- actual_uri = g_strdup(buffer + 5);
+ if (strlen (buffer) <= bytes_read) {
+ g_free (actual_uri);
+ actual_uri = g_strdup (buffer + 5);
}
}
}
@@ -1005,11 +1123,10 @@ nautilus_file_get_mapped_uri(NautilusFile *file)
}
/* see if it's a nautilus link xml file - if so, open and parse the file to fetch the uri */
-
- if (nautilus_link_is_link_file(actual_uri)) {
+ if (nautilus_link_is_link_file (actual_uri)) {
char *old_uri = actual_uri;
- actual_uri = nautilus_link_get_link_uri(actual_uri);
- g_free(old_uri);
+ actual_uri = nautilus_link_get_link_uri (actual_uri);
+ g_free (old_uri);
}
/* all done so return the result */
@@ -1025,8 +1142,9 @@ nautilus_file_get_uri (NautilusFile *file)
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- uri = gnome_vfs_uri_append_path (file->details->directory->details->uri,
- file->details->info->name);
+ uri = gnome_vfs_uri_append_path
+ (file->details->directory->details->uri,
+ file->details->info->name);
uri_text = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
gnome_vfs_uri_unref (uri);
return uri_text;
@@ -1166,6 +1284,9 @@ nautilus_file_get_size (NautilusFile *file)
gboolean
nautilus_file_can_get_permissions (NautilusFile *file)
{
+ if (nautilus_file_is_gone (file)) {
+ return FALSE;
+ }
return (file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS) != 0;
}
@@ -1207,7 +1328,8 @@ nautilus_file_can_set_permissions (NautilusFile *file)
}
GnomeVFSFilePermissions
-nautilus_file_get_permissions (NautilusFile *file) {
+nautilus_file_get_permissions (NautilusFile *file)
+{
g_return_val_if_fail (nautilus_file_can_get_permissions (file), 0);
return file->details->info->permissions;
@@ -1236,6 +1358,16 @@ nautilus_file_set_permissions (NautilusFile *file,
GnomeVFSResult result;
GnomeVFSFileInfo *partial_file_info;
char *uri;
+
+ if (!nautilus_file_can_set_permissions (file)) {
+ /* Claim that something changed even if the permission change failed.
+ * This makes it easier for some clients who see the "reverting"
+ * to the old permissions as "changing back".
+ */
+ nautilus_file_changed (file);
+ (* callback) (file, GNOME_VFS_ERROR_ACCESSDENIED, callback_data);
+ return;
+ }
if (new_permissions == file->details->info->permissions) {
(* callback) (file, GNOME_VFS_OK, callback_data);
@@ -1261,7 +1393,6 @@ nautilus_file_set_permissions (NautilusFile *file,
* to the old permissions as "changing back".
*/
nautilus_file_changed (file);
-
(* callback) (file, result, callback_data);
}
diff --git a/libnautilus-extensions/nautilus-metadata.h b/libnautilus-extensions/nautilus-metadata.h
index 5aac2fa10..650f5b5b1 100644
--- a/libnautilus-extensions/nautilus-metadata.h
+++ b/libnautilus-extensions/nautilus-metadata.h
@@ -39,6 +39,7 @@
#define NAUTILUS_METADATA_KEY_ICON_VIEW_ZOOM_LEVEL "ICONS_ZOOM_LEVEL"
#define NAUTILUS_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT "ICONS_AUTO_LAYOUT"
+#define NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY "ICONS_SORT_BY"
#define NAUTILUS_METADATA_KEY_LIST_VIEW_ZOOM_LEVEL "LIST_ZOOM_LEVEL"
#define NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN "LIST_SORT_COLUMN"
diff --git a/libnautilus-private/.cvsignore b/libnautilus-private/.cvsignore
index 1ab2604c4..9e497d981 100644
--- a/libnautilus-private/.cvsignore
+++ b/libnautilus-private/.cvsignore
@@ -3,14 +3,4 @@
*.lo
Makefile
Makefile.in
-fsextension-common.c
-fsextension.h
-fsextension_idl_stamp
-fsextension-skels.c
-fsextension-stubs.c
libnautilus-extensions.la
-nautilus-undo-manager-component-common.c
-nautilus-undo-manager-component-skels.c
-nautilus-undo-manager-component-stubs.c
-nautilus-undo-manager-component.h
-nautilus_undo_manager_component_idl_stamp
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am
index c29e81e76..557f6a195 100644
--- a/libnautilus-private/Makefile.am
+++ b/libnautilus-private/Makefile.am
@@ -19,17 +19,9 @@ libnautilus_extensions_la_LDFLAGS=\
$(GNOMECANVASPIXBUF_LIBS) \
$(VFS_LIBS) \
$(XML_LIBS) \
- $(LIBPNG) \
+ $(LIBPNG) \
$(top_src_dir)/libnautilus/.libs/libnautilus.so
-fsextension_idl_sources = \
- fsextension-stubs.c \
- fsextension-skels.c \
- fsextension-common.c \
- fsextension.h
-
-BUILT_SOURCES = $(fsextension_idl_sources)
-
libnautilus_extensionsincludedir=$(includedir)/libnautilus-extensions
libnautilus_extensionsinclude_HEADERS= \
@@ -118,14 +110,4 @@ libnautilus_extensions_la_SOURCES = \
nautilus-string-list.c \
nautilus-string.c \
nautilus-xml-extensions.c \
- $(fsextension_idl_sources) \
$(NULL)
-
-$(fsextension_idl_sources): fsextension_idl_stamp
-fsextension_idl_stamp: $(top_srcdir)/idl/fsextension.idl
- orbit-idl -I${datadir}/idl `gnome-config --cflags idl` $(top_srcdir)/idl/fsextension.idl
- touch fsextension_idl_stamp
-
-CLEANFILES = fsextension_idl_stamp
-
-EXTRA_DIST = $(top_srcdir)/idl/fsextension.idl $(top_srcdir)/idl/GNOME_Desktop_FileOperationService.idl
diff --git a/libnautilus-private/nautilus-directory-private.h b/libnautilus-private/nautilus-directory-private.h
index 7c2f4d351..74184399b 100644
--- a/libnautilus-private/nautilus-directory-private.h
+++ b/libnautilus-private/nautilus-directory-private.h
@@ -70,12 +70,14 @@ struct NautilusDirectoryDetails
GList *pending_file_info; /* list of GnomeVFSFileInfo's that are pending */
guint dequeue_pending_idle_id;
- GList *get_file_infos_in_progress; /* list of GnomeVFSAsyncHandle* */
+ GList *get_file_infos_in_progress; /* list of GnomeVFSAsyncHandle * */
GnomeVFSAsyncHandle *count_in_progress;
NautilusFile *count_file;
TopLeftTextReadState *top_left_read_state;
+
+ GList *file_operations_in_progress; /* list of FileOperation * */
};
typedef struct {
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 34cbf06b2..ccc186b7c 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -317,6 +317,11 @@ nautilus_file_denies_access_permission (NautilusFile *file,
{
g_assert (NAUTILUS_IS_FILE (file));
+ /* Once the file is gone, you can't do much of anything. */
+ if (nautilus_file_is_gone (file)) {
+ return TRUE;
+ }
+
if (!nautilus_file_can_get_permissions (file)) {
/*
* File's permissions field is not valid.
@@ -442,6 +447,11 @@ nautilus_file_can_rename (NautilusFile *file)
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
+ /* Nonexistent files can't be renamed. */
+ if (nautilus_file_is_gone (file)) {
+ return FALSE;
+ }
+
/* User must have write permissions for the parent directory. */
parent = get_file_for_parent_directory (file);
@@ -460,24 +470,143 @@ nautilus_file_can_rename (NautilusFile *file)
return result;
}
+typedef struct {
+ NautilusFile *file;
+ GnomeVFSAsyncHandle *handle;
+ NautilusFileOperationCallback callback;
+ gpointer callback_data;
+
+ /* Operation-specific data. */
+ char *new_name; /* rename */
+} FileOperationState;
+
+static FileOperationState *
+file_operation_state_new (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data)
+{
+ FileOperationState *state;
+
+ nautilus_file_ref (file);
+
+ state = g_new0 (FileOperationState, 1);
+ state->file = file;
+ state->callback = callback;
+ state->callback_data = callback_data;
+
+ return state;
+}
+
+static void
+file_operation_state_free (FileOperationState *state)
+{
+ nautilus_file_unref (state->file);
+ g_free (state->new_name);
+ g_free (state);
+}
+
+static void
+file_operation_state_complete (FileOperationState *state,
+ GnomeVFSResult result)
+{
+ /* Claim that something changed even if the operation failed.
+ * This makes it easier for some clients who see the "reverting"
+ * as "changing back".
+ */
+ nautilus_file_changed (state->file);
+ (* state->callback) (state->file, result, state->callback_data);
+ file_operation_state_free (state);
+}
+
+static void
+rename_update_info_and_metafile (FileOperationState *state)
+{
+ xmlNode *file_node;
+
+ file_node = nautilus_directory_get_file_metadata_node
+ (state->file->details->directory,
+ state->file->details->info->name,
+ FALSE);
+
+ if (file_node != NULL) {
+ xmlSetProp (file_node,
+ METADATA_NODE_NAME_FOR_FILE_NAME,
+ state->new_name);
+ nautilus_directory_request_write_metafile
+ (state->file->details->directory);
+ }
+
+ g_free (state->file->details->info->name);
+ state->file->details->info->name = g_strdup (state->new_name);
+}
+
+static int
+rename_callback (GnomeVFSAsyncHandle *handle,
+ GnomeVFSXferProgressInfo *info,
+ gpointer callback_data)
+{
+ FileOperationState *state;
+
+ state = callback_data;
+ g_assert (handle == state->handle);
+ g_assert (info != NULL);
+
+ /* We aren't really interested in progress, but we do need to see
+ * when the transfer is done or fails.
+ */
+
+ switch (info->status) {
+ case GNOME_VFS_XFER_PROGRESS_STATUS_OK:
+ if (info->phase == GNOME_VFS_XFER_PHASE_COMPLETED) {
+ /* Here's the case where we are done renaming and we succeed. */
+ rename_update_info_and_metafile (state);
+ file_operation_state_complete (state, GNOME_VFS_OK);
+ }
+ break;
+ case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR:
+ /* Here's the case where we are done renaming and we fail. */
+ file_operation_state_complete (state, info->vfs_status);
+ return GNOME_VFS_XFER_ERROR_ACTION_ABORT;
+ default:
+ break;
+ }
+
+ /* FIXME: Pavel says I should return this, but he promises
+ * he will fix the API.
+ */
+ return 1;
+}
+
void
nautilus_file_rename (NautilusFile *file,
const char *new_name,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
- GnomeVFSURI *new_uri;
- char *old_uri_text;
- char *new_uri_text;
+ char *directory_uri_text;
+ GList *source_name_list, *target_name_list;
GnomeVFSResult result;
- xmlNode *file_node;
+ FileOperationState *state;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (new_name != NULL);
g_return_if_fail (callback != NULL);
- /* Can't rename a file that's already gone. */
+ /* FIXME bugzilla.eazel.com 645:
+ * Make sure this returns an error for incoming names
+ * containing path separators.
+ */
+
+ /* Can't rename a file that's already gone.
+ * We need to check this here because there may be a new
+ * file with the same name.
+ */
if (nautilus_file_is_gone (file)) {
+ /* Claim that something changed even if the rename failed.
+ * This makes it easier for some clients who see the "reverting"
+ * to the old name as "changing back".
+ */
+ nautilus_file_changed (file);
(* callback) (file, GNOME_VFS_ERROR_NOTFOUND, callback_data);
return;
}
@@ -491,45 +620,36 @@ nautilus_file_rename (NautilusFile *file,
return;
}
- old_uri_text = nautilus_file_get_uri (file);
- new_uri = gnome_vfs_uri_append_path
- (file->details->directory->details->uri, new_name);
- new_uri_text = gnome_vfs_uri_to_string (new_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (new_uri);
+ state = file_operation_state_new (file, callback, callback_data);
+ state->new_name = g_strdup (new_name);
+
+ directory_uri_text = nautilus_directory_get_uri (file->details->directory);
+ source_name_list = g_list_prepend (NULL, file->details->info->name);
+ target_name_list = g_list_prepend (NULL, (char *) new_name);
+ result = gnome_vfs_async_xfer
+ (&state->handle,
+ directory_uri_text, source_name_list,
+ directory_uri_text, target_name_list,
+ GNOME_VFS_XFER_SAMEFS | GNOME_VFS_XFER_REMOVESOURCE,
+ GNOME_VFS_XFER_ERROR_MODE_QUERY,
+ GNOME_VFS_XFER_OVERWRITE_MODE_ABORT,
+ rename_callback, state,
+ NULL, NULL);
+ g_free (directory_uri_text);
+ g_list_free (source_name_list);
+ g_list_free (target_name_list);
- /* FIXME bugzilla.eazel.com 435:
- * Should handle possibility of slow asynch call here.
- */
- result = gnome_vfs_move (old_uri_text, new_uri_text, FALSE);
- if (result == GNOME_VFS_OK) {
- file_node = nautilus_directory_get_file_metadata_node
- (file->details->directory,
- file->details->info->name,
- FALSE);
-
- if (file_node != NULL) {
- xmlSetProp (file_node, METADATA_NODE_NAME_FOR_FILE_NAME, new_name);
- nautilus_directory_request_write_metafile (file->details->directory);
- }
-
- /* FIXME bugzilla.eazel.com 645:
- * Make sure this does something sensible with incoming names
- * containing path separators.
+ if (result != GNOME_VFS_OK) {
+ file_operation_state_free (state);
+
+ /* Claim that something changed even if the rename failed.
+ * This makes it easier for some clients who see the "reverting"
+ * to the old name as "changing back".
*/
- g_free (file->details->info->name);
- file->details->info->name = g_strdup (new_name);
+ nautilus_file_changed (file);
+ (* callback) (file, result, callback_data);
+ return;
}
-
- g_free (old_uri_text);
- g_free (new_uri_text);
-
- /* Claim that something changed even if the rename failed.
- * This makes it easier for some clients who see the "reverting"
- * to the old name as "changing back".
- */
- nautilus_file_changed (file);
-
- (* callback) (file, result, callback_data);
}
gboolean
@@ -563,8 +683,9 @@ nautilus_file_matches_uri (NautilusFile *file, const char *uri_string)
gboolean
nautilus_file_update (NautilusFile *file, GnomeVFSFileInfo *info)
{
- if (gnome_vfs_file_info_matches (file->details->info, info))
+ if (gnome_vfs_file_info_matches (file->details->info, info)) {
return FALSE;
+ }
gnome_vfs_file_info_unref (file->details->info);
gnome_vfs_file_info_ref (info);
@@ -827,13 +948,11 @@ nautilus_file_compare_for_sort_internal (NautilusFile *file_1,
}
if (reversed) {
- return gnome_vfs_file_info_compare_for_sort_reversed (file_1->details->info,
- file_2->details->info,
- rules);
+ return gnome_vfs_file_info_compare_for_sort_reversed
+ (file_1->details->info, file_2->details->info, rules);
} else {
- return gnome_vfs_file_info_compare_for_sort (file_1->details->info,
- file_2->details->info,
- rules);
+ return gnome_vfs_file_info_compare_for_sort
+ (file_1->details->info, file_2->details->info, rules);
}
}
@@ -967,9 +1086,8 @@ nautilus_file_monitor_remove (NautilusFile *file,
/* return the uri associated with the passed-in file, which may not be the actual uri if
the file is an old-style gmc link or a nautilus xml file */
-
char *
-nautilus_file_get_mapped_uri(NautilusFile *file)
+nautilus_file_get_mapped_uri (NautilusFile *file)
{
char* actual_uri;
GnomeVFSResult result;
@@ -978,26 +1096,26 @@ nautilus_file_get_mapped_uri(NautilusFile *file)
GnomeVFSFileSize bytes_read;
/* first get the actual uri */
-
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- actual_uri = nautilus_file_get_uri(file);
- if (actual_uri == NULL)
+ actual_uri = nautilus_file_get_uri (file);
+ if (actual_uri == NULL) {
return NULL;
+ }
+ /* FIXME: Need to use async. I/O. */
/* see if it's a gmc style URI by reading the first part of the file */
-
result = gnome_vfs_open (&handle, actual_uri, GNOME_VFS_OPEN_READ);
if (result == GNOME_VFS_OK) {
result = gnome_vfs_read (handle, buffer, sizeof (buffer), &bytes_read);
if (result == GNOME_VFS_OK || result == GNOME_VFS_ERROR_EOF) {
- if (nautilus_str_has_prefix(buffer, "URL: ")) {
- char *eol = strchr(buffer, '\n');
+ if (nautilus_str_has_prefix (buffer, "URL: ")) {
+ char *eol = strchr (buffer, '\n');
if (eol)
*eol = '\0';
- if (strlen(buffer) <= bytes_read) {
- g_free(actual_uri);
- actual_uri = g_strdup(buffer + 5);
+ if (strlen (buffer) <= bytes_read) {
+ g_free (actual_uri);
+ actual_uri = g_strdup (buffer + 5);
}
}
}
@@ -1005,11 +1123,10 @@ nautilus_file_get_mapped_uri(NautilusFile *file)
}
/* see if it's a nautilus link xml file - if so, open and parse the file to fetch the uri */
-
- if (nautilus_link_is_link_file(actual_uri)) {
+ if (nautilus_link_is_link_file (actual_uri)) {
char *old_uri = actual_uri;
- actual_uri = nautilus_link_get_link_uri(actual_uri);
- g_free(old_uri);
+ actual_uri = nautilus_link_get_link_uri (actual_uri);
+ g_free (old_uri);
}
/* all done so return the result */
@@ -1025,8 +1142,9 @@ nautilus_file_get_uri (NautilusFile *file)
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- uri = gnome_vfs_uri_append_path (file->details->directory->details->uri,
- file->details->info->name);
+ uri = gnome_vfs_uri_append_path
+ (file->details->directory->details->uri,
+ file->details->info->name);
uri_text = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
gnome_vfs_uri_unref (uri);
return uri_text;
@@ -1166,6 +1284,9 @@ nautilus_file_get_size (NautilusFile *file)
gboolean
nautilus_file_can_get_permissions (NautilusFile *file)
{
+ if (nautilus_file_is_gone (file)) {
+ return FALSE;
+ }
return (file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS) != 0;
}
@@ -1207,7 +1328,8 @@ nautilus_file_can_set_permissions (NautilusFile *file)
}
GnomeVFSFilePermissions
-nautilus_file_get_permissions (NautilusFile *file) {
+nautilus_file_get_permissions (NautilusFile *file)
+{
g_return_val_if_fail (nautilus_file_can_get_permissions (file), 0);
return file->details->info->permissions;
@@ -1236,6 +1358,16 @@ nautilus_file_set_permissions (NautilusFile *file,
GnomeVFSResult result;
GnomeVFSFileInfo *partial_file_info;
char *uri;
+
+ if (!nautilus_file_can_set_permissions (file)) {
+ /* Claim that something changed even if the permission change failed.
+ * This makes it easier for some clients who see the "reverting"
+ * to the old permissions as "changing back".
+ */
+ nautilus_file_changed (file);
+ (* callback) (file, GNOME_VFS_ERROR_ACCESSDENIED, callback_data);
+ return;
+ }
if (new_permissions == file->details->info->permissions) {
(* callback) (file, GNOME_VFS_OK, callback_data);
@@ -1261,7 +1393,6 @@ nautilus_file_set_permissions (NautilusFile *file,
* to the old permissions as "changing back".
*/
nautilus_file_changed (file);
-
(* callback) (file, result, callback_data);
}
diff --git a/libnautilus-private/nautilus-metadata.h b/libnautilus-private/nautilus-metadata.h
index 5aac2fa10..650f5b5b1 100644
--- a/libnautilus-private/nautilus-metadata.h
+++ b/libnautilus-private/nautilus-metadata.h
@@ -39,6 +39,7 @@
#define NAUTILUS_METADATA_KEY_ICON_VIEW_ZOOM_LEVEL "ICONS_ZOOM_LEVEL"
#define NAUTILUS_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT "ICONS_AUTO_LAYOUT"
+#define NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY "ICONS_SORT_BY"
#define NAUTILUS_METADATA_KEY_LIST_VIEW_ZOOM_LEVEL "LIST_ZOOM_LEVEL"
#define NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN "LIST_SORT_COLUMN"
diff --git a/libnautilus/.cvsignore b/libnautilus/.cvsignore
index 1386f604f..ac14f1dac 100644
--- a/libnautilus/.cvsignore
+++ b/libnautilus/.cvsignore
@@ -4,16 +4,16 @@
Makefile
Makefile.in
libnautilus.la
-nautilus.h
-nautilus-stubs.c
-nautilus-skels.c
nautilus-common.c
-nautilus-view-component-stubs.c
-nautilus-view-component-skels.c
+nautilus-skels.c
+nautilus-stubs.c
+nautilus-undo-manager-component-common.c
+nautilus-undo-manager-component-skels.c
+nautilus-undo-manager-component-stubs.c
+nautilus-undo-manager-component.h
nautilus-view-component-common.c
+nautilus-view-component-skels.c
+nautilus-view-component-stubs.c
nautilus-view-component.h
+nautilus_undo_manager_component_idl_stamp
nautilus_view_component_idl_stamp
-fsextension.h
-fsextension-stubs.c
-fsextension-skels.c
-fsextension-common.c