关闭

gtk display web contents--gtkhtml

标签: gtkwebhtmlnullcallbackencoding
782人阅读 评论(0) 收藏 举报
分类:

想用gtk 显示web内容? 请使用gtkhtml, 注意:gtkhtml并不是Gtk的原有组建。
/*
* gcc `pkg-config --cflags --libs gtk+-2.0 libgtkhtml-3.8` gtkhtml_demo.c
*/
#include <gtk/gtk.h>
#include <gtkhtml/gtkhtml.h>

//const gchar *html_source = "<B><FONT COLOR=Blue>Hello world!</FONT></B>";

const gchar *html_source = " /
<?xml version=/"1.0/" encoding=/"UTF-8/" ?> /
<dict> /
<key>test</key> <br>/
<lang>ec</lang> <br>/
<audio>http://dict.cn/mp3.php?q=VppwK</audio> <br>/
<pron>test</pron> <br>/
<font color=red><def>n. 测试,试验,考验 <br>/
vt. 测试,试验,接受测验 <br>/
adj. 测试的</def> <br></font>/
<sent><orig>I got B minus in the test.</orig><trans>我在考试中得了个B-。</trans></sent> <br>/
<sent><orig>How did you do on your test?</orig><trans> 你这次考试的结果如何?</trans></sent> <br>/
<sent><orig>Our test flight was to discover the bugs in the new plane.</orig><trans>试验飞行是为了发现新飞机有何毛病。</trans></sent> <br>/
</dict>"
;

gint
main (gint argc, gchar *args [])
{
    GtkWidget *app;
    GtkWidget *html;
    GtkWidget *scrolled_window;

    gtk_init (&argc, &args);

    /* create GtkHTML widget with preloaded content */
    html = gtk_html_new_from_string (html_source, -1);

    /* create GNOME app and put GtkHTML in scrolled window in it */
    app = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(app, "destroy", G_CALLBACK(gtk_main_quit), 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_container_add (GTK_CONTAINER (scrolled_window), html);
    gtk_container_add(GTK_CONTAINER (app), scrolled_window);
    gtk_window_set_default_size (GTK_WINDOW (app), 320, 80);
    gtk_widget_show_all (app);

    /* run the main loop */
    gtk_main ();
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:344786次
    • 积分:3758
    • 等级:
    • 排名:第8563名
    • 原创:29篇
    • 转载:175篇
    • 译文:0篇
    • 评论:37条
    文章分类
    最新评论