예제 #1
0
void ygtk_html_wrap_set_text (GtkWidget *widget, const gchar* text, gboolean plain_mode)
{
	// TODO: implement plain_mode
	GtkHTMLStream *stream = gtk_html_begin (GTK_HTML (widget));
	gtk_html_write (GTK_HTML (widget), stream, text, strlen (text));
	gtk_html_end (GTK_HTML (widget), stream, GTK_HTML_STREAM_OK);
}
예제 #2
0
GtkHTMLStream * glen_html_begin(GtkHTML *html)
{
	GtkHTMLStream *stream;
	
	stream = gtk_html_begin(html);
	gtk_html_write(html, stream, header, strlen(header));

	return stream;
}
static void
set_html_part (TnyGtkHtmlMimePartView *self, TnyMimePart *part)
{
	SomeData *info = g_slice_new (SomeData);

	info->self = (TnyGtkHtmlMimePartView *) g_object_ref (self);
	info->gtkhtml_stream = gtk_html_begin(GTK_HTML(self));
	info->tny_stream = TNY_STREAM (tny_gtk_html_stream_new (info->gtkhtml_stream));
	tny_stream_reset (info->tny_stream);

	tny_mime_part_decode_to_stream_async ((TnyMimePart*)part, info->tny_stream, 
			on_set_stream_finished, on_status, info);

	return;
}
static void
on_html_http_link_clicked (C2Pthread3 *data)
{
	C2Request *request;
	const gchar *url = data->v2;
	GtkHTML *html = GTK_HTML (data->v1);
	GtkHTMLStream *stream;

	stream = gtk_html_begin (html);
	data->v3 = (gpointer) stream;
	
	request = c2_request_new (url);
	gtk_signal_connect (GTK_OBJECT (request), "exchange",
							GTK_SIGNAL_FUNC (on_html_http_link_clicked_exchange), data);
	gtk_signal_connect (GTK_OBJECT (request), "disconnect",
							GTK_SIGNAL_FUNC (on_html_http_link_clicked_disconnect), data);
	c2_request_run (request);
}
예제 #5
0
파일: slib-editor.c 프로젝트: acli/xiphos
static void
view_source_dialog(GtkhtmlEditor *editor,
		   const gchar *title,
		   const gchar *content_type, gboolean show_output)
{
	GtkWidget *dialog;
	GtkWidget *content;
	GtkWidget *scrolled_window;
	GString *string;

	dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(editor),
					     GTK_DIALOG_DESTROY_WITH_PARENT,
#ifdef HAVE_GTK_310
					     "_Close", GTK_RESPONSE_CLOSE,
#else
					     GTK_STOCK_CLOSE,
					     GTK_RESPONSE_CLOSE,
#endif
					     NULL);

	scrolled_window = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
				       GTK_POLICY_AUTOMATIC,
				       GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window),
					    GTK_SHADOW_IN);
	gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), scrolled_window, TRUE,
			   TRUE, 0);

	gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
	gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 6);
	gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 300);

	string = g_string_sized_new(4096);

	gtk_html_export(gtkhtml_editor_get_html(editor),
			content_type, (GtkHTMLSaveReceiverFn)
			view_source_dialog_receiver,
			string);

	if (show_output) {
		GtkHTMLStream *stream;

		content = gtk_html_new();
		stream = gtk_html_begin(GTK_HTML(content));
		gtk_html_stream_write(stream, string->str, string->len);
		gtk_html_stream_close(stream, GTK_HTML_STREAM_OK);
	} else {
		GtkTextBuffer *buffer;

		content = gtk_text_view_new();
		buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(content));
		gtk_text_buffer_set_text(buffer, string->str, string->len);
		gtk_text_view_set_editable(GTK_TEXT_VIEW(content), FALSE);
	}

	g_string_free(string, TRUE);

	gtk_container_add(GTK_CONTAINER(scrolled_window), content);
	gtk_widget_show_all(scrolled_window);

	gtk_dialog_run(GTK_DIALOG(dialog));
	gtk_widget_destroy(dialog);
}
예제 #6
0
void
html_frame_init (HTMLFrame *frame,
                  HTMLFrameClass *klass,
                  GtkWidget *parent,
                  gchar *src,
                  gint width,
                  gint height,
                  gboolean border)
{
	HTMLEmbedded *em = HTML_EMBEDDED (frame);
	HTMLTokenizer *new_tokenizer;
	GtkWidget *new_widget;
	GtkHTML   *new_html;
	GtkHTML   *parent_html;
	GtkWidget *scrolled_window;

	g_assert (GTK_IS_HTML (parent));
	parent_html = GTK_HTML (parent);

	html_embedded_init (em, HTML_EMBEDDED_CLASS (klass),
			    parent, NULL, NULL);

	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
					     border ? GTK_SHADOW_IN : GTK_SHADOW_NONE);

	new_widget = gtk_html_new ();
	new_html = GTK_HTML (new_widget);

	new_tokenizer = html_tokenizer_clone (parent_html->engine->ht);

	html_engine_set_tokenizer (new_html->engine, new_tokenizer);
	g_object_unref (G_OBJECT (new_tokenizer));
	new_tokenizer = NULL;

	gtk_html_set_default_content_type (new_html,
					   gtk_html_get_default_content_type (parent_html));

	gtk_html_set_default_engine (new_html,
					   gtk_html_get_default_engine (parent_html));

	frame->html = new_widget;
	frame->url = g_strdup (src);
	frame->width = width;
	frame->height = height;
	frame->gdk_painter = NULL;
	gtk_html_set_base (new_html, src);
	gtk_html_set_iframe_parent (new_html, parent, HTML_OBJECT (frame));
	gtk_container_add (GTK_CONTAINER (scrolled_window), new_widget);
	gtk_widget_show (new_widget);

	g_signal_connect (new_html, "url_requested", G_CALLBACK (frame_url_requested), frame);

	if (parent_html->engine->stopped) {
		gtk_html_stop (new_html);
		gtk_html_load_empty (new_html);
	} else {
		GtkHTMLStream *handle;

		handle = gtk_html_begin (new_html);
		g_signal_emit_by_name (parent_html->engine, "url_requested", src, handle);
	}

	new_html->engine->clue->parent = HTML_OBJECT (frame);

