From c1b5430908ac8137f9aca3c6eb6a887c3ffb39c9 Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Wed, 22 Dec 1999 19:02:50 +0000 Subject: [PATCH] Allow passing initial URL on cmdline. Allow passing initial URL on cmdline. Try to make web browser work. --- TODO | 1 - components/html/ntl-web-browser.c | 33 ++++++++++++++++--- .../gnome-icon-container-dnd.c | 4 +-- .../gnome-icon-container-dnd.c | 4 +-- libnautilus/gnome-icon-container-dnd.c | 4 +-- src/file-manager/fm-directory-view.c | 8 +++++ src/nautilus-application.c | 4 +-- src/nautilus-application.h | 2 +- src/nautilus-main.c | 4 ++- src/nautilus-navigation-window.c | 2 +- src/nautilus-object-window.c | 2 +- src/nautilus-spatial-window.c | 2 +- src/nautilus-window-state.c | 17 +++++++--- src/nautilus-window-state.h | 2 +- src/nautilus-window.c | 2 +- src/ntl-app.c | 4 +-- src/ntl-app.h | 2 +- src/ntl-main.c | 4 ++- src/ntl-window-state.c | 17 +++++++--- src/ntl-window-state.h | 2 +- src/ntl-window.c | 2 +- 21 files changed, 83 insertions(+), 39 deletions(-) diff --git a/TODO b/TODO index 3f896b5be..a285d64cb 100644 --- a/TODO +++ b/TODO @@ -1,2 +1 @@ - Allow passing document title around -- Allow indication of progress. diff --git a/components/html/ntl-web-browser.c b/components/html/ntl-web-browser.c index 891a49ee4..c9c64d32b 100644 --- a/components/html/ntl-web-browser.c +++ b/components/html/ntl-web-browser.c @@ -183,8 +183,11 @@ static int netin_stream_flush (HTStream * me) static int netin_stream_free (HTStream * me) { + g_return_val_if_fail(me->handle, HT_ERROR); + + g_message("netin_stream_free"); gtk_html_end(GTK_HTML(me->bi->htmlw), me->handle, GTK_HTML_STREAM_OK); - gtk_html_stream_unref(me->handle); + me->handle = NULL; g_free(me); return HT_OK; @@ -192,8 +195,8 @@ static int netin_stream_free (HTStream * me) static int netin_stream_abort (HTStream * me, HTList * e) { - gtk_html_end(GTK_HTML(me->bi->htmlw), me->handle, GTK_HTML_STREAM_OK); - gtk_html_stream_unref(me->handle); + g_message("netin_stream_abort"); + gtk_html_end(GTK_HTML(me->bi->htmlw), me->handle, GTK_HTML_STREAM_ERROR); g_free(me); return HT_OK; @@ -219,11 +222,30 @@ netin_stream_new (BrowserInfo *bi, GtkHTMLStreamHandle handle) retval->isa = &netin_stream_class; retval->bi = bi; - retval->handle = gtk_html_stream_ref(handle); + retval->handle = handle; return retval; } +static gboolean +do_request_delete(gpointer req) +{ + HTRequest_delete(req); + + return FALSE; +} + +static int +request_terminator (HTRequest * request, HTResponse * response, void * param, int status) { + if (status != HT_LOADED) + g_print("Load couldn't be completed successfully (%p)\n", request); + + g_idle_add(do_request_delete, request); + + return HT_OK; +} + + static void browser_url_requested(GtkWidget *htmlw, const char *url, GtkHTMLStreamHandle handle, BrowserInfo *bi) { @@ -235,6 +257,7 @@ browser_url_requested(GtkWidget *htmlw, const char *url, GtkHTMLStreamHandle han request = HTRequest_new(); writer = netin_stream_new(bi, handle); + HTRequest_setContext(request, writer); HTRequest_setOutputFormat(request, WWW_SOURCE); HTRequest_setOutputStream(request, writer); HTRequest_setAnchor(request, HTAnchor_findAddress(real_url)); @@ -267,6 +290,7 @@ 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) { + HTNet_killAll(); g_free(bi->base_url); g_free(bi->base_target_url); @@ -368,6 +392,7 @@ int main(int argc, char *argv[]) GNORBA_INIT_SERVER_FUNC, &ev); gdk_rgb_init(); glibwww_init("ntl-web-browser", VERSION); + HTNet_addAfter(request_terminator, NULL, NULL, HT_ALL, HT_FILTER_LAST); bonobo_init(orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL); factory = gnome_generic_factory_new_multi("ntl_web_browser_factory", make_obj, NULL); diff --git a/libnautilus-extensions/gnome-icon-container-dnd.c b/libnautilus-extensions/gnome-icon-container-dnd.c index 02f97f181..d8a9a1f35 100644 --- a/libnautilus-extensions/gnome-icon-container-dnd.c +++ b/libnautilus-extensions/gnome-icon-container-dnd.c @@ -36,11 +36,10 @@ struct _DndSelectionItem { }; typedef struct _DndSelectionItem DndSelectionItem; - static GtkTargetEntry drag_types [] = { { GNOME_ICON_CONTAINER_DND_GNOME_ICON_LIST_TYPE, 0, GNOME_ICON_CONTAINER_DND_GNOME_ICON_LIST }, { GNOME_ICON_CONTAINER_DND_URI_LIST_TYPE, 0, GNOME_ICON_CONTAINER_DND_URI_LIST }, - /* { GNOME_ICON_CONTAINER_DND_URL_TYPE, 0, GNOME_ICON_CONTAINER_DND_URL } */ + { GNOME_ICON_CONTAINER_DND_URL_TYPE, 0, GNOME_ICON_CONTAINER_DND_URL } }; static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); @@ -51,7 +50,6 @@ static GtkTargetEntry drop_types [] = { }; static const int num_drop_types = sizeof (drop_types) / sizeof (drop_types[0]); - static GnomeCanvasItem * create_selection_shadow (GnomeIconContainer *container, GList *list) diff --git a/libnautilus-private/gnome-icon-container-dnd.c b/libnautilus-private/gnome-icon-container-dnd.c index 02f97f181..d8a9a1f35 100644 --- a/libnautilus-private/gnome-icon-container-dnd.c +++ b/libnautilus-private/gnome-icon-container-dnd.c @@ -36,11 +36,10 @@ struct _DndSelectionItem { }; typedef struct _DndSelectionItem DndSelectionItem; - static GtkTargetEntry drag_types [] = { { GNOME_ICON_CONTAINER_DND_GNOME_ICON_LIST_TYPE, 0, GNOME_ICON_CONTAINER_DND_GNOME_ICON_LIST }, { GNOME_ICON_CONTAINER_DND_URI_LIST_TYPE, 0, GNOME_ICON_CONTAINER_DND_URI_LIST }, - /* { GNOME_ICON_CONTAINER_DND_URL_TYPE, 0, GNOME_ICON_CONTAINER_DND_URL } */ + { GNOME_ICON_CONTAINER_DND_URL_TYPE, 0, GNOME_ICON_CONTAINER_DND_URL } }; static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); @@ -51,7 +50,6 @@ static GtkTargetEntry drop_types [] = { }; static const int num_drop_types = sizeof (drop_types) / sizeof (drop_types[0]); - static GnomeCanvasItem * create_selection_shadow (GnomeIconContainer *container, GList *list) diff --git a/libnautilus/gnome-icon-container-dnd.c b/libnautilus/gnome-icon-container-dnd.c index 02f97f181..d8a9a1f35 100644 --- a/libnautilus/gnome-icon-container-dnd.c +++ b/libnautilus/gnome-icon-container-dnd.c @@ -36,11 +36,10 @@ struct _DndSelectionItem { }; typedef struct _DndSelectionItem DndSelectionItem; - static GtkTargetEntry drag_types [] = { { GNOME_ICON_CONTAINER_DND_GNOME_ICON_LIST_TYPE, 0, GNOME_ICON_CONTAINER_DND_GNOME_ICON_LIST }, { GNOME_ICON_CONTAINER_DND_URI_LIST_TYPE, 0, GNOME_ICON_CONTAINER_DND_URI_LIST }, - /* { GNOME_ICON_CONTAINER_DND_URL_TYPE, 0, GNOME_ICON_CONTAINER_DND_URL } */ + { GNOME_ICON_CONTAINER_DND_URL_TYPE, 0, GNOME_ICON_CONTAINER_DND_URL } }; static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); @@ -51,7 +50,6 @@ static GtkTargetEntry drop_types [] = { }; static const int num_drop_types = sizeof (drop_types) / sizeof (drop_types[0]); - static GnomeCanvasItem * create_selection_shadow (GnomeIconContainer *container, GList *list) diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 43065621a..f3c33d96e 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -571,11 +571,19 @@ init (FMDirectoryView *directory_view) directory_view->display_selection_idle_id = 0; +#if 0 directory_view->scroll_frame = gtk_scroll_frame_new(NULL, NULL); gtk_scroll_frame_set_policy (GTK_SCROLL_FRAME(directory_view->scroll_frame), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scroll_frame_set_shadow_type (GTK_SCROLL_FRAME(directory_view->scroll_frame), GTK_SHADOW_IN); +#else + directory_view->scroll_frame = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(directory_view->scroll_frame), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + +#endif gtk_widget_show(directory_view->scroll_frame); gtk_container_add(GTK_CONTAINER(directory_view), directory_view->scroll_frame); diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 0f9643fd4..861a447b9 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -29,7 +29,7 @@ nautilus_make_object(GnomeGenericFactory *gfact, const char *goad_id, gpointer c } void -nautilus_app_init(void) +nautilus_app_init(const char *initial_url) { NautilusWindow *mainwin; @@ -39,7 +39,7 @@ nautilus_app_init(void) /* Set default configuration */ mainwin = nautilus_app_create_window(); bonobo_activate(); - nautilus_window_set_initial_state(mainwin); + nautilus_window_set_initial_state(mainwin, initial_url); } static void diff --git a/src/nautilus-application.h b/src/nautilus-application.h index 3aba90b09..4af66b54e 100644 --- a/src/nautilus-application.h +++ b/src/nautilus-application.h @@ -1,7 +1,7 @@ #ifndef NTL_APP_H #define NTL_APP_H 1 -void nautilus_app_init(void); +void nautilus_app_init(const char *initial_url); NautilusWindow *nautilus_app_create_window(void); #endif diff --git a/src/nautilus-main.c b/src/nautilus-main.c index f951b60aa..e3b35edfb 100644 --- a/src/nautilus-main.c +++ b/src/nautilus-main.c @@ -35,6 +35,7 @@ int main(int argc, char *argv[]) struct poptOption options[] = { { NULL, '\0', 0, NULL, 0, NULL, NULL } }; + const char **args; /* FIXME: This should also include G_LOG_LEVEL_WARNING, but I had to take it * out temporarily so we could continue to work on other parts of the software @@ -48,7 +49,8 @@ int main(int argc, char *argv[]) g_thread_init(NULL); gnome_vfs_init(); - nautilus_app_init(); + args = poptGetArgs(ctx); + nautilus_app_init(args?args[0]:NULL); bonobo_main(); return 0; diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index 83fafde27..056f6d29e 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -863,7 +863,7 @@ nautilus_window_reload (GtkWidget *btn, NautilusWindow *window) static void nautilus_window_home (GtkWidget *btn, NautilusWindow *window) { - nautilus_window_set_initial_state(window); + nautilus_window_set_initial_state(window, NULL); } static void diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index 83fafde27..056f6d29e 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -863,7 +863,7 @@ nautilus_window_reload (GtkWidget *btn, NautilusWindow *window) static void nautilus_window_home (GtkWidget *btn, NautilusWindow *window) { - nautilus_window_set_initial_state(window); + nautilus_window_set_initial_state(window, NULL); } static void diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index 83fafde27..056f6d29e 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -863,7 +863,7 @@ nautilus_window_reload (GtkWidget *btn, NautilusWindow *window) static void nautilus_window_home (GtkWidget *btn, NautilusWindow *window) { - nautilus_window_set_initial_state(window); + nautilus_window_set_initial_state(window, NULL); } static void diff --git a/src/nautilus-window-state.c b/src/nautilus-window-state.c index c7050c34d..43f009e8e 100644 --- a/src/nautilus-window-state.c +++ b/src/nautilus-window-state.c @@ -1,12 +1,19 @@ #include "nautilus.h" void -nautilus_window_set_initial_state(NautilusWindow *window) +nautilus_window_set_initial_state(NautilusWindow *window, const char *initial_url) { - GString* path_name = g_string_new("file://"); - g_string_append(path_name, g_get_home_dir()); - nautilus_window_goto_uri(window, path_name->str); - g_string_free(path_name, TRUE); + if(initial_url) + nautilus_window_goto_uri(window, initial_url); + else + { + GString* path_name; + + path_name = g_string_new("file://"); + g_string_append(path_name, g_get_home_dir()); + nautilus_window_goto_uri(window, path_name->str); + g_string_free(path_name, TRUE); + } } void diff --git a/src/nautilus-window-state.h b/src/nautilus-window-state.h index a2edb71b9..aa5c88ad4 100644 --- a/src/nautilus-window-state.h +++ b/src/nautilus-window-state.h @@ -5,6 +5,6 @@ void nautilus_window_save_state(NautilusWindow *window, const char *config_path); void nautilus_window_load_state(NautilusWindow *window, const char *config_path); -void nautilus_window_set_initial_state(NautilusWindow *window); +void nautilus_window_set_initial_state(NautilusWindow *window, const char *initial_url); #endif diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 83fafde27..056f6d29e 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -863,7 +863,7 @@ nautilus_window_reload (GtkWidget *btn, NautilusWindow *window) static void nautilus_window_home (GtkWidget *btn, NautilusWindow *window) { - nautilus_window_set_initial_state(window); + nautilus_window_set_initial_state(window, NULL); } static void diff --git a/src/ntl-app.c b/src/ntl-app.c index 0f9643fd4..861a447b9 100644 --- a/src/ntl-app.c +++ b/src/ntl-app.c @@ -29,7 +29,7 @@ nautilus_make_object(GnomeGenericFactory *gfact, const char *goad_id, gpointer c } void -nautilus_app_init(void) +nautilus_app_init(const char *initial_url) { NautilusWindow *mainwin; @@ -39,7 +39,7 @@ nautilus_app_init(void) /* Set default configuration */ mainwin = nautilus_app_create_window(); bonobo_activate(); - nautilus_window_set_initial_state(mainwin); + nautilus_window_set_initial_state(mainwin, initial_url); } static void diff --git a/src/ntl-app.h b/src/ntl-app.h index 3aba90b09..4af66b54e 100644 --- a/src/ntl-app.h +++ b/src/ntl-app.h @@ -1,7 +1,7 @@ #ifndef NTL_APP_H #define NTL_APP_H 1 -void nautilus_app_init(void); +void nautilus_app_init(const char *initial_url); NautilusWindow *nautilus_app_create_window(void); #endif diff --git a/src/ntl-main.c b/src/ntl-main.c index f951b60aa..e3b35edfb 100644 --- a/src/ntl-main.c +++ b/src/ntl-main.c @@ -35,6 +35,7 @@ int main(int argc, char *argv[]) struct poptOption options[] = { { NULL, '\0', 0, NULL, 0, NULL, NULL } }; + const char **args; /* FIXME: This should also include G_LOG_LEVEL_WARNING, but I had to take it * out temporarily so we could continue to work on other parts of the software @@ -48,7 +49,8 @@ int main(int argc, char *argv[]) g_thread_init(NULL); gnome_vfs_init(); - nautilus_app_init(); + args = poptGetArgs(ctx); + nautilus_app_init(args?args[0]:NULL); bonobo_main(); return 0; diff --git a/src/ntl-window-state.c b/src/ntl-window-state.c index c7050c34d..43f009e8e 100644 --- a/src/ntl-window-state.c +++ b/src/ntl-window-state.c @@ -1,12 +1,19 @@ #include "nautilus.h" void -nautilus_window_set_initial_state(NautilusWindow *window) +nautilus_window_set_initial_state(NautilusWindow *window, const char *initial_url) { - GString* path_name = g_string_new("file://"); - g_string_append(path_name, g_get_home_dir()); - nautilus_window_goto_uri(window, path_name->str); - g_string_free(path_name, TRUE); + if(initial_url) + nautilus_window_goto_uri(window, initial_url); + else + { + GString* path_name; + + path_name = g_string_new("file://"); + g_string_append(path_name, g_get_home_dir()); + nautilus_window_goto_uri(window, path_name->str); + g_string_free(path_name, TRUE); + } } void diff --git a/src/ntl-window-state.h b/src/ntl-window-state.h index a2edb71b9..aa5c88ad4 100644 --- a/src/ntl-window-state.h +++ b/src/ntl-window-state.h @@ -5,6 +5,6 @@ void nautilus_window_save_state(NautilusWindow *window, const char *config_path); void nautilus_window_load_state(NautilusWindow *window, const char *config_path); -void nautilus_window_set_initial_state(NautilusWindow *window); +void nautilus_window_set_initial_state(NautilusWindow *window, const char *initial_url); #endif diff --git a/src/ntl-window.c b/src/ntl-window.c index 83fafde27..056f6d29e 100644 --- a/src/ntl-window.c +++ b/src/ntl-window.c @@ -863,7 +863,7 @@ nautilus_window_reload (GtkWidget *btn, NautilusWindow *window) static void nautilus_window_home (GtkWidget *btn, NautilusWindow *window) { - nautilus_window_set_initial_state(window); + nautilus_window_set_initial_state(window, NULL); } static void