Commit c1b54309 authored by Elliot Lee's avatar Elliot Lee
Browse files

Allow passing initial URL on cmdline.



Allow passing initial URL on cmdline.

Try to make web browser work.
parent 4994722e
- Allow passing document title around
- Allow indication of progress.
......@@ -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);
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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);
......
......@@ -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
......
#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
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
#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
......
......@@ -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
......@@ -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
......
......@@ -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
......
#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
......@@ -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;
......
#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
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment