Ejemplo n.º 1
0
/* main */
int main(int argc, char * argv[])
{
	int o;
	Surfer * surfer;

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
#if defined(WITH_GTKHTML) || defined(WITH_GTKTEXTVIEW) || defined(WITH_WEBKIT)
	if(g_thread_supported() == FALSE)
		g_thread_init(NULL);
#endif /* WITH_GTKHTML */
	gtk_init(&argc, &argv);
	while((o = getopt(argc, argv, "")) != -1)
		switch(o)
		{
			default:
				return _usage();
		}
	if(optind == argc)
		surfer = surfer_new(NULL);
	else
		for(; optind != argc; optind++)
			if((surfer = surfer_new(argv[optind])) == NULL)
				break; /* ignore potential memory leak */
	if(surfer == NULL)
		return 2;
	gtk_main();
	return 0;
}
Ejemplo n.º 2
0
/* on_open_new_window */
static void _on_open_new_window(gpointer data)
{
	GHtml * ghtml = data;

	surfer_new(ghtml->popup_link);
	free(ghtml->popup_link);
	ghtml->popup_link = NULL;
}
Ejemplo n.º 3
0
/* htmlapp_new */
static HTMLApp * _htmlapp_new(void)
{
	HTMLApp * htmlapp;
	GtkAccelGroup * group;
	GtkWidget * vbox;

	if((htmlapp = surfer_new(NULL)) == NULL)
		return NULL;
	htmlapp->source = 0;
	htmlapp->p = NULL;
	/* widgets */
	htmlapp->icontheme = gtk_icon_theme_get_default();
	/* window */
	group = gtk_accel_group_new();
	htmlapp->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_add_accel_group(GTK_WINDOW(htmlapp->window), group);
#ifndef EMBEDDED
	gtk_window_set_default_size(GTK_WINDOW(htmlapp->window), 640, 480);
#else
	gtk_window_set_default_size(GTK_WINDOW(htmlapp->window), 240, 480);
#endif
#if GTK_CHECK_VERSION(2, 6, 0)
	gtk_window_set_icon_name(GTK_WINDOW(htmlapp->window), "web-browser");
#endif
	gtk_window_set_title(GTK_WINDOW(htmlapp->window), _("HTML Application"));
	g_signal_connect_swapped(htmlapp->window, "delete-event", G_CALLBACK(
				_htmlapp_on_closex), htmlapp);
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
	vbox = gtk_vbox_new(FALSE, 0);
#endif
	htmlapp->vbox = vbox;
	desktop_accel_create(_htmlapp_accel, htmlapp, group);
	/* view */
	htmlapp->view = ghtml_new(htmlapp);
	ghtml_set_enable_javascript(htmlapp->view, FALSE);
	gtk_box_pack_start(GTK_BOX(vbox), htmlapp->view, TRUE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(htmlapp->window), vbox);
	gtk_widget_grab_focus(htmlapp->view);
	gtk_widget_show_all(htmlapp->window);
	htmlapp->fi_dialog = NULL;
	htmlapp->ab_window = NULL;
	return htmlapp;
}
Ejemplo n.º 4
0
/* on_create_web_view */
static WebKitWebView * _on_create_web_view(WebKitWebView * view,
		WebKitWebFrame * frame, gpointer data)
{
	GHtml * ghtml;
	Surfer * surfer;
	GtkWidget * widget;

	if((surfer = surfer_new(NULL)) == NULL)
		return NULL;
	/* FIXME we may want the history to be copied (and then more) */
	if((widget = surfer_get_view(surfer)) == NULL)
	{
		surfer_delete(surfer);
		return NULL;
	}
	ghtml = g_object_get_data(G_OBJECT(widget), "ghtml");
	g_signal_connect(G_OBJECT(ghtml->view), "web-view-ready", G_CALLBACK(
				_on_web_view_ready), widget);
	return WEBKIT_WEB_VIEW(ghtml->view);
}