Exemplo n.º 1
0
Arquivo: tree.c Projeto: jimiszm/peos
void tree_select( GtkTree *tree, xmlNode *action)
{
  int i = 0;
  
  if ( strcmp (action->name, "action") != 0) {
  	gtk_widget_destroy(table[cur_pid].page.text1);
	table[cur_pid].page.text1 = gtk_html_new ();
  	gtk_widget_set_name (table[cur_pid].page.text1, "text1");
  	gtk_widget_ref (table[cur_pid].page.text1);
  	gtk_object_set_data_full (GTK_OBJECT (Peos), "text1", table[cur_pid].page.text1,
                           	(GtkDestroyNotify) gtk_widget_unref);
  	gtk_widget_show (table[cur_pid].page.text1);
  	gtk_container_add (GTK_CONTAINER (table[cur_pid].page.scrollwindow2), table[cur_pid].page.text1);
	deactivate();
  }

  else  {
	table[cur_pid].page.curr = action;
	/* set index to save position when destroyed */
	if (table[cur_pid].process != NULL ) {
		if(process_count > 0) while(linklist[cur_pid][i].cur != table[cur_pid].page.curr && i <= counting_action) i++;
		table[cur_pid].page.index = i;
		draw_text(action);
  		check_state();
	}
  } 
}
Exemplo n.º 2
0
static GtkWidget *create_htmlview(GtkNotebook *notebook)
{

#if defined(USE_WEBKITGTK)
  WebKitWebView *html_widget = WEBKIT_WEB_VIEW(webkit_web_view_new());
#elif defined(USE_GTKHTML)
  GtkWidget *html_widget = gtk_html_new();
#endif
  GtkWidget *scrolled;

  SYLPF_START_FUNC;

  scrolled = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_container_add(GTK_CONTAINER(scrolled), GTK_WIDGET(html_widget));
  gtk_widget_show_all(GTK_WIDGET(scrolled));

  gtk_container_add(GTK_CONTAINER(notebook),
                    GTK_WIDGET(scrolled));
  gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook),
                                  GTK_WIDGET(scrolled), _("HTML"));

  SYLPF_RETURN_VALUE(GTK_WIDGET(html_widget));
}
Exemplo n.º 3
0
gint main (gint argc, gchar *argv[])
{
	GtkWidget *win, *html_widget, *sw;
	GtkHTML *html;
	gint i = 0, n_all, n_successful;

	if (argc > 1)
		return 0;

	gtk_init (&argc, &argv);

	html_widget = gtk_html_new ();
	html = GTK_HTML (html_widget);
	gtk_html_load_empty (html);
	gtk_html_set_editable (html, TRUE);
	win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_set_size_request (win, 600, 400);
	gtk_container_add (GTK_CONTAINER (sw), html_widget);
	gtk_container_add (GTK_CONTAINER (win), sw);

	gtk_widget_show_all (win);
	gtk_widget_show_now (win);

	n_all = n_successful = 0;

	fprintf (stderr, "\nGtkHTML test suite\n");
	fprintf (stderr, "--------------------------------------------------------------------------------\n");
	for (i = 0; tests [i].name; i ++) {
		gint j, result;

		if (tests [i].test_function) {
			fprintf (stderr, "  %s ", tests [i].name);
			for (j = strlen (tests [i].name); j < 69; j ++)
				fputc ('.', stderr);
			result = (*tests [i].test_function) (html);
			fprintf (stderr, " %s\n", result ? "passed" : "failed");

			n_all ++;
			if (result)
				n_successful ++;
		} else {
			fprintf (stderr, "* %s\n", tests [i].name);
		}
	}

	fprintf (stderr, "--------------------------------------------------------------------------------\n");
	fprintf (stderr, "%d tests failed %d tests passed (of %d tests)\n\n", n_all - n_successful, n_successful, n_all);

	gtk_main ();

	return n_all != n_successful;
}
Exemplo n.º 4
0
GtkWidget *glen_html_new()
{
	GtkWidget *ret;

	ret = gtk_html_new();
	g_assert(ret != NULL);
	
	g_signal_connect(G_OBJECT(ret), "url_requested",
		G_CALLBACK(url_requested_cb), NULL);
	g_signal_connect(G_OBJECT(ret), "link_clicked",
		G_CALLBACK(link_clicked_cb), NULL);

	gtk_html_set_animate(GTK_HTML(ret), TRUE);
	gtk_html_set_images_blocking(GTK_HTML(ret), FALSE);

	return ret;
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
void init_html_view() {
	gdk_threads_enter();
	gtk_html = GTK_HTML(gtk_html_new());
	gdk_threads_leave();
}
Exemplo n.º 7
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);
	*/
}