Commit f804c9ac authored by Darin Adler's avatar Darin Adler

Store icon positions as "x,y" in ICON_POSITION instead of

	storing ICON_X and ICON_Y.

	Take first step in moving the directory view to use the opaque
	NautilusDirectory and NautilusFile instead of using gnome-vfs
	directly. This will separate the controller from the model:
	FMDirectoryView is a controller and NautilusDirectory a model.

	* src/file-manager/fm-directory-view-icons.c:
	(add_to_icon_container):
	(fm_directory_view_icons_icon_moved_cb):
	Store icons positions as "x,y" in ICON_POSITION instead of storing
	separate numbers in ICON_X and ICON_Y.

	* libnautilus/nautilus-directory.h:
	libnautilus/nautilus-directory.c:
	(nautilus_directory_get_uri):
	Added a new call needed to replace fm_directory_view_get_uri.
	(nautilus_directory_get_file_metadata):
	(nautilus_directory_set_file_metadata):
	(nautilus_file_get_metadata):
	(nautilus_file_set_metadata):
	Moved the calls for getting and setting file metadata into the
	file objects.
	(nautilus_directory_new_file):
	(nautilus_file_get_info):
	Added temporary interfaces for the current situation where we're
	dealing with both NautilusFile and GnomeVFSFileInfo objects at
	once.
	(nautilus_directory_finalize):
	Detach and unref all the files when the directory is destroyed.
	(nautilus_file_unref):
	(nautilus_file_get_name):
	Implemented these functions now that we are using them.

	* src/file-manager/fm-directory-view.h:
	src/file-manager/fm-directory-view.c:
	(fm_directory_view_add_entry):
	(fm_directory_view_activate_entry):
	(display_selection_info):
	(fm_directory_view_get_selection):
	src/file-manager/fm-directory-view-icons.c:
	(add_to_icon_container):
	(fm_directory_view_icons_icon_moved_cb):
	(dm_directory_view_icons_add_entry):
	(fm_directory_view_icons_get_selection):
	(icon_container_activate_cb):
	src/file-manager/fm-directory-view-list.c:
	(add_to_flist):
	(fm_directory_view_list_add_entry):
	Change all the code to work with NautilusFile instead of
	GnomeVFSFileInfo, except for the parts of FMDirectoryView dealing
	with the directory_list.

	* src/file-manager/fm-directory-view.h:
	src/file-manager/fm-directory-view.c:
	(nautilus_file_date_as_string):
	(nautilus_file_size_as_string):
	(nautilus_file_type_as_string):
	libnautilus/nautilus-directory.h:
	libnautilus/nautilus-directory.c:
	(nautilus_file_get_date_as_string):
	(nautilus_file_get_size_as_string):
	(nautilus_file_get_type_as_string):
	Moved and renamed these functions and made them work on
	NautilusFile objects.
