Exemple #1
0
static int _ghtml_document_load(GHtml * ghtml, char const * url,
		char const * post)
{
	char const * q;
	History * h;

	_ghtml_stop(ghtml);
	if((q = _history_get_location(ghtml->current)) == NULL
			|| strcmp(q, url) != 0)
	{
		if((h = _history_new(url, post)) == NULL)
			return 1;
		ghtml->current = _history_append(h, ghtml->current);
		ghtml->history = g_list_first(ghtml->current);
	}
	gtk_text_buffer_set_text(ghtml->tbuffer, "", 0);
	free(ghtml->buffer);
	ghtml->buffer = NULL;
	ghtml->buffer_cnt = 0;
	ghtml->search = 0;
	surfer_set_location(ghtml->surfer, url);
	free(ghtml->title);
	ghtml->title = NULL;
	free(ghtml->base);
	ghtml->base = NULL;
	surfer_set_title(ghtml->surfer, NULL);
	if(strncmp(url, "file:", 5) == 0 || strncmp(url, "/", 1) == 0)
		return _document_load_file(ghtml, &url[5]);
	return _document_load_url(ghtml, url, post);
}
Exemple #2
0
static void _document_load_write_node(GHtml * ghtml, XMLNode * node)
{
	GtkTextIter iter;

	if(node == NULL)
		return;
	switch(node->type)
	{
		case XML_NODE_TYPE_DATA:
			if(ghtml->position == GHTML_POSITION_HEAD_TITLE)
			{
				free(ghtml->title);
				ghtml->title = strdup(node->data.buffer);
				surfer_set_title(ghtml->surfer, ghtml->title);
				break;
			}
			else if(ghtml->position != GHTML_POSITION_BODY)
				break;
			/* FIXME looks like memory corruption at some point */
			gtk_text_buffer_get_end_iter(ghtml->tbuffer, &iter);
			gtk_text_buffer_insert_with_tags(ghtml->tbuffer, &iter,
					node->data.buffer, node->data.size,
					ghtml->tag, NULL);
			break;
		case XML_NODE_TYPE_ENTITY:
			_document_load_write_node_entity(ghtml, &node->entity);
			break;
		case XML_NODE_TYPE_TAG:
			_document_load_write_node_tag(ghtml, &node->tag);
			break;
	}
}
Exemple #3
0
static void _on_title_changed(WebKitWebView * view, WebKitWebFrame * frame,
		const gchar * title, gpointer data)
{
	GHtml * ghtml;

	ghtml = g_object_get_data(G_OBJECT(data), "ghtml");
	surfer_set_title(ghtml->surfer, title);
}