Commit e82bab8c authored by Darin Adler's avatar Darin Adler

reviewed by: John Sullivan <sullivan@eazel.com>

	Fixed bug 2147 (NautilusFile for trash needs non-empty values for
	more properties), bug 5652 (MIME type field appears but shouldn't
	in properties window for Trash), and bug 4620 (trash sidebar
	should show number of items).

	* libnautilus-extensions/nautilus-file.h:
	* libnautilus-extensions/nautilus-file-private.h:
	* libnautilus-extensions/nautilus-file.c:
	(nautilus_file_new_from_relative_uri): Create trash file subclass
	when appropriate.
	(nautilus_file_info_missing): Rename so it can be used in other
	source files.
	(nautilus_file_get_date): New method that returns numeric dates.
	(nautilus_file_get_date_as_string): Change to call
	nautilus_file_get_date to get the numeric date.
	(nautilus_file_get_file_type): Turn into a method.

	* libnautilus-extensions/nautilus-merged-directory.h:
	* libnautilus-extensions/nautilus-merged-directory.c:
	(merged_call_when_ready): Rolled in the old
	merged_callback_connect_directory function.
	(merged_contains_file): Moved down to a more appropriate part of
	the source file.
	(nautilus_merged_directory_get_real_directories): New public
	function for use by trash.

	* libnautilus-extensions/nautilus-trash-file.c:
	(trash_callback_hash), (trash_callback_equal),
	(trash_callback_destroy), (trash_callback_check_done),
	(trash_callback_remove_file), (ready_callback),
	(real_file_changed_callback), (monitor_add_file), (add_real_file),
	(trash_callback_remove_file_cover), (monitor_remove_file),
	(remove_real_file), (add_real_file_given_directory),
	(add_directory_callback), (remove_directory_callback),
	(trash_file_call_when_ready), (trash_file_cancel_call_when_ready),
	(trash_file_check_if_ready), (trash_file_monitor_add),
	(trash_file_monitor_remove), (trash_file_get_file_type),
	(trash_file_get_item_count), (trash_file_get_deep_counts),
	(trash_file_get_date), (remove_all_real_files),
	(nautilus_trash_file_initialize), (trash_destroy),
	(nautilus_trash_file_initialize_class):
	New code. First implementation of getting some attributes for the
	merged trash. Gets list of directories from the
	NautilusTrashDirectory object. The code in here is similar to the
	NautilusMergedDirectory class and at some point perhaps we can
	make the two share more.

	* libnautilus-extensions/nautilus-vfs-file.c:
	(vfs_file_get_file_type), (vfs_file_get_date),
	(nautilus_vfs_file_initialize_class): Implement the two new
	methods for the standard vfs case.

	Fixed various things that affect the properties window for the
	trash that showed up while I was testing the above work:

	* libnautilus-extensions/nautilus-icon-factory.c:
	(nautilus_icon_factory_get_icon_name_for_regular_file),
	(nautilus_icon_factory_get_icon_name_for_file): Move trash special
	case out so it doesn't matter what type the trash seems to be. The
	old code relied on trash not being a directory.

	* src/file-manager/fm-properties-window.c:
	(create_properties_window), (create_properties_window_callback),
	(cancel_create_properties_window_callback),
	(directory_view_destroyed_callback), (remove_pending_file): Rework
	code to fix problems where the timed wait or the signal handler
	wasn't properly cleaned up.

	Fixed remaining bit of bug 5631 (Tear-offs of right-click menus
	don't work.):

	* src/file-manager/nautilus-desktop-icon-view-ui.xml: Mark Disks
	right-click submenu so it won't get a tear-off item.

	Fixed bug 5650 (nautilus --quit fails to return to prompt
	sometimes):

	* src/nautilus-application.c: (nautilus_application_startup): Add
	special case so "nautilus --quit" doesn't hang waiting for a
	response from the (now quit) "server" instance of Nautilus.
	* src/nautilus-shell-interface.idl: Had to make the quit call no
	longer be "oneway" to get it to work right, otherwise the quit
	message could be lost when the sending application exited too
	fast.

	Fix bug 5675 (Nitpicks in new "could not be moved to new special
	location" dialog):

	* libnautilus-extensions/nautilus-file-operations.c:
	(handle_transfer_overwrite): Updated message wording as Eli (and
	Vera) suggest.

	Other changes:

	* libnautilus-extensions/nautilus-view-identifier.c:
	(get_lang_list): Fix comment and a small storage leak in the case
	where lang_with_locale is non-NULL but empty.

	* po/POTFILES.ignore: Obsolete file, no longer used.

	* src/file-manager/fm-desktop-icon-view.c:
	(update_home_link_and_delete_copies): Update comment to help
	translators understand better.

	* libnautilus-extensions/nautilus-directory-async.c:
	(directory_load_callback): Added a new assertion that could help
	in future gnome-vfs debugging.

	* libnautilus/nautilus-view-component.idl: Removed long-ago-fixed
	FIXME comment.

	* src/nautilus-window-manage-views.c: Tweak spacing.
parent aee3945e
2001-01-18 Darin Adler <darin@eazel.com>
reviewed by: John Sullivan <sullivan@eazel.com>
Fixed bug 2147 (NautilusFile for trash needs non-empty values for
more properties), bug 5652 (MIME type field appears but shouldn't
in properties window for Trash), and bug 4620 (trash sidebar
should show number of items).
* libnautilus-extensions/nautilus-file.h:
* libnautilus-extensions/nautilus-file-private.h:
* libnautilus-extensions/nautilus-file.c:
(nautilus_file_new_from_relative_uri): Create trash file subclass
when appropriate.
(nautilus_file_info_missing): Rename so it can be used in other
source files.
(nautilus_file_get_date): New method that returns numeric dates.
(nautilus_file_get_date_as_string): Change to call
nautilus_file_get_date to get the numeric date.
(nautilus_file_get_file_type): Turn into a method.
* libnautilus-extensions/nautilus-merged-directory.h:
* libnautilus-extensions/nautilus-merged-directory.c:
(merged_call_when_ready): Rolled in the old
merged_callback_connect_directory function.
(merged_contains_file): Moved down to a more appropriate part of
the source file.
(nautilus_merged_directory_get_real_directories): New public
function for use by trash.
* libnautilus-extensions/nautilus-trash-file.c:
(trash_callback_hash), (trash_callback_equal),
(trash_callback_destroy), (trash_callback_check_done),
(trash_callback_remove_file), (ready_callback),
(real_file_changed_callback), (monitor_add_file), (add_real_file),
(trash_callback_remove_file_cover), (monitor_remove_file),
(remove_real_file), (add_real_file_given_directory),
(add_directory_callback), (remove_directory_callback),
(trash_file_call_when_ready), (trash_file_cancel_call_when_ready),
(trash_file_check_if_ready), (trash_file_monitor_add),
(trash_file_monitor_remove), (trash_file_get_file_type),
(trash_file_get_item_count), (trash_file_get_deep_counts),
(trash_file_get_date), (remove_all_real_files),
(nautilus_trash_file_initialize), (trash_destroy),
(nautilus_trash_file_initialize_class):
New code. First implementation of getting some attributes for the
merged trash. Gets list of directories from the
NautilusTrashDirectory object. The code in here is similar to the
NautilusMergedDirectory class and at some point perhaps we can
make the two share more.
* libnautilus-extensions/nautilus-vfs-file.c:
(vfs_file_get_file_type), (vfs_file_get_date),
(nautilus_vfs_file_initialize_class): Implement the two new
methods for the standard vfs case.
Fixed various things that affect the properties window for the
trash that showed up while I was testing the above work:
* libnautilus-extensions/nautilus-icon-factory.c:
(nautilus_icon_factory_get_icon_name_for_regular_file),
(nautilus_icon_factory_get_icon_name_for_file): Move trash special
case out so it doesn't matter what type the trash seems to be. The
old code relied on trash not being a directory.
* src/file-manager/fm-properties-window.c:
(create_properties_window), (create_properties_window_callback),
(cancel_create_properties_window_callback),
(directory_view_destroyed_callback), (remove_pending_file): Rework
code to fix problems where the timed wait or the signal handler
wasn't properly cleaned up.
Fixed remaining bit of bug 5631 (Tear-offs of right-click menus
don't work.):
* src/file-manager/nautilus-desktop-icon-view-ui.xml: Mark Disks
right-click submenu so it won't get a tear-off item.
Fixed bug 5650 (nautilus --quit fails to return to prompt
sometimes):
* src/nautilus-application.c: (nautilus_application_startup): Add
special case so "nautilus --quit" doesn't hang waiting for a
response from the (now quit) "server" instance of Nautilus.
* src/nautilus-shell-interface.idl: Had to make the quit call no
longer be "oneway" to get it to work right, otherwise the quit
message could be lost when the sending application exited too
fast.
Fix bug 5675 (Nitpicks in new "could not be moved to new special
location" dialog):
* libnautilus-extensions/nautilus-file-operations.c:
(handle_transfer_overwrite): Updated message wording as Eli (and
Vera) suggest.
Other changes:
* libnautilus-extensions/nautilus-view-identifier.c:
(get_lang_list): Fix comment and a small storage leak in the case
where lang_with_locale is non-NULL but empty.
* po/POTFILES.ignore: Obsolete file, no longer used.
* src/file-manager/fm-desktop-icon-view.c:
(update_home_link_and_delete_copies): Update comment to help
translators understand better.
* libnautilus-extensions/nautilus-directory-async.c:
(directory_load_callback): Added a new assertion that could help
in future gnome-vfs debugging.
* libnautilus/nautilus-view-component.idl: Removed long-ago-fixed
FIXME comment.
* src/nautilus-window-manage-views.c: Tweak spacing.
2001-01-18 John Sullivan <sullivan@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>
......@@ -585,7 +702,6 @@
(nautilus_list_get_drop_action):
Tiny tweak.
>>>>>>> 1.3384
2001-01-16 Michael Engber <engber@eazel.com>
* libnautilus-extensions/nautilus-directory-background.c:
......
......@@ -1414,6 +1414,7 @@ directory_load_callback (GnomeVFSAsyncHandle *handle,
directory = NAUTILUS_DIRECTORY (callback_data);
g_assert (directory->details->directory_load_in_progress != NULL);
g_assert (directory->details->directory_load_in_progress == handle);
/* Move items from the list onto our pending queue.
......
......@@ -1000,22 +1000,22 @@ handle_transfer_overwrite (const GnomeVFSXferProgressInfo *progress_info,
/* Handle special case files such as Trash, mount links and home directory */
if (is_special_link (progress_info->target_name)) {
formatted_name = extract_and_ellipsize_file_name_for_dialog (progress_info->target_name);
formatted_name = extract_and_ellipsize_file_name_for_dialog
(progress_info->target_name);
if (transfer_info->kind == TRANSFER_MOVE) {
text = g_strdup_printf (_("\"%s\" could not be moved to the new location, "
"because the name is already used for a special item that "
"cannot be removed or replaced. "
"because its name is already used for a special item that "
"cannot be removed or replaced.\n\n"
"If you still want to move \"%s\", rename it and try again."),
formatted_name, formatted_name);
} else {
text = g_strdup_printf (_("\"%s\" could not be copied to the new location, "
"because the name is already used for a special item that "
"cannot be removed or replaced. "
"because its name is already used for a special item that "
"cannot be removed or replaced.\n\n"
"If you still want to copy \"%s\", rename it and try again."),
formatted_name, formatted_name);
};
}
nautilus_simple_dialog (parent_for_error_dialog (transfer_info), TRUE, text,
_("Unable to replace file."), _("OK"), NULL, NULL);
......
......@@ -99,36 +99,41 @@ struct NautilusFileDetails
nautilus_boolean_bit activation_uri_is_up_to_date : 1;
};
NautilusFile *nautilus_file_new_from_info (NautilusDirectory *directory,
GnomeVFSFileInfo *info);
NautilusFile *nautilus_file_get_existing (const char *uri);
void nautilus_file_emit_changed (NautilusFile *file);
void nautilus_file_mark_gone (NautilusFile *file);
char * nautilus_extract_top_left_text (const char *text,
int length);
gboolean nautilus_file_contains_text (NautilusFile *file);
void nautilus_file_set_directory (NautilusFile *file,
NautilusDirectory *directory);
NautilusFile *nautilus_file_new_from_info (NautilusDirectory *directory,
GnomeVFSFileInfo *info);
NautilusFile *nautilus_file_get_existing (const char *uri);
void nautilus_file_emit_changed (NautilusFile *file);
void nautilus_file_mark_gone (NautilusFile *file);
gboolean nautilus_file_info_missing (NautilusFile *file,
GnomeVFSFileInfoFields needed_mask);
char * nautilus_extract_top_left_text (const char *text,
int length);
gboolean nautilus_file_contains_text (NautilusFile *file);
void nautilus_file_set_directory (NautilusFile *file,
NautilusDirectory *directory);
gboolean nautilus_file_get_date (NautilusFile *file,
NautilusDateType date_type,
time_t *date);
/* Compare file's state with a fresh file info struct, return FALSE if
* no change, update file and return TRUE if the file info contains
* new state. */
gboolean nautilus_file_update_info (NautilusFile *file,
GnomeVFSFileInfo *info);
gboolean nautilus_file_update_name (NautilusFile *file,
const char *name);
gboolean nautilus_file_update_info (NautilusFile *file,
GnomeVFSFileInfo *info);
gboolean nautilus_file_update_name (NautilusFile *file,
const char *name);
/* Return true if the top lefts of files in this directory should be
* fetched, according to the preference settings.
*/
gboolean nautilus_file_should_get_top_left_text (NautilusFile *file);
gboolean nautilus_file_should_get_top_left_text (NautilusFile *file);
/* Mark specified attributes for this file out of date without canceling current
* I/O or kicking off new I/O.
*/
void nautilus_file_invalidate_attributes_internal (NautilusFile *file,
GList *file_attributes);
void nautilus_file_invalidate_attributes_internal (NautilusFile *file,
GList *file_attributes);
/* Recognizing special file names. */
gboolean nautilus_file_name_matches_hidden_pattern (const char *name_or_relative_uri);
gboolean nautilus_file_name_matches_backup_pattern (const char *name_or_relative_uri);
gboolean nautilus_file_name_matches_hidden_pattern (const char *name_or_relative_uri);
gboolean nautilus_file_name_matches_backup_pattern (const char *name_or_relative_uri);
......@@ -37,6 +37,7 @@
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-link.h"
#include "nautilus-string.h"
#include "nautilus-trash-directory.h"
#include "nautilus-trash-file.h"
#include "nautilus-vfs-file.h"
#include <ctype.h>
......@@ -69,13 +70,6 @@ extern void eazel_dump_stack_trace (const char *print_prefix,
/* Name to use to tag metadata for the directory itself. */
#define FILE_NAME_FOR_DIRECTORY_METADATA "."
typedef enum {
NAUTILUS_DATE_TYPE_MODIFIED,
NAUTILUS_DATE_TYPE_CHANGED,
NAUTILUS_DATE_TYPE_ACCESSED,
NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED
} NautilusDateType;
typedef struct {
NautilusFile *file;
GnomeVFSAsyncHandle *handle;
......@@ -133,7 +127,8 @@ nautilus_file_initialize (NautilusFile *file)
static NautilusFile *
nautilus_file_new_from_relative_uri (NautilusDirectory *directory,
const char *relative_uri)
const char *relative_uri,
gboolean self_owned)
{
NautilusFile *file;
......@@ -141,7 +136,11 @@ nautilus_file_new_from_relative_uri (NautilusDirectory *directory,
g_return_val_if_fail (relative_uri != NULL, NULL);
g_return_val_if_fail (relative_uri[0] != '\0', NULL);
file = NAUTILUS_FILE (gtk_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
if (self_owned && NAUTILUS_IS_TRASH_DIRECTORY (directory)) {
file = NAUTILUS_FILE (gtk_object_new (NAUTILUS_TYPE_TRASH_FILE, NULL));
} else {
file = NAUTILUS_FILE (gtk_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
}
gtk_object_ref (GTK_OBJECT (file));
gtk_object_sink (GTK_OBJECT (file));
......@@ -158,8 +157,8 @@ nautilus_file_new_from_relative_uri (NautilusDirectory *directory,
return file;
}
static gboolean
info_missing (NautilusFile *file, GnomeVFSFileInfoFields needed_mask)
gboolean
nautilus_file_info_missing (NautilusFile *file, GnomeVFSFileInfoFields needed_mask)
{
GnomeVFSFileInfo *info;
......@@ -185,7 +184,7 @@ modify_link_hash_table (NautilusFile *file,
GList *list;
/* Check if there is a symlink name. If none, we are OK. */
if (info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME)) {
if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME)) {
return;
}
symlink_name = file->details->info->symlink_name;
......@@ -356,7 +355,7 @@ nautilus_file_get_internal (const char *uri, gboolean create)
if (file != NULL) {
nautilus_file_ref (file);
} else if (create) {
file = nautilus_file_new_from_relative_uri (directory, relative_uri);
file = nautilus_file_new_from_relative_uri (directory, relative_uri, self_owned);
if (self_owned) {
g_assert (directory->details->as_file == NULL);
directory->details->as_file = file;
......@@ -1077,7 +1076,7 @@ update_link (NautilusFile *link_file, NautilusFile *target_file)
{
g_assert (NAUTILUS_IS_FILE (link_file));
g_assert (NAUTILUS_IS_FILE (target_file));
g_assert (!info_missing (link_file, GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME));
g_assert (!nautilus_file_info_missing (link_file, GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME));
/* FIXME bugzilla.eazel.com 2044: If we don't put any code
* here then the hash table is a waste of time.
......@@ -2159,7 +2158,29 @@ nautilus_file_get_uri_scheme (NautilusFile *file)
colon - file->details->directory->details->uri);
}
gboolean
nautilus_file_get_date (NautilusFile *file,
NautilusDateType date_type,
time_t *date)
{
if (date != NULL) {
*date = 0;
}
g_return_val_if_fail (date_type == NAUTILUS_DATE_TYPE_CHANGED
|| date_type == NAUTILUS_DATE_TYPE_ACCESSED
|| date_type == NAUTILUS_DATE_TYPE_MODIFIED
|| date_type == NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED, FALSE);
if (file == NULL) {
return FALSE;
}
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
return NAUTILUS_CALL_VIRTUAL (NAUTILUS_FILE_CLASS, file,
get_date, (file, date_type, date));
}
/**
* nautilus_file_get_date_as_string:
......@@ -2173,61 +2194,19 @@ nautilus_file_get_uri_scheme (NautilusFile *file)
**/
static char *
nautilus_file_get_date_as_string (NautilusFile *file, NautilusDateType date_type)
{
struct tm *file_time = NULL;
{
time_t file_time_raw;
struct tm *file_time;
const char *format;
GDate *today;
GDate *file_date;
guint32 file_date_age;
g_return_val_if_fail (date_type == NAUTILUS_DATE_TYPE_CHANGED
|| date_type == NAUTILUS_DATE_TYPE_ACCESSED
|| date_type == NAUTILUS_DATE_TYPE_MODIFIED
|| date_type == NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED, NULL);
switch (date_type) {
case NAUTILUS_DATE_TYPE_CHANGED:
/* Before we have info on a file, the date is unknown. */
if (info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_CTIME)) {
return NULL;
}
file_time = localtime (&file->details->info->ctime);
break;
case NAUTILUS_DATE_TYPE_ACCESSED:
/* Before we have info on a file, the date is unknown. */
if (info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_ATIME)) {
return NULL;
}
file_time = localtime (&file->details->info->atime);
break;
case NAUTILUS_DATE_TYPE_MODIFIED:
/* Before we have info on a file, the date is unknown. */
if (info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_MTIME)) {
return NULL;
}
file_time = localtime (&file->details->info->mtime);
break;
case NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED:
/* Before we have info on a file, the date is unknown. */
if (info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_MTIME) ||
info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_CTIME)) {
return NULL;
}
/* mtime is when the contents changed; ctime is when the
* contents or the permissions (inc. owner/group) changed.
* So we can only know when the permissions changed if mtime
* and ctime are different.
*/
if (file->details->info->mtime == file->details->info->ctime) {
return NULL;
}
file_time = localtime (&file->details->info->ctime);
break;
default:
g_assert_not_reached ();
if (!nautilus_file_get_date (file, date_type, &file_time_raw)) {
return NULL;
}
file_time = localtime (&file_time_raw);
file_date = nautilus_g_date_new_tm (file_time);
today = g_date_new ();
......@@ -2298,13 +2277,12 @@ nautilus_file_get_directory_item_count (NautilusFile *file,
guint *count,
gboolean *count_unreadable)
{
if (count != NULL) {
*count = 0;
}
if (count_unreadable != NULL) {
*count_unreadable = 0;
*count_unreadable = FALSE;
}
g_return_val_if_fail (count != NULL, FALSE);
*count = 0;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
......@@ -2414,7 +2392,7 @@ GnomeVFSFileSize
nautilus_file_get_size (NautilusFile *file)
{
/* Before we have info on the file, we don't know the size. */
return info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SIZE)
return nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SIZE)
? 0 : file->details->info->size;
}
......@@ -2431,7 +2409,7 @@ nautilus_file_get_size (NautilusFile *file)
gboolean
nautilus_file_can_get_permissions (NautilusFile *file)
{
return !info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS);
return !nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS);
}
/**
......@@ -2720,7 +2698,7 @@ nautilus_file_can_get_owner (NautilusFile *file)
* Can we trust the uid in the file info? Might
* there be garbage there? What will it do for non-local files?
*/
return !info_missing (file, 0 /* FIXME bugzilla.eazel.com 644: GNOME_VFS_FILE_INFO_FIELDS_UID */);
return !nautilus_file_info_missing (file, 0 /* FIXME bugzilla.eazel.com 644: GNOME_VFS_FILE_INFO_FIELDS_UID */);
}
/**
......@@ -2935,7 +2913,7 @@ nautilus_file_can_get_group (NautilusFile *file)
* Can we trust the gid in the file info? Might
* there be garbage there? What will it do for non-local files?
*/
return !info_missing (file, 0 /* FIXME bugzilla.eazel.com 644: GNOME_VFS_FILE_INFO_FIELDS_GID */);
return !nautilus_file_info_missing (file, 0 /* FIXME bugzilla.eazel.com 644: GNOME_VFS_FILE_INFO_FIELDS_GID */);
}
/**
......@@ -2955,7 +2933,7 @@ nautilus_file_get_group_name (NautilusFile *file)
struct group *group_info;
/* Before we have info on a file, the owner is unknown. */
if (info_missing (file, 0 /* FIXME bugzilla.eazel.com 644: GNOME_VFS_FILE_INFO_FIELDS_GID */)) {
if (nautilus_file_info_missing (file, 0 /* FIXME bugzilla.eazel.com 644: GNOME_VFS_FILE_INFO_FIELDS_GID */)) {
return NULL;
}
......@@ -3284,7 +3262,7 @@ nautilus_file_get_owner_as_string (NautilusFile *file, gboolean include_real_nam
* Can we trust the uid in the file info? Might
* there be garbage there? What will it do for non-local files?
*/
if (info_missing (file, 0 /* FIXME bugzilla.eazel.com 644: GNOME_VFS_FILE_INFO_FIELDS_UID */)) {
if (nautilus_file_info_missing (file, 0 /* FIXME bugzilla.eazel.com 644: GNOME_VFS_FILE_INFO_FIELDS_UID */)) {
return NULL;
}
......@@ -3357,7 +3335,7 @@ nautilus_file_get_size_as_string (NautilusFile *file)
return format_item_count_for_display (item_count, TRUE, TRUE);
}
if (info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SIZE)) {
if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SIZE)) {
return NULL;
}
return gnome_vfs_format_file_size_for_display (file->details->info->size);
......@@ -3750,8 +3728,10 @@ nautilus_file_get_type_as_string (NautilusFile *file)
GnomeVFSFileType
nautilus_file_get_file_type (NautilusFile *file)
{
return info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_TYPE)
? GNOME_VFS_FILE_TYPE_UNKNOWN : file->details->info->type;
if (file == NULL) {
return GNOME_VFS_FILE_TYPE_UNKNOWN;
}
return NAUTILUS_CALL_VIRTUAL (NAUTILUS_FILE_CLASS, file, get_file_type, (file));
}
/**
......@@ -3908,7 +3888,7 @@ nautilus_file_set_keywords (NautilusFile *file, GList *keywords)
gboolean
nautilus_file_is_symbolic_link (NautilusFile *file)
{
return info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_FLAGS)
return nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_FLAGS)
? FALSE : (file->details->info->flags & GNOME_VFS_FILE_FLAGS_SYMLINK);
}
......@@ -3948,7 +3928,7 @@ nautilus_file_get_symbolic_link_target_path (NautilusFile *file)
{
g_return_val_if_fail (nautilus_file_is_symbolic_link (file), NULL);
return info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME)
return nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME)
? NULL
: g_strdup (file->details->info->symlink_name);
}
......@@ -3980,12 +3960,6 @@ nautilus_file_is_nautilus_link (NautilusFile *file)
gboolean
nautilus_file_is_directory (NautilusFile *file)
{
if (file == NULL) {
return FALSE;
}
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
return nautilus_file_get_file_type (file) == GNOME_VFS_FILE_TYPE_DIRECTORY;
}
......
......@@ -288,6 +288,16 @@ struct NautilusFile {
NautilusFileDetails *details;
};
/* This is actually a "protected" type, but it must be here so we can
* compile the get_date function pointer declaration below.
*/
typedef enum {
NAUTILUS_DATE_TYPE_MODIFIED,
NAUTILUS_DATE_TYPE_CHANGED,
NAUTILUS_DATE_TYPE_ACCESSED,
NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED
} NautilusDateType;
typedef struct {
GtkObjectClass parent_slot;
......@@ -309,6 +319,7 @@ typedef struct {
gpointer callback_data);
gboolean (* check_if_ready) (NautilusFile *file,
GList *attributes);
GnomeVFSFileType (* get_file_type) (NautilusFile *file);
gboolean (* get_item_count) (NautilusFile *file,
guint *count,
gboolean *count_unreadable);
......@@ -317,6 +328,9 @@ typedef struct {
guint *file_count,
guint *unreadable_directory_count,
GnomeVFSFileSize *total_size);
gboolean (* get_date) (NautilusFile *file,
NautilusDateType type,
time_t *date);
} NautilusFileClass;
#endif /* NAUTILUS_FILE_H */
......@@ -766,9 +766,6 @@ nautilus_icon_factory_get_icon_name_for_regular_file (NautilusFile *file)
icon_name = ICON_NAME_WEB;
} else if (nautilus_istr_has_prefix (uri, "eazel-install:")) {
icon_name = ICON_NAME_INSTALL;
} else if (strcmp (uri, NAUTILUS_TRASH_URI) == 0) {
icon_name = nautilus_trash_monitor_is_empty ()
? ICON_NAME_TRASH_EMPTY : ICON_NAME_TRASH_NOT_EMPTY;
} else {
if (nautilus_file_is_executable (file)
&& nautilus_strcasecmp (mime_type, "text/plain") != 0) {
......@@ -798,7 +795,7 @@ nautilus_icon_factory_get_icon_name_for_directory (NautilusFile *file)
} else {
icon_name = ICON_NAME_DIRECTORY;
}
g_free (mime_type);
return icon_name;
......@@ -809,6 +806,16 @@ nautilus_icon_factory_get_icon_name_for_directory (NautilusFile *file)
static const char *
nautilus_icon_factory_get_icon_name_for_file (NautilusFile *file)
{
char *uri;
uri = nautilus_file_get_uri (file);
if (strcmp (uri, NAUTILUS_TRASH_URI) == 0) {
g_free (uri);
return nautilus_trash_monitor_is_empty ()
? ICON_NAME_TRASH_EMPTY : ICON_NAME_TRASH_NOT_EMPTY;
}
g_free (uri);
/* Get an icon name based on the file's type. */
switch (nautilus_file_get_file_type (file)) {
case GNOME_VFS_FILE_TYPE_DIRECTORY:
......
......@@ -139,24 +139,6 @@ merged_callback_equal (gconstpointer merged_callback_as_pointer,
&& merged_callback->callback_data == merged_callback_2->callback_data;
}
/* Return true if any directory in the list does. */
static gboolean
merged_contains_file (NautilusDirectory *directory,
NautilusFile *file)
{
NautilusMergedDirectory *merged;
GList *p;
merged = NAUTILUS_MERGED_DIRECTORY (directory);
for (p = merged->details->directories; p != NULL; p = p->next) {
if (nautilus_directory_contains_file (p->data, file)) {
return TRUE;
}
}
return FALSE;
}
static void
merged_callback_destroy (MergedCallback *merged_callback)
{
......@@ -196,8 +178,6 @@ merged_callback_remove_directory (MergedCallback *merged_callback,
merged_callback->non_ready_directories = g_list_remove
(merged_callback->non_ready_directories,
directory);
/* Check if we are ready. */
merged_callback_check_done (merged_callback);
}
......@@ -220,18 +200,7 @@ directory_ready_callback (NautilusDirectory *directory,
nautilus_file_list_copy (files));
/* Check if we are ready. */
merged_callback_remove_directory (merged_callback,
directory);
}
static void
merged_callback_connect_directory (MergedCallback *merged_callback,
NautilusDirectory *real_merged)
{
nautilus_directory_call_when_ready
(real_merged,
merged_callback->wait_for_attributes,
directory_ready_callback, merged_callback);
merged_callback_remove_directory (merged_callback, directory);
}
static void
......@@ -242,7 +211,7 @@ merged_call_when_ready (NautilusDirectory *directory,
{
NautilusMergedDirectory *merged;
MergedCallback search_key, *merged_callback;
GList *p;
GList *node;
merged = NAUTILUS_MERGED_DIRECTORY (directory);
......@@ -260,9 +229,9 @@ merged_call_when_ready (NautilusDirectory *directory,
merged_callback->callback = callback;
merged_callback->callback_data = callback_data;
merged_callback->wait_for_attributes = nautilus_g_str_list_copy (file_attributes);
for (p = merged->details->directories; p != NULL; p = p->next) {
for (node = merged->details->directories; node != NULL; node = node->next) {
merged_callback->non_ready_directories = g_list_prepend
(merged_callback->non_ready_directories, p->data);
(merged_callback->non_ready_directories, node->data);
}
/* Put it in the hash table. */
......@@ -275,8 +244,11 @@ merged_call_when_ready (NautilusDirectory *directory,
}
/* Now tell all the directories about it. */
for (p = merged->details->directories; p != NULL; p = p->next) {
merged_callback_connect_directory (merged_callback, p->data);
for (node = merged->details->directories; node != NULL; node = node->next) {
nautilus_directory_call_when_ready
(node->data,
merged_callback->wait_for_attributes,
directory_ready_callback, merged_callback);
}
}
......@@ -287,7 +259,7 @@ merged_cancel_callback (NautilusDirectory *directory,
{
NautilusMergedDirectory *merged;
MergedCallback search_key, *merged_callback;
GList *p;
GList *node;
merged = NAUTILUS_MERGED_DIRECTORY (directory);
......@@ -303,9 +275,9 @@ merged_cancel_callback (NautilusDirectory *directory,
g_hash_table_remove (merged_callback->merged->details->callbacks, merged_callback);
/* Tell all the directories to cancel the call. */
for (p = merged_callback->non_ready_directories; p != NULL; p = p->next) {
for (node = merged_callback->non_ready_directories; node != NULL; node = node->next) {
nautilus_directory_cancel_callback
(p->data,
(node->data,
directory_ready_callback, merged_callback);
}
merged_callback_destroy (merged_callback);
......@@ -322,7 +294,7 @@ merged_file_monitor_add (NautilusDirectory *directory,
{
NautilusMergedDirectory *merged;
MergedMonitor *monitor;
GList *p;
GList *node;
merged = NAUTILUS_MERGED_DIRECTORY (directory);
......@@ -345,9 +317,9 @@ merged_file_monitor_add (NautilusDirectory *directory,
monitor->force_reload = force_reload;
/* Call through to the real directory add calls. */