summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-file.c
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2000-12-29 21:01:44 +0000
committerDarin Adler <darin@src.gnome.org>2000-12-29 21:01:44 +0000
commit47a828d5502a1b3abf7d92f01c2e69c78c52bcea (patch)
tree3a692b16214cbc74a505001ce385497e2fcef246 /libnautilus-private/nautilus-file.c
parent7c3b04d2ac14263b50c339897dc315dc2b155500 (diff)
downloadnautilus-47a828d5502a1b3abf7d92f01c2e69c78c52bcea.tar.gz
reviewed by: Gene Ragan <gzr@eazel.com>
Fixed bug 5067 (Moving a file doesn't update the directory in the link hash table). Fixed bug 5366 (error when passing two directories on the command line). * libnautilus-extensions/nautilus-directory.c: (nautilus_directory_remove_file): Change code that was doing "== FALSE" which is not such good style. (nautilus_directory_notify_files_moved): Change to properly update file names in all cases and to update the directory with a new nautilus_file_set_directory function. * libnautilus-extensions/nautilus-file-private.h: Moved the Knowledge enum up here. I was going to make a change that required it, and now I don't feel like moving it back. * libnautilus-extensions/nautilus-file.h: Add nautilus_file_set_directory (and reformat). * libnautilus-extensions/nautilus-file.c: (is_self_owned), (destroy): Moved is_self_owned so the destroy function can use it. (update_info_internal): Call the update_links functions before (nautilus_file_set_directory): New function that changes the parent directory and updates everything appropriately. (nautilus_file_mark_gone): Added a check that the file is not already marked gone. * src/nautilus-main.c: (main): Sort the command-line options, add some single-character versions, add code to initialize the "geometry" variable for the case where the option is not passed, removed some unused code that sets start_desktop twice.
Diffstat (limited to 'libnautilus-private/nautilus-file.c')
-rw-r--r--libnautilus-private/nautilus-file.c73
1 files changed, 53 insertions, 20 deletions
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 232bb9aaa..48e446bf0 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -80,15 +80,6 @@ typedef struct {
gpointer callback_data;
} Operation;
-/* These are in sort order. Known things come first, then things
- * where we can't know, finally things where we don't yet know.
- */
-typedef enum {
- KNOWN,
- UNKNOWABLE,
- UNKNOWN
-} Knowledge;
-
typedef GList * (* ModifyListFunction) (GList *list, NautilusFile *file);
enum {
@@ -157,8 +148,8 @@ nautilus_file_new_from_relative_uri (NautilusDirectory *directory,
#endif
nautilus_directory_ref (directory);
-
file->details->directory = directory;
+
file->details->relative_uri = g_strdup (relative_uri);
return file;
@@ -390,6 +381,12 @@ nautilus_file_get (const char *uri)
return nautilus_file_get_internal (uri, TRUE);
}
+static gboolean
+is_self_owned (NautilusFile *file)
+{
+ return file->details->directory->details->as_file == file;
+}
+
static void
destroy (GtkObject *object)
{
@@ -406,7 +403,7 @@ destroy (GtkObject *object)
directory = file->details->directory;
- if (directory->details->as_file == file) {
+ if (is_self_owned (file)) {
directory->details->as_file = NULL;
} else {
if (!file->details->is_gone) {
@@ -464,12 +461,6 @@ nautilus_file_unref (NautilusFile *file)
gtk_object_unref (GTK_OBJECT (file));
}
-static gboolean
-is_self_owned (NautilusFile *file)
-{
- return file->details->directory->details->as_file == file;
-}
-
/**
* nautilus_file_get_parent_uri_for_display:
*
@@ -1112,7 +1103,7 @@ static void
update_links_if_target (NautilusFile *target_file)
{
GList *link_files, *p;
-
+
link_files = get_link_files (target_file);
for (p = link_files; p != NULL; p = p->next) {
update_link (NAUTILUS_FILE (p->data), target_file);
@@ -1229,6 +1220,46 @@ nautilus_file_update_name (NautilusFile *file, const char *name)
return TRUE;
}
+void
+nautilus_file_set_directory (NautilusFile *file,
+ NautilusDirectory *new_directory)
+{
+ NautilusDirectory *old_directory;
+
+ g_return_if_fail (NAUTILUS_IS_FILE (file));
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (file->details->directory));
+ g_return_if_fail (!file->details->is_gone);
+ g_return_if_fail (!is_self_owned (file));
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (new_directory));
+
+ old_directory = file->details->directory;
+ if (old_directory == new_directory) {
+ return;
+ }
+
+ nautilus_file_ref (file);
+
+ /* FIXME bugzilla.eazel.com 2044: Need to let links that
+ * point to the old name know that the file has been moved.
+ */
+
+ remove_from_link_hash_table (file);
+
+ nautilus_directory_remove_file (old_directory, file);
+
+ nautilus_directory_ref (new_directory);
+ file->details->directory = new_directory;
+ nautilus_directory_unref (old_directory);
+
+ nautilus_directory_add_file (new_directory, file);
+
+ add_to_link_hash_table (file);
+
+ update_links_if_target (file);
+
+ nautilus_file_unref (file);
+}
+
static Knowledge
get_item_count (NautilusFile *file,
guint *count)
@@ -4131,6 +4162,8 @@ nautilus_file_mark_gone (NautilusFile *file)
{
NautilusDirectory *directory;
+ g_return_if_fail (!file->details->is_gone);
+
file->details->is_gone = TRUE;
update_links_if_target (file);
@@ -4381,13 +4414,13 @@ nautilus_file_invalidate_attributes_internal (NautilusFile *file,
void
nautilus_file_invalidate_attributes (NautilusFile *file,
- GList *file_attributes)
+ GList *file_attributes)
{
/* Cancel possible in-progress loads of any of these attributes */
nautilus_directory_cancel_loading_file_attributes (file->details->directory,
file,
file_attributes);
-
+
/* Actually invalidate the values */
nautilus_file_invalidate_attributes_internal (file, file_attributes);