Commit 1ae3a242 authored by Darin Adler's avatar Darin Adler
Browse files

Added the hooks needed to make metafile reading asynchronous.

	Next I'll change the actual metafile access to work that way.

	* libnautilus/nautilus-directory.h:
	* libnautilus/nautilus-directory.c:
	(nautilus_directory_metadata_call_when_ready): Added function
	that requests a read of some metadata and calls back when the
	data is ready.

	* src/ntl-app.c: (nautilus_app_startup): Got rid of call to
	nautilus_navinfo_init.

	* src/ntl-types.h: Moved the NautilusNavigationInfo struct
	and related defines to ntl-uri-map.h.

	* src/ntl-uri-map.h:
	* src/ntl-uri-map.c:
	Reformatted and changed the names of many functions.
	Added code to use the new metadata callback.

	* src/ntl-index-panel.c:
	* src/ntl-main.c:
	* src/ntl-view.h:
	* src/ntl-window-msgs.c:
	* src/ntl-window.c:
	* src/ntl-window.h:
	Had to change includes a bit because of my changes to what
	header files are including.

	* src/ntl-window-msgs.c: (nautilus_window_update_state):
	* src/ntl-window.h:
	Use the new nautilus_navigation_info_cancel call instead of
	reaching right in to cancel the underlying call.

	* src/ntl-view-private.h:
	Reformatting.