#if 0
	/* NOTE: because of peculiarities of the frame/gtkhtml relationship
	 * on_url and link_clicked are emitted from the toplevel widget not
	 * proxied like url_requested is.
	 */
	g_signal_connect (new_html, "on_url", G_CALLBACK (frame_on_url), frame);
	g_signal_connect (new_html, "link_clicked", G_CALLBACK (frame_link_clicked), frame);
#endif
	g_signal_connect (new_html, "size_changed", G_CALLBACK (frame_size_changed), frame);
	g_signal_connect (new_html, "object_requested", G_CALLBACK (frame_object_requested), frame);
	g_signal_connect (new_html, "submit", G_CALLBACK (frame_submit), frame);
	g_signal_connect (new_html, "set_base", G_CALLBACK (frame_set_base), frame);

	html_frame_set_margin_height (frame, 0);
	html_frame_set_margin_width (frame, 0);

	/*
	  g_signal_connect (html, "button_press_event", G_CALLBACK (frame_button_press_event), frame);
	*/

	gtk_widget_set_size_request (scrolled_window, width, height);

	gtk_widget_show (scrolled_window);
	frame->scroll = scrolled_window;
	html_frame_set_scrolling (frame, GTK_POLICY_AUTOMATIC);

	html_embedded_set_widget (em, scrolled_window);

	g_signal_connect (scrolled_window, "button_press_event", G_CALLBACK (html_frame_grab_cursor), NULL);

	/* inherit the current colors from our parent */
	html_colorset_set_unchanged (new_html->engine->defaultSettings->color_set,
				     parent_html->engine->settings->color_set);
	html_colorset_set_unchanged (new_html->engine->settings->color_set,
				     parent_html->engine->settings->color_set);
	html_painter_set_focus (new_html->engine->painter, parent_html->engine->have_focus);
	/*
	g_signal_connect (html, "title_changed", G_CALLBACK (title_changed_cb), app);
	g_signal_connect (html, "button_press_event", G_CALLBACK (on_button_press_event), popup_menu);
	g_signal_connect (html, "redirect", G_CALLBACK (on_redirect), NULL);
	g_signal_connect (html, "object_requested", G_CALLBACK (object_requested_cmd), NULL);
	*/
}