Commit 682bcce2 authored by Darin Adler's avatar Darin Adler

Finished task 226 (Read metadata asynchronously instead of

	synchronously).

	Requires new GNOME VFS.

	* libnautilus/nautilus-directory-private.h:
	* libnautilus/nautilus-directory.c:
	* libnautilus/nautilus-directory.h:
	Changed code to read and write metafiles async. Too many functions
	modified for me to list here.

	* libnautilus/nautilus-file-private.h:
	* libnautilus/nautilus-file.c:
	* libnautilus/nautilus-file.h:
	(nautilus_file_changed), (nautilus_file_emit_changed),
	(nautilus_file_get_metadata), (nautilus_file_set_metadata),
	(nautilus_file_call_when_ready), (nautilus_file_cancel_callback):
	Changes to NautilusFile so it can participate in the new.

	* components/notes/ntl-notes.c (notes_load_metainfo):
	Fixed a bug in my recent changes where it would use a bad file
	object when getting metadata.

	* src/file-manager/fm-directory-view.c (notes_load_metainfo):
	Renamed "tags" to "keys".
parent 2ac3c5da
2000-04-11 Darin Adler <darin@eazel.com>
Finished task 226 (Read metadata asynchronously instead of
synchronously).
Requires new GNOME VFS.
* libnautilus/nautilus-directory-private.h:
* libnautilus/nautilus-directory.c:
* libnautilus/nautilus-directory.h:
Changed code to read and write metafiles async. Too many functions
modified for me to list here.
* libnautilus/nautilus-file-private.h:
* libnautilus/nautilus-file.c:
* libnautilus/nautilus-file.h:
(nautilus_file_changed), (nautilus_file_emit_changed),
(nautilus_file_get_metadata), (nautilus_file_set_metadata),
(nautilus_file_call_when_ready), (nautilus_file_cancel_callback):
Changes to NautilusFile so it can participate in the new.
* components/notes/ntl-notes.c (notes_load_metainfo):
Fixed a bug in my recent changes where it would use a bad file
object when getting metadata.
* src/file-manager/fm-directory-view.c (notes_load_metainfo):
Renamed "tags" to "keys".
2000-04-11 Andy Hertzfeld <andy@eazel.com>
* components/rpmview/nautilus-rpmview.c:
......
......@@ -81,19 +81,18 @@ done_with_file (Notes *notes)
static void
notes_load_metainfo (Notes *notes)
{
NautilusFile *file;
GList *keys;
gtk_editable_delete_text (GTK_EDITABLE (notes->note_text_field), 0, -1);
done_with_file (notes);
notes->file = nautilus_file_get (notes->uri);
if (file == NULL) {
if (notes->file == NULL) {
return;
}
keys = g_list_prepend (NULL, NAUTILUS_METADATA_KEY_ANNOTATION);
nautilus_file_call_when_ready (file, keys, finish_loading_note, notes);
nautilus_file_call_when_ready (notes->file, keys, finish_loading_note, notes);
g_list_free (keys);
}
......
......@@ -81,19 +81,18 @@ done_with_file (Notes *notes)
static void
notes_load_metainfo (Notes *notes)
{
NautilusFile *file;
GList *keys;
gtk_editable_delete_text (GTK_EDITABLE (notes->note_text_field), 0, -1);
done_with_file (notes);
notes->file = nautilus_file_get (notes->uri);
if (file == NULL) {
if (notes->file == NULL) {
return;
}
keys = g_list_prepend (NULL, NAUTILUS_METADATA_KEY_ANNOTATION);
nautilus_file_call_when_ready (file, keys, finish_loading_note, notes);
nautilus_file_call_when_ready (notes->file, keys, finish_loading_note, notes);
g_list_free (keys);
}
......
......@@ -32,7 +32,10 @@
#include "nautilus-file.h"
#define METADATA_NODE_NAME_FOR_FILE_NAME "NAME"
#define METADATA_NODE_NAME_FOR_FILE_NAME "NAME"
typedef struct MetafileReadState MetafileReadState;
typedef struct MetafileWriteState MetafileWriteState;
struct NautilusDirectoryDetails
{
......@@ -44,36 +47,59 @@ struct NautilusDirectoryDetails
guint monitor_files_ref_count;
GList *files;
xmlDoc *metafile;
gboolean metafile_read;
gboolean use_alternate_metafile;
MetafileReadState *read_state;
guint write_metafile_idle_id;
MetafileWriteState *write_state;
/* This list is going to be pretty short.
* If we thought it was going to get big, we could
* use a hash table instead.
*/
GList *metafile_callbacks;
gboolean directory_loaded;
GnomeVFSAsyncHandle *directory_load_in_progress;
GnomeVFSDirectoryListPosition directory_load_list_last_handled;
GList *pending_file_info;
guint dequeue_pending_idle_id;
gboolean metafile_read;
gboolean use_alternate_metafile;
guint write_metafile_idle_id;
};
NautilusFile *nautilus_directory_find_file (NautilusDirectory *directory,
const char *file_name);
char * nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
const char *default_metadata);
gboolean nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
const char *default_metadata,
const char *metadata);
xmlNode * nautilus_directory_get_file_metadata_node (NautilusDirectory *directory,
const char *file_name,
gboolean create);
void nautilus_directory_files_changed (NautilusDirectory *directory,
GList *changed_files);
void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
typedef struct {
NautilusFile *file;
union {
NautilusDirectoryCallback directory;
NautilusFileCallback file;
} callback;
gpointer callback_data;
} QueuedCallback;
NautilusFile *nautilus_directory_find_file (NautilusDirectory *directory,
const char *file_name);
char * nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *key,
const char *default_metadata);
gboolean nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *key,
const char *default_metadata,
const char *metadata);
xmlNode * nautilus_directory_get_file_metadata_node (NautilusDirectory *directory,
const char *file_name,
gboolean create);
void nautilus_directory_files_changed (NautilusDirectory *directory,
GList *changed_files);
void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
void nautilus_directory_cancel_callback_internal (NautilusDirectory *directory,
const QueuedCallback *callback);
void nautilus_directory_call_when_ready_internal (NautilusDirectory *directory,
const QueuedCallback *callback);
/* debugging functions */
int nautilus_directory_number_outstanding (void);
This diff is collapsed.
......@@ -84,8 +84,8 @@ char * nautilus_directory_get_uri (NautilusDirectory
* to other attributes as well.
*/
void nautilus_directory_call_when_ready (NautilusDirectory *directory,
GList *directory_metadata_tags,
GList *file_metadata_tags,
GList *directory_metadata_keys,
GList *file_metadata_keys,
NautilusDirectoryCallback callback,
gpointer callback_data);
void nautilus_directory_cancel_callback (NautilusDirectory *directory,
......@@ -93,26 +93,26 @@ void nautilus_directory_cancel_callback (NautilusDirectory
gpointer callback_data);
/* Getting and setting metadata. */
char * nautilus_directory_get_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
const char *default_metadata);
void nautilus_directory_set_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
const char *default_metadata,
const char *metadata);
/* Covers for common data types. */
gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
gboolean default_metadata);
void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
gboolean default_metadata,
gboolean metadata);
int nautilus_directory_get_integer_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
int default_metadata);
void nautilus_directory_set_integer_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
int default_metadata,
int metadata);
......
......@@ -32,5 +32,6 @@ struct NautilusFileDetails
gboolean is_gone;
};
NautilusFile *nautilus_file_new (NautilusDirectory *directory,
GnomeVFSFileInfo *info);
NautilusFile *nautilus_file_new (NautilusDirectory *directory,
GnomeVFSFileInfo *info);
void nautilus_file_emit_changed (NautilusFile *file);
......@@ -671,20 +671,20 @@ nautilus_file_compare_for_sort_reversed (NautilusFile *file_1,
char *
nautilus_file_get_metadata (NautilusFile *file,
const char *tag,
const char *key,
const char *default_metadata)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
return nautilus_directory_get_file_metadata (file->details->directory,
file->details->info->name,
tag,
key,
default_metadata);
}
void
nautilus_file_set_metadata (NautilusFile *file,
const char *tag,
const char *key,
const char *default_metadata,
const char *metadata)
{
......@@ -692,7 +692,7 @@ nautilus_file_set_metadata (NautilusFile *file,
nautilus_directory_set_file_metadata (file->details->directory,
file->details->info->name,
tag,
key,
default_metadata,
metadata);
nautilus_file_changed (file);
......@@ -1410,13 +1410,29 @@ nautilus_file_changed (NautilusFile *file)
g_return_if_fail (NAUTILUS_IS_FILE (file));
changed_files = g_list_prepend (NULL, file);
nautilus_directory_files_changed (file->details->directory, changed_files);
g_list_free (changed_files);
}
/**
* nautilus_file_emit_changed
*
* Emit a file changed signal.
* This can only be called by the directory, since the directory
* also has to emit a files_changed signal.
*
* @file: NautilusFile representing the file in question.
**/
void
nautilus_file_emit_changed (NautilusFile *file)
{
g_assert (NAUTILUS_IS_FILE (file));
/* Send out a signal. */
gtk_signal_emit (GTK_OBJECT (file),
signals[CHANGED],
file);
changed_files = g_list_prepend (NULL, file);
nautilus_directory_files_changed (file->details->directory, changed_files);
g_list_free (changed_files);
}
/**
......@@ -1437,12 +1453,22 @@ nautilus_file_is_gone (NautilusFile *file)
void
nautilus_file_call_when_ready (NautilusFile *file,
GList *file_metadata_tags,
GList *file_metadata_keys,
NautilusFileCallback callback,
gpointer callback_data)
{
/* For now, it's synchronous for testing. */
(* callback) (file, callback_data);
QueuedCallback new_callback;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (file_metadata_keys != NULL);
g_return_if_fail (callback != NULL);
new_callback.file = file;
new_callback.callback.file = callback;
new_callback.callback_data = callback_data;
nautilus_directory_call_when_ready_internal (file->details->directory,
&new_callback);
}
void
......@@ -1450,6 +1476,22 @@ nautilus_file_cancel_callback (NautilusFile *file,
NautilusFileCallback callback,
gpointer callback_data)
{
QueuedCallback old_callback;
g_return_if_fail (callback != NULL);
if (file == NULL) {
return;
}
g_return_if_fail (NAUTILUS_IS_FILE (file));
old_callback.file = file;
old_callback.callback.file = callback;
old_callback.callback_data = callback_data;
nautilus_directory_cancel_callback_internal (file->details->directory,
&old_callback);
}
/**
......
......@@ -75,7 +75,7 @@ void nautilus_file_delete (NautilusFile *
* to other attributes as well.
*/
void nautilus_file_call_when_ready (NautilusFile *file,
GList *metadata_tags,
GList *metadata_keys,
NautilusFileCallback callback,
gpointer callback_data);
void nautilus_file_cancel_callback (NautilusFile *file,
......@@ -111,10 +111,10 @@ gboolean nautilus_file_is_gone (NautilusFile *
/* Simple getting and setting top-level metadata. */
char * nautilus_file_get_metadata (NautilusFile *file,
const char *tag,
const char *key,
const char *default_metadata);
void nautilus_file_set_metadata (NautilusFile *file,
const char *tag,
const char *key,
const char *default_metadata,
const char *metadata);
......
......@@ -32,7 +32,10 @@
#include "nautilus-file.h"
#define METADATA_NODE_NAME_FOR_FILE_NAME "NAME"
#define METADATA_NODE_NAME_FOR_FILE_NAME "NAME"
typedef struct MetafileReadState MetafileReadState;
typedef struct MetafileWriteState MetafileWriteState;
struct NautilusDirectoryDetails
{
......@@ -44,36 +47,59 @@ struct NautilusDirectoryDetails
guint monitor_files_ref_count;
GList *files;
xmlDoc *metafile;
gboolean metafile_read;
gboolean use_alternate_metafile;
MetafileReadState *read_state;
guint write_metafile_idle_id;
MetafileWriteState *write_state;
/* This list is going to be pretty short.
* If we thought it was going to get big, we could
* use a hash table instead.
*/
GList *metafile_callbacks;
gboolean directory_loaded;
GnomeVFSAsyncHandle *directory_load_in_progress;
GnomeVFSDirectoryListPosition directory_load_list_last_handled;
GList *pending_file_info;
guint dequeue_pending_idle_id;
gboolean metafile_read;
gboolean use_alternate_metafile;
guint write_metafile_idle_id;
};
NautilusFile *nautilus_directory_find_file (NautilusDirectory *directory,
const char *file_name);
char * nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
const char *default_metadata);
gboolean nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
const char *default_metadata,
const char *metadata);
xmlNode * nautilus_directory_get_file_metadata_node (NautilusDirectory *directory,
const char *file_name,
gboolean create);
void nautilus_directory_files_changed (NautilusDirectory *directory,
GList *changed_files);
void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
typedef struct {
NautilusFile *file;
union {
NautilusDirectoryCallback directory;
NautilusFileCallback file;
} callback;
gpointer callback_data;
} QueuedCallback;
NautilusFile *nautilus_directory_find_file (NautilusDirectory *directory,
const char *file_name);
char * nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *key,
const char *default_metadata);
gboolean nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *key,
const char *default_metadata,
const char *metadata);
xmlNode * nautilus_directory_get_file_metadata_node (NautilusDirectory *directory,
const char *file_name,
gboolean create);
void nautilus_directory_files_changed (NautilusDirectory *directory,
GList *changed_files);
void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
void nautilus_directory_cancel_callback_internal (NautilusDirectory *directory,
const QueuedCallback *callback);
void nautilus_directory_call_when_ready_internal (NautilusDirectory *directory,
const QueuedCallback *callback);
/* debugging functions */
int nautilus_directory_number_outstanding (void);
This diff is collapsed.
......@@ -84,8 +84,8 @@ char * nautilus_directory_get_uri (NautilusDirectory
* to other attributes as well.
*/
void nautilus_directory_call_when_ready (NautilusDirectory *directory,
GList *directory_metadata_tags,
GList *file_metadata_tags,
GList *directory_metadata_keys,
GList *file_metadata_keys,
NautilusDirectoryCallback callback,
gpointer callback_data);
void nautilus_directory_cancel_callback (NautilusDirectory *directory,
......@@ -93,26 +93,26 @@ void nautilus_directory_cancel_callback (NautilusDirectory
gpointer callback_data);
/* Getting and setting metadata. */
char * nautilus_directory_get_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
const char *default_metadata);
void nautilus_directory_set_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
const char *default_metadata,
const char *metadata);
/* Covers for common data types. */
gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
gboolean default_metadata);
void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
gboolean default_metadata,
gboolean metadata);
int nautilus_directory_get_integer_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
int default_metadata);
void nautilus_directory_set_integer_metadata (NautilusDirectory *directory,
const char *tag,
const char *key,
int default_metadata,
int metadata);
......
......@@ -32,5 +32,6 @@ struct NautilusFileDetails
gboolean is_gone;
};
NautilusFile *nautilus_file_new (NautilusDirectory *directory,
GnomeVFSFileInfo *info);
NautilusFile *nautilus_file_new (NautilusDirectory *directory,
GnomeVFSFileInfo *info);
void nautilus_file_emit_changed (NautilusFile *file);
......@@ -671,20 +671,20 @@ nautilus_file_compare_for_sort_reversed (NautilusFile *file_1,
char *
nautilus_file_get_metadata (NautilusFile *file,
const char *tag,
const char *key,
const char *default_metadata)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
return nautilus_directory_get_file_metadata (file->details->directory,
file->details->info->name,
tag,
key,
default_metadata);
}
void
nautilus_file_set_metadata (NautilusFile *file,
const char *tag,
const char *key,
const char *default_metadata,
const char *metadata)
{
......@@ -692,7 +692,7 @@ nautilus_file_set_metadata (NautilusFile *file,
nautilus_directory_set_file_metadata (file->details->directory,
file->details->info->name,
tag,
key,
default_metadata,
metadata);
nautilus_file_changed (file);
......@@ -1410,13 +1410,29 @@ nautilus_file_changed (NautilusFile *file)
g_return_if_fail (NAUTILUS_IS_FILE (file));
changed_files = g_list_prepend (NULL, file);
nautilus_directory_files_changed (file->details->directory, changed_files);
g_list_free (changed_files);
}
/**
* nautilus_file_emit_changed
*
* Emit a file changed signal.
* This can only be called by the directory, since the directory
* also has to emit a files_changed signal.
*
* @file: NautilusFile representing the file in question.
**/
void
nautilus_file_emit_changed (NautilusFile *file)
{
g_assert (NAUTILUS_IS_FILE (file));
/* Send out a signal. */
gtk_signal_emit (GTK_OBJECT (file),
signals[CHANGED],
file);
changed_files = g_list_prepend (NULL, file);
nautilus_directory_files_changed (file->details->directory, changed_files);
g_list_free (changed_files);
}
/**
......@@ -1437,12 +1453,22 @@ nautilus_file_is_gone (NautilusFile *file)
void
nautilus_file_call_when_ready (NautilusFile *file,
GList *file_metadata_tags,
GList *file_metadata_keys,
NautilusFileCallback callback,
gpointer callback_data)
{
/* For now, it's synchronous for testing. */
(* callback) (file, callback_data);
QueuedCallback new_callback;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (file_metadata_keys != NULL);
g_return_if_fail (callback != NULL);
new_callback.file = file;
new_callback.callback.file = callback;
new_callback.callback_data = callback_data;
nautilus_directory_call_when_ready_internal (file->details->directory,
&new_callback);
}
void
......@@ -1450,6 +1476,22 @@ nautilus_file_cancel_callback (NautilusFile *file,
NautilusFileCallback callback,
gpointer callback_data)
{
QueuedCallback old_callback;
g_return_if_fail (callback != NULL);
if (file == NULL) {
return;
}
g_return_if_fail (NAUTILUS_IS_FILE (file));
old_callback.file = file;
old_callback.callback.file = callback;
old_callback.callback_data = callback_data;
nautilus_directory_cancel_callback_internal (file->details->directory,
&old_callback);
}
/**
......
......@@ -75,7 +75,7 @@ void nautilus_file_delete (NautilusFile *
* to other attributes as well.
*/
void nautilus_file_call_when_ready (NautilusFile *file,
GList *metadata_tags,
GList *metadata_keys,
NautilusFileCallback callback,
gpointer callback_data);
void nautilus_file_cancel_callback (NautilusFile *file,
......@@ -111,10 +111,10 @@ gboolean nautilus_file_is_gone (NautilusFile *
/* Simple getting and setting top-level metadata. */
char * nautilus_file_get_metadata (NautilusFile *file,
const char *tag,
const char *key,
const char *default_metadata);
void nautilus_file_set_metadata (NautilusFile *file,
const char *tag,
const char *key,
const char *default_metadata,
const char *metadata);
......
......@@ -32,7 +32,10 @@
#include "nautilus-file.h"
#define METADATA_NODE_NAME_FOR_FILE_NAME "NAME"
#define METADATA_NODE_NAME_FOR_FILE_NAME "NAME"
typedef struct MetafileReadState MetafileReadState;
typedef struct MetafileWriteState MetafileWriteState;
struct NautilusDirectoryDetails
{
......@@ -44,36 +47,59 @@ struct NautilusDirectoryDetails
guint monitor_files_ref_count;
GList *files;
xmlDoc *metafile;
gboolean metafile_read;
gboolean use_alternate_metafile;
MetafileReadState *read_state;
guint write_metafile_idle_id;
MetafileWriteState *write_state;
/* This list is going to be pretty short.
* If we thought it was going to get big, we could
* use a hash table instead.
*/
GList *metafile_callbacks;
gboolean directory_loaded;
GnomeVFSAsyncHandle *directory_load_in_progress;
GnomeVFSDirectoryListPosition directory_load_list_last_handled;
GList *pending_file_info;
guint dequeue_pending_idle_id;
gboolean metafile_read;
gboolean use_alternate_metafile;
guint write_metafile_idle_id;
};
NautilusFile *nautilus_directory_find_file (NautilusDirectory *directory,
const char *file_name);
char * nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
const char *default_metadata);
gboolean nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *tag,
const char *default_metadata,
const char *metadata);
xmlNode * nautilus_directory_get_file_metadata_node (NautilusDirectory *directory,
const char *file_name,
gboolean create);
void nautilus_directory_files_changed (NautilusDirectory *directory,
GList *changed_files);
void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
typedef struct {
NautilusFile *file;
union {
NautilusDirectoryCallback directory;
NautilusFileCallback file;
} callback;
gpointer callback_data;
} QueuedCallback;
NautilusFile *nautilus_directory_find_file (NautilusDirectory *directory,
const char *file_name);
char * nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *key,
const char *default_metadata);
gboolean nautilus_directory_set_file_metadata (NautilusDirectory *