parent 50206e4a
2000-04-06 Darin Adler <darin@eazel.com>
Added the hooks needed to make metafile reading asynchronous.
Next I'll change the actual metafile access to work that way.
* libnautilus/nautilus-directory.h:
* libnautilus/nautilus-directory.c:
(nautilus_directory_metadata_call_when_ready): Added function
that requests a read of some metadata and calls back when the
data is ready.
* src/ntl-app.c: (nautilus_app_startup): Got rid of call to
nautilus_navinfo_init.
* src/ntl-types.h: Moved the NautilusNavigationInfo struct
and related defines to ntl-uri-map.h.
* src/ntl-uri-map.h:
* src/ntl-uri-map.c:
Reformatted and changed the names of many functions.
Added code to use the new metadata callback.
* src/ntl-index-panel.c:
* src/ntl-main.c:
* src/ntl-view.h:
* src/ntl-window-msgs.c:
* src/ntl-window.c:
* src/ntl-window.h:
Had to change includes a bit because of my changes to what
header files are including.
* src/ntl-window-msgs.c: (nautilus_window_update_state):
* src/ntl-window.h:
Use the new nautilus_navigation_info_cancel call instead of
reaching right in to cancel the underlying call.
* src/ntl-view-private.h:
Reformatting.
2000-04-06 Darin Adler <darin@eazel.com>
* libnautilus/nautilus-directory-background.c:
......
......@@ -1082,6 +1082,23 @@ nautilus_directory_get_file_metadata_node (NautilusDirectory *directory,
return NULL;
}
void
nautilus_directory_metadata_call_when_ready (NautilusDirectory *directory,
GList *tags,
NautilusMetadataCallback callback,
gpointer callback_data)
{
/* For now, it's synchronous for testing. */
(* callback) (directory, callback_data);
}
void
nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory,
NautilusMetadataCallback callback,
gpointer callback_data)
{
}
char *
nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
......
......@@ -56,66 +56,77 @@ typedef struct NautilusDirectoryClass NautilusDirectoryClass;
#define NAUTILUS_IS_DIRECTORY_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DIRECTORY))
typedef void (*NautilusMetadataCallback) (NautilusDirectory *directory,
gpointer callback_data);
typedef void (*NautilusFileListCallback) (NautilusDirectory *directory,
GList *files,
gpointer callback_data);
/* Basic GtkObject requirements. */
GtkType nautilus_directory_get_type (void);
GtkType nautilus_directory_get_type (void);
/* Get a directory given a uri.
* Creates the appropriate subclass given the uri mappings.
* Returns a referenced object, not a floating one. Unref when finished.
* If two windows are viewing the same uri, the directory object is shared.
*/
NautilusDirectory *nautilus_directory_get (const char *uri);
NautilusDirectory *nautilus_directory_get (const char *uri);
/* Convenience functions, since we do a lot of ref'ing and unref'ing. */
void nautilus_directory_ref (NautilusDirectory *directory);
void nautilus_directory_unref (NautilusDirectory *directory);
void nautilus_directory_ref (NautilusDirectory *directory);
void nautilus_directory_unref (NautilusDirectory *directory);
/* Access to a 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);
void nautilus_directory_set_metadata (NautilusDirectory *directory,
const char *tag,
const char *default_metadata,
const char *metadata);
gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata);
void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata,
gboolean metadata);
int nautilus_directory_get_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata);
void nautilus_directory_set_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata,
int metadata);
char * nautilus_directory_get_uri (NautilusDirectory *directory);
/* Getting and setting metadata. */
char * nautilus_directory_get_metadata (NautilusDirectory *directory,
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_metadata_call_when_ready (NautilusDirectory *directory,
GList *tags,
NautilusMetadataCallback callback,
gpointer callback_data);
void nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory,
NautilusMetadataCallback callback,
gpointer callback_data);
/* Covers for common data types. */
gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata);
void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata,
gboolean metadata);
int nautilus_directory_get_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata);
void nautilus_directory_set_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata,
int metadata);
/* Monitor the files in a directory. */
void nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
NautilusFileListCallback initial_files_callback,
gpointer callback_data);
void nautilus_directory_monitor_files_unref (NautilusDirectory *directory);
void nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
NautilusFileListCallback initial_files_callback,
gpointer callback_data);
void nautilus_directory_monitor_files_unref (NautilusDirectory *directory);
/* Return true if the directory has information about all the files.
* This will be false until the directory has been read at least once.
*/
gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory);
gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory);
/* Return true if the directory metadata has been loaded.
* Until this is true, get_metadata calls will return defaults.
* (We could have another way to indicate "don't know".)
*/
gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory);
gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory);
typedef struct NautilusDirectoryDetails NautilusDirectoryDetails;
......
......@@ -1082,6 +1082,23 @@ nautilus_directory_get_file_metadata_node (NautilusDirectory *directory,
return NULL;
}
void
nautilus_directory_metadata_call_when_ready (NautilusDirectory *directory,
GList *tags,
NautilusMetadataCallback callback,
gpointer callback_data)
{
/* For now, it's synchronous for testing. */
(* callback) (directory, callback_data);
}
void
nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory,
NautilusMetadataCallback callback,
gpointer callback_data)
{
}
char *
nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
......
......@@ -56,66 +56,77 @@ typedef struct NautilusDirectoryClass NautilusDirectoryClass;
#define NAUTILUS_IS_DIRECTORY_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DIRECTORY))
typedef void (*NautilusMetadataCallback) (NautilusDirectory *directory,
gpointer callback_data);
typedef void (*NautilusFileListCallback) (NautilusDirectory *directory,
GList *files,
gpointer callback_data);
/* Basic GtkObject requirements. */
GtkType nautilus_directory_get_type (void);
GtkType nautilus_directory_get_type (void);
/* Get a directory given a uri.
* Creates the appropriate subclass given the uri mappings.
* Returns a referenced object, not a floating one. Unref when finished.
* If two windows are viewing the same uri, the directory object is shared.
*/
NautilusDirectory *nautilus_directory_get (const char *uri);
NautilusDirectory *nautilus_directory_get (const char *uri);
/* Convenience functions, since we do a lot of ref'ing and unref'ing. */
void nautilus_directory_ref (NautilusDirectory *directory);
void nautilus_directory_unref (NautilusDirectory *directory);
void nautilus_directory_ref (NautilusDirectory *directory);
void nautilus_directory_unref (NautilusDirectory *directory);
/* Access to a 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);
void nautilus_directory_set_metadata (NautilusDirectory *directory,
const char *tag,
const char *default_metadata,
const char *metadata);
gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata);
void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata,
gboolean metadata);
int nautilus_directory_get_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata);
void nautilus_directory_set_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata,
int metadata);
char * nautilus_directory_get_uri (NautilusDirectory *directory);
/* Getting and setting metadata. */
char * nautilus_directory_get_metadata (NautilusDirectory *directory,
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_metadata_call_when_ready (NautilusDirectory *directory,
GList *tags,
NautilusMetadataCallback callback,
gpointer callback_data);
void nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory,
NautilusMetadataCallback callback,
gpointer callback_data);
/* Covers for common data types. */
gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata);
void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata,
gboolean metadata);
int nautilus_directory_get_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata);
void nautilus_directory_set_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata,
int metadata);
/* Monitor the files in a directory. */
void nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
NautilusFileListCallback initial_files_callback,
gpointer callback_data);
void nautilus_directory_monitor_files_unref (NautilusDirectory *directory);
void nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
NautilusFileListCallback initial_files_callback,
gpointer callback_data);
void nautilus_directory_monitor_files_unref (NautilusDirectory *directory);
/* Return true if the directory has information about all the files.
* This will be false until the directory has been read at least once.
*/
gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory);
gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory);
/* Return true if the directory metadata has been loaded.
* Until this is true, get_metadata calls will return defaults.
* (We could have another way to indicate "don't know".)
*/
gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory);
gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory);
typedef struct NautilusDirectoryDetails NautilusDirectoryDetails;
......
......@@ -1082,6 +1082,23 @@ nautilus_directory_get_file_metadata_node (NautilusDirectory *directory,
return NULL;
}
void
nautilus_directory_metadata_call_when_ready (NautilusDirectory *directory,
GList *tags,
NautilusMetadataCallback callback,
gpointer callback_data)
{
/* For now, it's synchronous for testing. */
(* callback) (directory, callback_data);
}
void
nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory,
NautilusMetadataCallback callback,
gpointer callback_data)
{
}
char *
nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
......
......@@ -56,66 +56,77 @@ typedef struct NautilusDirectoryClass NautilusDirectoryClass;
#define NAUTILUS_IS_DIRECTORY_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DIRECTORY))
typedef void (*NautilusMetadataCallback) (NautilusDirectory *directory,
gpointer callback_data);
typedef void (*NautilusFileListCallback) (NautilusDirectory *directory,
GList *files,
gpointer callback_data);
/* Basic GtkObject requirements. */
GtkType nautilus_directory_get_type (void);
GtkType nautilus_directory_get_type (void);
/* Get a directory given a uri.
* Creates the appropriate subclass given the uri mappings.
* Returns a referenced object, not a floating one. Unref when finished.
* If two windows are viewing the same uri, the directory object is shared.
*/
NautilusDirectory *nautilus_directory_get (const char *uri);
NautilusDirectory *nautilus_directory_get (const char *uri);
/* Convenience functions, since we do a lot of ref'ing and unref'ing. */
void nautilus_directory_ref (NautilusDirectory *directory);
void nautilus_directory_unref (NautilusDirectory *directory);
void nautilus_directory_ref (NautilusDirectory *directory);
void nautilus_directory_unref (NautilusDirectory *directory);
/* Access to a 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);
void nautilus_directory_set_metadata (NautilusDirectory *directory,
const char *tag,
const char *default_metadata,
const char *metadata);
gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata);
void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata,
gboolean metadata);
int nautilus_directory_get_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata);
void nautilus_directory_set_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata,
int metadata);
char * nautilus_directory_get_uri (NautilusDirectory *directory);
/* Getting and setting metadata. */
char * nautilus_directory_get_metadata (NautilusDirectory *directory,
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_metadata_call_when_ready (NautilusDirectory *directory,
GList *tags,
NautilusMetadataCallback callback,
gpointer callback_data);
void nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory,
NautilusMetadataCallback callback,
gpointer callback_data);
/* Covers for common data types. */
gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata);
void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory,
const char *tag,
gboolean default_metadata,
gboolean metadata);
int nautilus_directory_get_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata);
void nautilus_directory_set_integer_metadata (NautilusDirectory *directory,
const char *tag,
int default_metadata,
int metadata);
/* Monitor the files in a directory. */
void nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
NautilusFileListCallback initial_files_callback,
gpointer callback_data);
void nautilus_directory_monitor_files_unref (NautilusDirectory *directory);
void nautilus_directory_monitor_files_ref (NautilusDirectory *directory,
NautilusFileListCallback initial_files_callback,
gpointer callback_data);
void nautilus_directory_monitor_files_unref (NautilusDirectory *directory);
/* Return true if the directory has information about all the files.
* This will be false until the directory has been read at least once.
*/
gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory);
gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory);
/* Return true if the directory metadata has been loaded.
* Until this is true, get_metadata calls will return defaults.
* (We could have another way to indicate "don't know".)
*/
gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory);
gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory);
typedef struct NautilusDirectoryDetails NautilusDirectoryDetails;
......
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* Nautilus
......@@ -22,20 +22,59 @@
* Author: Elliot Lee <sopwith@redhat.com>
*
*/
/* ntl-uri-map.h: Interface for mapping a location change request to a set of views and actual URL to be loaded. */
#ifndef NAUTILUS_URI_MAP_H
#define NAUTILUS_URI_MAP_H 1
#include "ntl-types.h"
#include "ntl-view.h"
void nautilus_navinfo_init(void);
gpointer nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
Nautilus_NavigationInfo *old_navinfo,
NautilusNavigationInfoFunc notify_when_ready,
gpointer notify_data,
const char *referring_iid);
void nautilus_navinfo_free(NautilusNavigationInfo *navinfo);
#define NAUTILUS_URI_MAP_H
#include <glib.h>
#include <libgnomevfs/gnome-vfs-types.h>
#include <libnautilus/nautilus.h>
#include <libnautilus/nautilus-directory.h>
typedef struct NautilusNavigationInfo NautilusNavigationInfo;
/* These are the different ways that Nautilus can fail to
* display the contents of a given uri. NAUTILUS_NAVIGATION_RESULT_OK
* means the uri was displayed successfully. These are similar to
* GnomeVFSResults but there are nautilus-specific codes and many of
* the GnomeVFSResults are treated the same here.
*/
typedef enum {
NAUTILUS_NAVIGATION_RESULT_OK,
NAUTILUS_NAVIGATION_RESULT_UNSPECIFIC_ERROR,
NAUTILUS_NAVIGATION_RESULT_NO_HANDLER_FOR_TYPE,
NAUTILUS_NAVIGATION_RESULT_NOT_FOUND,
NAUTILUS_NAVIGATION_RESULT_UNSUPPORTED_SCHEME,
NAUTILUS_NAVIGATION_RESULT_INVALID_URI
} NautilusNavigationResult;
typedef void (*NautilusNavigationCallback) (NautilusNavigationResult result,
NautilusNavigationInfo *info,
gpointer callback_data);
struct NautilusNavigationInfo {
Nautilus_NavigationInfo navinfo;
char *referring_iid; /* iid of content view that we're coming from */
char *initial_content_iid; /* iid to use for content view that we're going to display */
GSList *content_identifiers; /* list of NautilusViewIdentifiers */
GSList *meta_iids; /* list of iid strings */
/* internal usage */
NautilusNavigationCallback callback;
gpointer callback_data;
GnomeVFSAsyncHandle *ah;
NautilusDirectory *directory;
};
NautilusNavigationInfo *nautilus_navigation_info_new (Nautilus_NavigationRequestInfo *request,
Nautilus_NavigationInfo *previous_location,
NautilusNavigationCallback ready_callback,
gpointer callback_data,
const char *referring_iid);
void nautilus_navigation_info_cancel (NautilusNavigationInfo *info);
void nautilus_navigation_info_free (NautilusNavigationInfo *info);
#endif
......@@ -254,8 +254,6 @@ nautilus_app_startup(NautilusApp *app, const char *initial_url)
{
NautilusWindow *mainwin;
nautilus_navinfo_init();
/* Set default configuration */
mainwin = nautilus_app_create_window(app);
bonobo_activate();
......
......@@ -28,6 +28,7 @@
#include "ntl-index-panel.h"
#include <math.h>
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libnautilus/nautilus-background.h>
......
......@@ -34,6 +34,7 @@
#include <libnautilus/nautilus-debug.h>
#include <libnautilus/nautilus-lib-self-check-functions.h>
#include <libnautilus/nautilus-self-checks.h>
#include <libgnomevfs/gnome-vfs-init.h>
int
main(int argc, char *argv[])
......
......@@ -43,6 +43,7 @@
#include <libnautilus/nautilus-string.h>
#include "nautilus-zoom-control.h"
#include <ctype.h>
#include <libgnomevfs/gnome-vfs-uri.h>
enum
{
......
......@@ -30,7 +30,7 @@
#include <libgnomeui/gnome-app.h>
#include <libnautilus/nautilus-bookmark.h>
#include "ntl-types.h"
#include "ntl-uri-map.h"
#include "ntl-view.h"
#include "ntl-index-panel.h"
......@@ -106,7 +106,7 @@ struct _NautilusWindow {
enum { NW_LOADING_INFO, NW_LOADING_VIEWS, NW_IDLE } state;
gpointer cancel_tag;
NautilusNavigationInfo *cancel_tag;
guint action_tag;
guint16 made_changes, making_changes;
......
......@@ -43,6 +43,7 @@
#include <libnautilus/nautilus-string.h>
#include "nautilus-zoom-control.h"
#include <ctype.h>
#include <libgnomevfs/gnome-vfs-uri.h>
enum