Commit a332b89e authored by Cosimo Cecchi's avatar Cosimo Cecchi

file: add an utility to set the file directory

We're going to add some other code in here.
parent cbee96ac
......@@ -271,7 +271,7 @@ nautilus_desktop_icon_file_new (NautilusDesktopLink *link)
eazel_dump_stack_trace ("\t", 10);
#endif
file->details->directory = directory;
nautilus_file_set_directory (file, directory);
icon_file = NAUTILUS_DESKTOP_ICON_FILE (file);
icon_file->details->link = link;
......
......@@ -256,6 +256,8 @@ gboolean nautilus_file_set_display_name (NautilusFile
const char *display_name,
const char *edit_name,
gboolean custom);
void nautilus_file_set_directory (NautilusFile *file,
NautilusDirectory *directory);
void nautilus_file_set_mount (NautilusFile *file,
GMount *mount);
......
......@@ -500,6 +500,14 @@ nautilus_file_clear_info (NautilusFile *file)
clear_metadata (file);
}
void
nautilus_file_set_directory (NautilusFile *file,
NautilusDirectory *directory)
{
g_clear_object (&file->details->directory);
file->details->directory = nautilus_directory_ref (directory);
}
static NautilusFile *
nautilus_file_new_from_filename (NautilusDirectory *directory,
const char *filename,
......@@ -530,8 +538,7 @@ nautilus_file_new_from_filename (NautilusDirectory *directory,
} else {
file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
}
file->details->directory = nautilus_directory_ref (directory);
nautilus_file_set_directory (file, directory);
file->details->name = eel_ref_str_new (filename);
......@@ -634,7 +641,7 @@ nautilus_file_new_from_info (NautilusDirectory *directory,
g_return_val_if_fail (info != NULL, NULL);
file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
file->details->directory = nautilus_directory_ref (directory);
nautilus_file_set_directory (file, directory);
update_info_and_name (file, info);
......@@ -2624,8 +2631,7 @@ nautilus_file_update_name_and_directory (NautilusFile *file,
monitors = nautilus_directory_remove_file_monitors (old_directory, file);
nautilus_directory_remove_file (old_directory, file);
file->details->directory = nautilus_directory_ref (new_directory);
nautilus_directory_unref (old_directory);
nautilus_file_set_directory (file, new_directory);
if (name) {
update_name_internal (file, name, FALSE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment