Commit 6018bcea authored by Elliot Lee's avatar Elliot Lee
Browse files

Add support for the location change state machine and related



* src/ntl-types.h, src/ntl-uri-map.[ch], src/ntl-window-msgs.c, src/ntl-window.[ch]:
  Add support for the location change state machine and related notifications,
  to allow much better error handling.

* src/ntl-view.[ch]: Catch client failures, also allow for active sensing of client death.
* src/file-manager/fm-directory-view.c: Send progress notifications.
* components/html/ntl-web-browser.c: Send progress
  notifications. Try to fix crashes caused by ending an error stream
  twice.
parent cdf570ee
2000-01-05 Elliot Lee <sopwith@redhat.com>
* src/ntl-types.h, src/ntl-uri-map.[ch], src/ntl-window-msgs.c, src/ntl-window.[ch]:
Add support for the location change state machine and related notifications,
to allow much better error handling.
* src/ntl-view.[ch]: Catch client failures, also allow for active sensing of client death.
* src/file-manager/fm-directory-view.c: Send progress notifications.
* components/html/ntl-web-browser.c: Send progress
notifications. Try to fix crashes caused by ending an error stream
twice.
2000-01-05 John Sullivan <sullivan@eazel.com>
* src/nautilus-bookmarks-window.c: (create_bookmarks_window):
......
......@@ -13,3 +13,7 @@ Components
. Help index, contents, search
. Bookmarks
. Web search
Misc
----
Search for "XXX" or "TODO" in the source.
......@@ -152,13 +152,15 @@ canonicalize_url (const char *in_url, const char *base_url)
static void
browser_url_load_done(GtkWidget *htmlw, BrowserInfo *bi)
{
Nautilus_StatusRequestInfo sri;
Nautilus_ProgressRequestInfo pri;
gtk_html_calc_scrollbars(GTK_HTML(bi->htmlw));
memset(&sri, 0, sizeof(sri));
sri.status_string = _("Load done.");
nautilus_view_client_request_status_change(bi->vc, &sri);
memset(&pri, 0, sizeof(pri));
pri.type = Nautilus_PROGRESS_DONE_OK;
pri.amount = 100.0;
nautilus_view_client_request_progress_change(bi->vc, &pri);
}
struct _HTStream {
......@@ -307,7 +309,8 @@ browser_url_requested(GtkWidget *htmlw, const char *url, GtkHTMLStreamHandle han
if(HTLoad(request, NO) == NO)
{
HTRequest_delete(request);
gtk_html_end(GTK_HTML(bi->htmlw), handle, GTK_HTML_STREAM_ERROR);
/* I think deleting the request will end the stream, too */
/* gtk_html_end(GTK_HTML(bi->htmlw), handle, GTK_HTML_STREAM_ERROR); */
}
g_free(real_url);
......@@ -332,6 +335,11 @@ browser_set_base_target(GtkWidget *htmlw, const char *base_target_url, BrowserIn
static void
browser_goto_url_real(GtkWidget *htmlw, const char *url, BrowserInfo *bi)
{
Nautilus_ProgressRequestInfo pri;
pri.type = Nautilus_PROGRESS_UNDERWAY;
pri.amount = 0.0;
HTNet_killAll();
g_free(bi->base_url);
g_free(bi->base_target_url);
......@@ -349,6 +357,7 @@ browser_goto_url_real(GtkWidget *htmlw, const char *url, BrowserInfo *bi)
gtk_html_begin(GTK_HTML(bi->htmlw), url);
gtk_html_parse(GTK_HTML(bi->htmlw));
nautilus_view_client_request_progress_change(bi->vc, &pri);
}
static void
......
......@@ -620,6 +620,7 @@ stop_load (FMDirectoryView *view, gboolean error)
view->entries_to_display = 0;
view->directory_list = NULL;
memset(&pri, 0, sizeof(pri));
pri.amount = 100.0;
pri.type = error ? Nautilus_PROGRESS_DONE_ERROR : Nautilus_PROGRESS_DONE_OK;
......@@ -903,6 +904,7 @@ fm_directory_view_load_uri (FMDirectoryView *view,
GNOME_VFS_DIRECTORY_SORT_NONE
}; /* FIXME */
GnomeVFSResult result;
Nautilus_ProgressRequestInfo pri;
g_return_if_fail (view != NULL);
g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
......@@ -919,6 +921,11 @@ fm_directory_view_load_uri (FMDirectoryView *view,
gnome_vfs_uri_unref (view->uri);
view->uri = gnome_vfs_uri_new (uri);
memset(&pri, 0, sizeof(pri));
pri.type = Nautilus_PROGRESS_UNDERWAY;
pri.amount = 0;
nautilus_view_client_request_progress_change(NAUTILUS_VIEW_CLIENT(view), &pri);
result = gnome_vfs_async_load_directory_uri
(&view->vfs_async_handle, /* handle */
view->uri, /* uri */
......@@ -937,11 +944,6 @@ fm_directory_view_load_uri (FMDirectoryView *view,
view); /* callback_data */
g_return_if_fail(result == GNOME_VFS_OK);
/*
if (result != GNOME_VFS_OK)
gtk_signal_emit (GTK_OBJECT (view), signals[OPEN_FAILED],
result);
*/
}
void
......
......@@ -192,15 +192,20 @@ nautilus_navinfo_map(NautilusNavigationInfo *navinfo)
navinfo->navinfo.actual_uri = g_strdup(navinfo->navinfo.requested_uri);
}
NautilusNavigationInfo *
nautilus_navinfo_new(NautilusNavigationInfo *navinfo,
Nautilus_NavigationRequestInfo *nri,
guint
nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
Nautilus_NavigationInfo *old_navinfo,
NautilusView *requesting_view)
NautilusView *requesting_view,
NautilusNavigationInfoFunc notify_when_ready,
gpointer notify_data)
{
const char *meta_keys[] = {"icon-filename", NULL};
NautilusNavigationInfo *navinfo;
navinfo = g_new0(NautilusNavigationInfo, 1);
memset(navinfo, 0, sizeof(*navinfo));
navinfo->notify_ready = notify_when_ready;
navinfo->data = notify_data;
if(old_navinfo)
{
......@@ -229,8 +234,8 @@ nautilus_navinfo_new(NautilusNavigationInfo *navinfo,
if(res != GNOME_VFS_OK)
{
gnome_vfs_file_info_destroy(vfs_fileinfo);
nautilus_navinfo_free(navinfo);
return NULL;
nautilus_navinfo_free(navinfo); navinfo = NULL;
goto out;
}
navinfo->navinfo.content_type = g_strdup(gnome_vfs_file_info_get_mime_type(vfs_fileinfo));
......@@ -278,22 +283,35 @@ nautilus_navinfo_new(NautilusNavigationInfo *navinfo,
}
else
{
g_warning("Unhandled content type %s", navinfo->navinfo.content_type);
/* Error - couldn't handle */
nautilus_navinfo_free(navinfo); navinfo = NULL;
goto out;
}
}
navinfo->meta_iids = g_slist_append(navinfo->meta_iids, g_strdup("ntl_history_view"));
navinfo->meta_iids = g_slist_append(navinfo->meta_iids, g_strdup("ntl_websearch_view"));
return navinfo;
out:
if(notify_when_ready)
{
navinfo->notify_tag = 0;
notify_when_ready(navinfo, notify_data);
}
return 0;
}
void
nautilus_navinfo_free(NautilusNavigationInfo *navinfo)
{
if(navinfo->notify_tag)
/* XXX remove_notification */ ;
g_slist_foreach(navinfo->meta_iids, (GFunc)g_free, NULL);
g_slist_free(navinfo->meta_iids);
g_free(navinfo->navinfo.requested_uri);
g_free(navinfo->navinfo.actual_uri);
g_free(navinfo->navinfo.content_type);
g_free(navinfo);
}
......@@ -31,10 +31,11 @@
#include "ntl-view.h"
void nautilus_navinfo_init(void);
NautilusNavigationInfo *nautilus_navinfo_new(NautilusNavigationInfo *navinfo,
Nautilus_NavigationRequestInfo *nri,
Nautilus_NavigationInfo *old_navinfo,
NautilusView *requesting_view);
guint nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
Nautilus_NavigationInfo *old_navinfo,
NautilusView *requesting_view,
NautilusNavigationInfoFunc notify_when_ready,
gpointer notify_data);
void nautilus_navinfo_free(NautilusNavigationInfo *navinfo);
#endif
......@@ -121,15 +121,6 @@ static void nautilus_window_goto_uri_cb (GtkWidget *widget,
GtkWidget *window);
static void nautilus_window_about_cb (GtkWidget *widget,
NautilusWindow *window);
static void nautilus_window_connect_view (NautilusWindow *window,
NautilusView *view);
static void nautilus_window_disconnect_view (NautilusWindow *window,
NautilusView *view);
static void nautilus_window_disconnect_view_exchanged (NautilusView *view,
NautilusWindow *window);
#undef CONTENTS_AS_HBOX
......@@ -574,15 +565,11 @@ nautilus_window_set_arg (GtkObject *object,
#endif
}
nautilus_window_disconnect_view(window, window->content_view);
gtk_widget_unref(GTK_WIDGET(window->content_view));
}
if (new_cv)
{
nautilus_window_connect_view(window, NAUTILUS_VIEW(new_cv));
#ifdef CONTENTS_AS_HBOX
gtk_box_pack_end(GTK_BOX(window->content_hbox), new_cv, TRUE, TRUE, GNOME_PAD);
#else
......@@ -617,12 +604,6 @@ static void nautilus_window_destroy (NautilusWindow *window)
{
NautilusWindowClass *klass = NAUTILUS_WINDOW_CLASS(GTK_OBJECT(window)->klass);
if (window->content_view != NULL) {
nautilus_window_disconnect_view(window, window->content_view);
}
g_slist_foreach(window->meta_views, (GFunc)nautilus_window_disconnect_view_exchanged, window);
g_slist_free(window->meta_views);
CORBA_free(window->ni);
CORBA_free(window->si);
......@@ -774,8 +755,6 @@ nautilus_window_add_meta_view(NautilusWindow *window, NautilusView *meta_view)
g_return_if_fail(!g_slist_find(window->meta_views, meta_view));
g_return_if_fail(NAUTILUS_IS_META_VIEW(meta_view));
nautilus_window_connect_view(window, meta_view);
desc = nautilus_meta_view_get_label(NAUTILUS_META_VIEW(meta_view));
if(!desc)
{
......@@ -793,21 +772,25 @@ nautilus_window_add_meta_view(NautilusWindow *window, NautilusView *meta_view)
}
void
nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view)
nautilus_window_remove_meta_view_real(NautilusWindow *window, NautilusView *meta_view)
{
gint pagenum;
g_return_if_fail(g_slist_find(window->meta_views, meta_view));
window->meta_views = g_slist_remove(window->meta_views, meta_view);
pagenum = gtk_notebook_page_num(GTK_NOTEBOOK(window->meta_notebook), GTK_WIDGET(meta_view));
g_return_if_fail(pagenum >= 0);
gtk_notebook_remove_page(GTK_NOTEBOOK(window->meta_notebook), pagenum);
}
void
nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view)
{
g_return_if_fail(g_slist_find(window->meta_views, meta_view));
window->meta_views = g_slist_remove(window->meta_views, meta_view);
nautilus_window_disconnect_view(window, meta_view);
nautilus_window_remove_meta_view_real(window, meta_view);
}
/* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */
......@@ -883,21 +866,10 @@ nautilus_window_home (GtkWidget *btn, NautilusWindow *window)
nautilus_window_set_initial_state(window, NULL);
}
static void
nv_stop_location_change_adapter(NautilusView *view, gpointer dummy)
{
nautilus_view_stop_location_change (view);
}
static void
nautilus_window_stop (GtkWidget *btn, NautilusWindow *window)
{
if (window->content_view != NULL) {
nautilus_view_stop_location_change (window->content_view);
}
g_slist_foreach(window->meta_views, (GFunc) nv_stop_location_change_adapter, NULL);
nautilus_window_end_location_change(window);
}
static void
......@@ -987,52 +959,43 @@ nautilus_window_request_progress_change_cb (NautilusView *view,
nautilus_window_request_progress_change(window, info, view);
}
static void
void
nautilus_window_connect_view(NautilusWindow *window, NautilusView *view)
{
gtk_signal_connect(GTK_OBJECT(view),
GtkObject *viewo;
viewo = GTK_OBJECT(view);
gtk_signal_connect(viewo,
"request_location_change",
nautilus_window_request_location_change_cb,
window);
gtk_signal_connect(GTK_OBJECT(view),
gtk_signal_connect(viewo,
"request_selection_change",
nautilus_window_request_selection_change_cb,
window);
gtk_signal_connect(GTK_OBJECT(view),
gtk_signal_connect(viewo,
"request_status_change",
nautilus_window_request_status_change_cb,
window);
gtk_signal_connect(GTK_OBJECT(view),
gtk_signal_connect(viewo,
"request_progress_change",
nautilus_window_request_progress_change_cb,
window);
gtk_signal_connect(viewo,
"destroy",
nautilus_window_view_destroyed,
window);
}
static void
nautilus_window_disconnect_view(NautilusWindow *window, NautilusView *view)
void
nautilus_window_display_error(NautilusWindow *window, const char *error_msg)
{
gtk_signal_disconnect_by_func(GTK_OBJECT(view),
nautilus_window_request_location_change_cb,
window);
gtk_signal_disconnect_by_func(GTK_OBJECT(view),
nautilus_window_request_selection_change_cb,
window);
gtk_signal_disconnect_by_func(GTK_OBJECT(view),
nautilus_window_request_status_change_cb,
window);
gtk_signal_disconnect_by_func(GTK_OBJECT(view),
nautilus_window_request_progress_change_cb,
window);
}
GtkWidget *dialog;
static void
nautilus_window_disconnect_view_exchanged(NautilusView *view, NautilusWindow *window)
{
nautilus_window_disconnect_view(window, view);
}
dialog = gnome_message_box_new(error_msg, GNOME_MESSAGE_BOX_ERROR, _("Close"), NULL);
gnome_dialog_set_close(GNOME_DIALOG(dialog), TRUE);
gnome_dialog_set_default(GNOME_DIALOG(dialog), 0);
gtk_widget_show(dialog);
}
......@@ -47,6 +47,8 @@ typedef struct {
guint window_signals[0];
} NautilusWindowClass;
typedef struct _NautilusWindowLoadInfo NautilusWindowLoadInfo;
struct _NautilusWindow {
GnomeApp parent_object;
......@@ -70,6 +72,8 @@ struct _NautilusWindow {
/* Information about current location/selection */
Nautilus_NavigationInfo *ni;
Nautilus_SelectionInfo *si;
NautilusWindowLoadInfo *load_info;
};
GtkType nautilus_window_get_type(void);
......@@ -78,6 +82,8 @@ void nautilus_window_set_content_view(NautilusWindow *window, NautilusView *cont
void nautilus_window_add_meta_view(NautilusWindow *window, NautilusView *meta_view);
void nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view);
void nautilus_window_goto_uri(NautilusWindow *window, const char *uri);
void nautilus_window_display_error(NautilusWindow *window, const char *error_msg);
const char *nautilus_window_get_requested_uri(NautilusWindow *window);
GnomeUIHandler *nautilus_window_get_uih(NautilusWindow *window);
......
......@@ -121,15 +121,6 @@ static void nautilus_window_goto_uri_cb (GtkWidget *widget,
GtkWidget *window);
static void nautilus_window_about_cb (GtkWidget *widget,
NautilusWindow *window);
static void nautilus_window_connect_view (NautilusWindow *window,
NautilusView *view);
static void nautilus_window_disconnect_view (NautilusWindow *window,
NautilusView *view);
static void nautilus_window_disconnect_view_exchanged (NautilusView *view,
NautilusWindow *window);
#undef CONTENTS_AS_HBOX
......@@ -574,15 +565,11 @@ nautilus_window_set_arg (GtkObject *object,
#endif
}
nautilus_window_disconnect_view(window, window->content_view);
gtk_widget_unref(GTK_WIDGET(window->content_view));
}
if (new_cv)
{
nautilus_window_connect_view(window, NAUTILUS_VIEW(new_cv));
#ifdef CONTENTS_AS_HBOX
gtk_box_pack_end(GTK_BOX(window->content_hbox), new_cv, TRUE, TRUE, GNOME_PAD);
#else
......@@ -617,12 +604,6 @@ static void nautilus_window_destroy (NautilusWindow *window)
{
NautilusWindowClass *klass = NAUTILUS_WINDOW_CLASS(GTK_OBJECT(window)->klass);
if (window->content_view != NULL) {
nautilus_window_disconnect_view(window, window->content_view);
}
g_slist_foreach(window->meta_views, (GFunc)nautilus_window_disconnect_view_exchanged, window);
g_slist_free(window->meta_views);
CORBA_free(window->ni);
CORBA_free(window->si);
......@@ -774,8 +755,6 @@ nautilus_window_add_meta_view(NautilusWindow *window, NautilusView *meta_view)
g_return_if_fail(!g_slist_find(window->meta_views, meta_view));
g_return_if_fail(NAUTILUS_IS_META_VIEW(meta_view));
nautilus_window_connect_view(window, meta_view);
desc = nautilus_meta_view_get_label(NAUTILUS_META_VIEW(meta_view));
if(!desc)
{
......@@ -793,21 +772,25 @@ nautilus_window_add_meta_view(NautilusWindow *window, NautilusView *meta_view)
}
void
nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view)
nautilus_window_remove_meta_view_real(NautilusWindow *window, NautilusView *meta_view)
{
gint pagenum;
g_return_if_fail(g_slist_find(window->meta_views, meta_view));
window->meta_views = g_slist_remove(window->meta_views, meta_view);
pagenum = gtk_notebook_page_num(GTK_NOTEBOOK(window->meta_notebook), GTK_WIDGET(meta_view));
g_return_if_fail(pagenum >= 0);
gtk_notebook_remove_page(GTK_NOTEBOOK(window->meta_notebook), pagenum);
}
void
nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view)
{
g_return_if_fail(g_slist_find(window->meta_views, meta_view));
window->meta_views = g_slist_remove(window->meta_views, meta_view);
nautilus_window_disconnect_view(window, meta_view);
nautilus_window_remove_meta_view_real(window, meta_view);
}
/* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */
......@@ -883,21 +866,10 @@ nautilus_window_home (GtkWidget *btn, NautilusWindow *window)
nautilus_window_set_initial_state(window, NULL);
}
static void
nv_stop_location_change_adapter(NautilusView *view, gpointer dummy)
{
nautilus_view_stop_location_change (view);
}
static void
nautilus_window_stop (GtkWidget *btn, NautilusWindow *window)
{
if (window->content_view != NULL) {
nautilus_view_stop_location_change (window->content_view);
}
g_slist_foreach(window->meta_views, (GFunc) nv_stop_location_change_adapter, NULL);
nautilus_window_end_location_change(window);
}
static void
......@@ -987,52 +959,43 @@ nautilus_window_request_progress_change_cb (NautilusView *view,
nautilus_window_request_progress_change(window, info, view);
}
static void
void
nautilus_window_connect_view(NautilusWindow *window, NautilusView *view)
{
gtk_signal_connect(GTK_OBJECT(view),
GtkObject *viewo;
viewo = GTK_OBJECT(view);
gtk_signal_connect(viewo,
"request_location_change",
nautilus_window_request_location_change_cb,
window);
gtk_signal_connect(GTK_OBJECT(view),
gtk_signal_connect(viewo,
"request_selection_change",
nautilus_window_request_selection_change_cb,
window);
gtk_signal_connect(GTK_OBJECT(view),
gtk_signal_connect(viewo,
"request_status_change",
nautilus_window_request_status_change_cb,
window);
gtk_signal_connect(GTK_OBJECT(view),
gtk_signal_connect(viewo,
"request_progress_change",
nautilus_window_request_progress_change_cb,
window);
gtk_signal_connect(viewo,
"destroy",
nautilus_window_view_destroyed,
window);
}
static void
nautilus_window_disconnect_view(NautilusWindow *window, NautilusView *view)
void
nautilus_window_display_error(NautilusWindow *window, const char *error_msg)
{
gtk_signal_disconnect_by_func(GTK_OBJECT(view),
nautilus_window_request_location_change_cb,
window);
gtk_signal_disconnect_by_func(GTK_OBJECT(view),
nautilus_window_request_selection_change_cb,
window);
gtk_signal_disconnect_by_func(GTK_OBJECT(view),
nautilus_window_request_status_change_cb,
window);
gtk_signal_disconnect_by_func(GTK_OBJECT(view),
nautilus_window_request_progress_change_cb,
window);
}
GtkWidget *dialog;
static void
nautilus_window_disconnect_view_exchanged(NautilusView *view, NautilusWindow *window)
{
nautilus_window_disconnect_view(window, view);
}
dialog = gnome_message_box_new(error_msg, GNOME_MESSAGE_BOX_ERROR, _("Close"), NULL);
gnome_dialog_set_close(GNOME_DIALOG(dialog), TRUE);
gnome_dialog_set_default(GNOME_DIALOG(dialog), 0);
gtk_widget_show(dialog);
}
......@@ -47,6 +47,8 @@ typedef struct {
guint window_signals[0];
} NautilusWindowClass;
typedef struct _NautilusWindowLoadInfo NautilusWindowLoadInfo;
struct _NautilusWindow {
GnomeApp parent_object;
......@@ -70,6 +72,8 @@ struct _NautilusWindow {
/* Information about current location/selection */
Nautilus_NavigationInfo *ni;
Nautilus_SelectionInfo *si;
NautilusWindowLoadInfo *load_info;
};
GtkType nautilus_window_get_type(void);
......@@ -78,6 +82,8 @@ void nautilus_window_set_content_view(NautilusWindow *window, NautilusView *cont
void nautilus_window_add_meta_view(NautilusWindow *window, NautilusView *meta_view);
void nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view);
void nautilus_window_goto_uri(NautilusWindow *window, const char *uri);
void nautilus_window_display_error(NautilusWindow *window, const char *error_msg);
const char *nautilus_window_get_requested_uri(NautilusWindow *window);
GnomeUIHandler *nautilus_window_get_uih(NautilusWindow *window);
......
......@@ -121,15 +121,6 @@ static void nautilus_window_goto_uri_cb (GtkWidget *widget,
GtkWidget *window);
static void nautilus_window_about_cb (GtkWidget *widget,
NautilusWindow *window);
static void nautilus_window_connect_view (NautilusWindow *window,