parent 430ca69c
2000-01-20 Darin Adler <darin@eazel.com>
Store icon positions as "x,y" in ICON_POSITION instead of
storing ICON_X and ICON_Y.
Take first step in moving the directory view to use the opaque
NautilusDirectory and NautilusFile instead of using gnome-vfs
directly. This will separate the controller from the model:
FMDirectoryView is a controller and NautilusDirectory a model.
* src/file-manager/fm-directory-view-icons.c:
(add_to_icon_container):
(fm_directory_view_icons_icon_moved_cb):
Store icons positions as "x,y" in ICON_POSITION instead of storing
separate numbers in ICON_X and ICON_Y.
* libnautilus/nautilus-directory.h:
libnautilus/nautilus-directory.c:
(nautilus_directory_get_uri):
Added a new call needed to replace fm_directory_view_get_uri.
(nautilus_directory_get_file_metadata):
(nautilus_directory_set_file_metadata):
(nautilus_file_get_metadata):
(nautilus_file_set_metadata):
Moved the calls for getting and setting file metadata into the
file objects.
(nautilus_directory_new_file):
(nautilus_file_get_info):
Added temporary interfaces for the current situation where we're
dealing with both NautilusFile and GnomeVFSFileInfo objects at
once.
(nautilus_directory_finalize):
Detach and unref all the files when the directory is destroyed.
(nautilus_file_unref):
(nautilus_file_get_name):
Implemented these functions now that we are using them.
* src/file-manager/fm-directory-view.h:
src/file-manager/fm-directory-view.c:
(fm_directory_view_add_entry):
(fm_directory_view_activate_entry):
(display_selection_info):
(fm_directory_view_get_selection):
src/file-manager/fm-directory-view-icons.c:
(add_to_icon_container):
(fm_directory_view_icons_icon_moved_cb):
(dm_directory_view_icons_add_entry):
(fm_directory_view_icons_get_selection):
(icon_container_activate_cb):
src/file-manager/fm-directory-view-list.c:
(add_to_flist):
(fm_directory_view_list_add_entry):
Change all the code to work with NautilusFile instead of
GnomeVFSFileInfo, except for the parts of FMDirectoryView dealing
with the directory_list.
* src/file-manager/fm-directory-view.h:
src/file-manager/fm-directory-view.c:
(nautilus_file_date_as_string):
(nautilus_file_size_as_string):
(nautilus_file_type_as_string):
libnautilus/nautilus-directory.h:
libnautilus/nautilus-directory.c:
(nautilus_file_get_date_as_string):
(nautilus_file_get_size_as_string):
(nautilus_file_get_type_as_string):
Moved and renamed these functions and made them work on
NautilusFile objects.
2000-01-20 John Sullivan <sullivan@eazel.com>
* src/file-manager/fm-directory-view.c: (display_selection_info):
......
......@@ -35,6 +35,7 @@
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-async-ops.h>
......@@ -90,6 +91,10 @@ struct _NautilusDirectoryDetails
struct _NautilusFile
{
guint ref_count;
NautilusDirectory *directory;
GnomeVFSFileInfo *info;
};
static GHashTable* directory_objects;
......@@ -123,6 +128,22 @@ nautilus_directory_finalize (GtkObject *object)
g_hash_table_remove (directory_objects, directory->details->uri_text);
/* Unref all the files. */
while (directory->details->files != NULL) {
NautilusFile *file;
file = directory->details->files->data;
/* Detach the file from this directory. */
g_assert (file->directory == directory);
file->directory = NULL;
/* Let the reference go. */
nautilus_file_unref (file);
directory->details->files = g_list_remove_link (directory->details->files, directory->details->files);
}
g_free (directory->details->uri_text);
if (directory->details->uri != NULL)
gnome_vfs_uri_unref (directory->details->uri);
......@@ -181,6 +202,14 @@ nautilus_directory_get (const char *uri)
return directory;
}
char *
nautilus_directory_get_uri (NautilusDirectory *directory)
{
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
return g_strdup (directory->details->uri_text);
}
/* This reads the metafile synchronously. This must go eventually.
To do this asynchronously we'd need a way to read an entire file
with async. calls; currently you can only get the file length with
......@@ -617,7 +646,7 @@ nautilus_directory_set_metadata (NautilusDirectory *directory,
nautilus_directory_request_write_metafile (directory);
}
char *
static char *
nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
......@@ -635,7 +664,7 @@ nautilus_directory_get_file_metadata (NautilusDirectory *directory,
/* The children represent the files.
This linear search is temporary.
Eventually, we'll have a pointer from the FMFile right to
Eventually, we'll have a pointer from the NautilusFile right to
the corresponding XML node, or we won't have the XML tree
in memory at all.
*/
......@@ -651,7 +680,7 @@ nautilus_directory_get_file_metadata (NautilusDirectory *directory,
(child, tag, default_metadata);
}
void
static void
nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
......@@ -690,7 +719,7 @@ nautilus_directory_set_file_metadata (NautilusDirectory *directory,
/* The children represent the files.
This linear search is temporary.
Eventually, we'll have a pointer from the FMFile right to
Eventually, we'll have a pointer from the NautilusFile right to
the corresponding XML node, or we won't have the XML tree
in memory at all.
*/
......@@ -715,6 +744,152 @@ nautilus_directory_set_file_metadata (NautilusDirectory *directory,
nautilus_directory_request_write_metafile (directory);
}
NautilusFile *
nautilus_directory_new_file (NautilusDirectory *directory, GnomeVFSFileInfo *info)
{
NautilusFile *file;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
g_return_val_if_fail (info != NULL, NULL);
gnome_vfs_file_info_ref (info);
file = g_new (NautilusFile, 1);
file->ref_count = 1;
file->directory = directory;
file->info = info;
directory->details->files = g_list_prepend (directory->details->files, file);
return file;
}
void
nautilus_file_unref (NautilusFile *file)
{
g_return_if_fail (file != NULL);
g_return_if_fail (file->ref_count != 0);
/* Decrement the ref count. */
if (--file->ref_count != 0)
return;
/* Destroy the file object. */
g_assert (file->directory == NULL);
gnome_vfs_file_info_unref (file->info);
}
char *
nautilus_file_get_metadata (NautilusFile *file,
const char *tag,
const char *default_metadata)
{
g_return_val_if_fail (file != NULL, NULL);
return nautilus_directory_get_file_metadata (file->directory, file->info->name, tag, default_metadata);
}
void
nautilus_file_set_metadata (NautilusFile *file,
const char *tag,
const char *default_metadata,
const char *metadata)
{
g_return_if_fail (file != NULL);
nautilus_directory_set_file_metadata (file->directory, file->info->name, tag, default_metadata, metadata);
}
char *
nautilus_file_get_name (NautilusFile *file)
{
g_return_val_if_fail (file != NULL, NULL);
return g_strdup (file->info->name);
}
GnomeVFSFileInfo *
nautilus_file_get_info (NautilusFile *file)
{
g_return_val_if_fail (file != NULL, NULL);
return file->info;
}
/**
* nautilus_file_get_date_as_string:
*
* Get a user-displayable string representing a file modification date.
* The caller is responsible for g_free-ing this string.
* @file: NautilusFile representing the file in question.
*
* Returns: Newly allocated string ready to display to the user.
*
**/
gchar *
nautilus_file_get_date_as_string (NautilusFile *file)
{
/* Note: There's also accessed time and changed time.
* Accessed time doesn't seem worth showing to the user.
* Changed time is only subtly different from modified time
* (changed time includes "metadata" changes like file permissions).
* We should not display both, but we might change our minds as to
* which one is better.
*/
g_return_val_if_fail (file != NULL, NULL);
/* Note that ctime is a funky function that returns a
* string that you're not supposed to free.
*/
return g_strdup (ctime (&file->info->mtime));
}
/**
* nautilus_file_get_size_as_string:
*
* Get a user-displayable string representing a file size. The caller
* is responsible for g_free-ing this string.
* @file: NautilusFile representing the file in question.
*
* Returns: Newly allocated string ready to display to the user.
*
**/
gchar *
nautilus_file_get_size_as_string (NautilusFile *file)
{
g_return_val_if_fail (file != NULL, NULL);
if (file->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
return g_strdup (_("--"));
return gnome_vfs_file_size_to_string (file->info->size);
}
/**
* nautilus_file_get_type_as_string:
*
* Get a user-displayable string representing a file type. The caller
* is responsible for g_free-ing this string.
* @file: NautilusFile representing the file in question.
*
* Returns: Newly allocated string ready to display to the user.
*
**/
gchar *
nautilus_file_get_type_as_string (NautilusFile *file)
{
g_return_val_if_fail (file != NULL, NULL);
if (file->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
/* Special-case this so it isn't "special/directory".
* Should this be "folder" instead?
*/
return g_strdup (_("directory"));
return g_strdup (file->info->mime_type);
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
static int data_dummy;
......
......@@ -26,6 +26,7 @@
#define NAUTILUS_DIRECTORY_H
#include <gtk/gtkobject.h>
#include <libgnomevfs/gnome-vfs-types.h>
/* NautilusDirectory is a class that manages the model for a directory,
real or virtual, for Nautilus, mainly the file-manager component. The directory is
......@@ -73,23 +74,16 @@ GtkType nautilus_directory_get_type (void);
*/
NautilusDirectory *nautilus_directory_get (const char *uri);
char * nautilus_directory_get_uri (NautilusDirectory *directory);
/* Simple preliminary interface for getting and setting metadata. */
char * nautilus_directory_get_metadata (NautilusDirectory *directory,
const char *tag,
const char *default_metadata);
char * nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
const char *default_metadata);
void nautilus_directory_set_metadata (NautilusDirectory *directory,
const char *tag,
const char *default_metadata,
const char *metadata);
void nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
const char *default_metadata,
const char *metadata);
/* Get the current files.
Instead of returning the list of files, this function uses a callback.
......@@ -106,17 +100,38 @@ void nautilus_directory_get_files (NautilusDirectory
*/
gboolean nautilus_directory_is_ready_for_layout (NautilusDirectory *directory);
/* Temporary interface for NautilusFile while we are phasing it in. */
NautilusFile * nautilus_directory_new_file (NautilusDirectory *directory,
GnomeVFSFileInfo *info);
GnomeVFSFileInfo * nautilus_file_get_info (NautilusFile *file);
/* Basic operations on file objects. */
void nautilus_file_ref (NautilusFile *file);
void nautilus_file_unref (NautilusFile *file);
char * nautilus_file_get_name (NautilusFile *file);
/* Utility functions for formatting file-related information.
* FIXME: Probably these should be moved to some appropriate place in libnautilus.
*/
char * nautilus_file_get_date_as_string (NautilusFile *file);
char * nautilus_file_get_size_as_string (NautilusFile *file);
char * nautilus_file_get_type_as_string (NautilusFile *file);
/* Return true if this file has already been deleted.
This object will be unref'd after sending the files_removed signal,
but it could hang around longer if someone ref'd it.
*/
gboolean nautilus_file_is_gone (NautilusFile *file);
/* Simple preliminary interface for getting and setting metadata. */
char * nautilus_file_get_metadata (NautilusFile *file,
const char *tag,
const char *default_metadata);
void nautilus_file_set_metadata (NautilusFile *file,
const char *tag,
const char *default_metadata,
const char *metadata);
typedef struct _NautilusDirectoryDetails NautilusDirectoryDetails;
struct _NautilusDirectory
......
......@@ -35,6 +35,7 @@
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-async-ops.h>
......@@ -90,6 +91,10 @@ struct _NautilusDirectoryDetails
struct _NautilusFile
{
guint ref_count;
NautilusDirectory *directory;
GnomeVFSFileInfo *info;
};
static GHashTable* directory_objects;
......@@ -123,6 +128,22 @@ nautilus_directory_finalize (GtkObject *object)
g_hash_table_remove (directory_objects, directory->details->uri_text);
/* Unref all the files. */
while (directory->details->files != NULL) {
NautilusFile *file;
file = directory->details->files->data;
/* Detach the file from this directory. */
g_assert (file->directory == directory);
file->directory = NULL;
/* Let the reference go. */
nautilus_file_unref (file);
directory->details->files = g_list_remove_link (directory->details->files, directory->details->files);
}
g_free (directory->details->uri_text);
if (directory->details->uri != NULL)
gnome_vfs_uri_unref (directory->details->uri);
......@@ -181,6 +202,14 @@ nautilus_directory_get (const char *uri)
return directory;
}
char *
nautilus_directory_get_uri (NautilusDirectory *directory)
{
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
return g_strdup (directory->details->uri_text);
}
/* This reads the metafile synchronously. This must go eventually.
To do this asynchronously we'd need a way to read an entire file
with async. calls; currently you can only get the file length with
......@@ -617,7 +646,7 @@ nautilus_directory_set_metadata (NautilusDirectory *directory,
nautilus_directory_request_write_metafile (directory);
}
char *
static char *
nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
......@@ -635,7 +664,7 @@ nautilus_directory_get_file_metadata (NautilusDirectory *directory,
/* The children represent the files.
This linear search is temporary.
Eventually, we'll have a pointer from the FMFile right to
Eventually, we'll have a pointer from the NautilusFile right to
the corresponding XML node, or we won't have the XML tree
in memory at all.
*/
......@@ -651,7 +680,7 @@ nautilus_directory_get_file_metadata (NautilusDirectory *directory,
(child, tag, default_metadata);
}
void
static void
nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
......@@ -690,7 +719,7 @@ nautilus_directory_set_file_metadata (NautilusDirectory *directory,
/* The children represent the files.
This linear search is temporary.
Eventually, we'll have a pointer from the FMFile right to
Eventually, we'll have a pointer from the NautilusFile right to
the corresponding XML node, or we won't have the XML tree
in memory at all.
*/
......@@ -715,6 +744,152 @@ nautilus_directory_set_file_metadata (NautilusDirectory *directory,
nautilus_directory_request_write_metafile (directory);
}
NautilusFile *
nautilus_directory_new_file (NautilusDirectory *directory, GnomeVFSFileInfo *info)
{
NautilusFile *file;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
g_return_val_if_fail (info != NULL, NULL);
gnome_vfs_file_info_ref (info);
file = g_new (NautilusFile, 1);
file->ref_count = 1;
file->directory = directory;
file->info = info;
directory->details->files = g_list_prepend (directory->details->files, file);
return file;
}
void
nautilus_file_unref (NautilusFile *file)
{
g_return_if_fail (file != NULL);
g_return_if_fail (file->ref_count != 0);
/* Decrement the ref count. */
if (--file->ref_count != 0)
return;
/* Destroy the file object. */
g_assert (file->directory == NULL);
gnome_vfs_file_info_unref (file->info);
}
char *
nautilus_file_get_metadata (NautilusFile *file,
const char *tag,
const char *default_metadata)
{
g_return_val_if_fail (file != NULL, NULL);
return nautilus_directory_get_file_metadata (file->directory, file->info->name, tag, default_metadata);
}
void
nautilus_file_set_metadata (NautilusFile *file,
const char *tag,
const char *default_metadata,
const char *metadata)
{
g_return_if_fail (file != NULL);
nautilus_directory_set_file_metadata (file->directory, file->info->name, tag, default_metadata, metadata);
}
char *
nautilus_file_get_name (NautilusFile *file)
{
g_return_val_if_fail (file != NULL, NULL);
return g_strdup (file->info->name);
}
GnomeVFSFileInfo *
nautilus_file_get_info (NautilusFile *file)
{
g_return_val_if_fail (file != NULL, NULL);
return file->info;
}
/**
* nautilus_file_get_date_as_string:
*
* Get a user-displayable string representing a file modification date.
* The caller is responsible for g_free-ing this string.
* @file: NautilusFile representing the file in question.
*
* Returns: Newly allocated string ready to display to the user.
*
**/
gchar *
nautilus_file_get_date_as_string (NautilusFile *file)
{
/* Note: There's also accessed time and changed time.
* Accessed time doesn't seem worth showing to the user.
* Changed time is only subtly different from modified time
* (changed time includes "metadata" changes like file permissions).
* We should not display both, but we might change our minds as to
* which one is better.
*/
g_return_val_if_fail (file != NULL, NULL);
/* Note that ctime is a funky function that returns a
* string that you're not supposed to free.
*/
return g_strdup (ctime (&file->info->mtime));
}
/**
* nautilus_file_get_size_as_string:
*
* Get a user-displayable string representing a file size. The caller
* is responsible for g_free-ing this string.
* @file: NautilusFile representing the file in question.
*
* Returns: Newly allocated string ready to display to the user.
*
**/
gchar *
nautilus_file_get_size_as_string (NautilusFile *file)
{
g_return_val_if_fail (file != NULL, NULL);
if (file->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
return g_strdup (_("--"));
return gnome_vfs_file_size_to_string (file->info->size);
}
/**
* nautilus_file_get_type_as_string:
*
* Get a user-displayable string representing a file type. The caller
* is responsible for g_free-ing this string.
* @file: NautilusFile representing the file in question.
*
* Returns: Newly allocated string ready to display to the user.
*
**/
gchar *
nautilus_file_get_type_as_string (NautilusFile *file)
{
g_return_val_if_fail (file != NULL, NULL);
if (file->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
/* Special-case this so it isn't "special/directory".
* Should this be "folder" instead?
*/
return g_strdup (_("directory"));
return g_strdup (file->info->mime_type);
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
static int data_dummy;
......
......@@ -26,6 +26,7 @@
#define NAUTILUS_DIRECTORY_H
#include <gtk/gtkobject.h>
#include <libgnomevfs/gnome-vfs-types.h>
/* NautilusDirectory is a class that manages the model for a directory,
real or virtual, for Nautilus, mainly the file-manager component. The directory is
......@@ -73,23 +74,16 @@ GtkType nautilus_directory_get_type (void);
*/
NautilusDirectory *nautilus_directory_get (const char *uri);
char * nautilus_directory_get_uri (NautilusDirectory *directory);
/* Simple preliminary interface for getting and setting metadata. */
char * nautilus_directory_get_metadata (NautilusDirectory *directory,
const char *tag,
const char *default_metadata);
char * nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
const char *default_metadata);
void nautilus_directory_set_metadata (NautilusDirectory *directory,
const char *tag,
const char *default_metadata,
const char *metadata);
void nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
const char *default_metadata,
const char *metadata);
/* Get the current files.
Instead of returning the list of files, this function uses a callback.
......@@ -106,17 +100,38 @@ void nautilus_directory_get_files (NautilusDirectory
*/
gboolean nautilus_directory_is_ready_for_layout (NautilusDirectory *directory);
/* Temporary interface for NautilusFile while we are phasing it in. */
NautilusFile * nautilus_directory_new_file (NautilusDirectory *directory,
GnomeVFSFileInfo *info);
GnomeVFSFileInfo * nautilus_file_get_info (NautilusFile *file);
/* Basic operations on file objects. */
void nautilus_file_ref (NautilusFile *file);
void nautilus_file_unref (NautilusFile *file);
char * nautilus_file_get_name (NautilusFile *file);
/* Utility functions for formatting file-related information.
* FIXME: Probably these should be moved to some appropriate place in libnautilus.
*/
char * nautilus_file_get_date_as_string (NautilusFile *file);
char * nautilus_file_get_size_as_string (NautilusFile *file);
char * nautilus_file_get_type_as_string (NautilusFile *file);
/* Return true if this file has already been deleted.
This object will be unref'd after sending the files_removed signal,
but it could hang around longer if someone ref'd it.
*/
gboolean nautilus_file_is_gone (NautilusFile *file);
/* Simple preliminary interface for getting and setting metadata. */
char * nautilus_file_get_metadata (NautilusFile *file,
const char *tag,
const char *default_metadata);
void nautilus_file_set_metadata (NautilusFile *file,
const char *tag,
const char *default_metadata,
const char *metadata);
typedef struct _NautilusDirectoryDetails NautilusDirectoryDetails;
struct _NautilusDirectory
......
......@@ -35,6 +35,7 @@
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-async-ops.h>
......@@ -90,6 +91,10 @@ struct _NautilusDirectoryDetails
struct _NautilusFile
{
guint ref_count;
NautilusDirectory *directory;
GnomeVFSFileInfo *info;
};
static GHashTable* directory_objects;
......@@ -123,6 +128,22 @@ nautilus_directory_finalize (GtkObject *object)
g_hash_table_remove (directory_objects, directory->details->uri_text);
/* Unref all the files. */
while (directory->details->files != NULL) {
NautilusFile *file;
file = directory->details->files->data;
/* Detach the file from this directory. */
g_assert (file->directory == directory);
file->directory = NULL;
/* Let the reference go. */
nautilus_file_unref (file);
directory->details->files = g_list_remove_link (directory->details->files, directory->details->files);