我需要在一个Gtk Widget中嵌入一个非常简单的浏览器(可以解析HTML和JS Ext),希望在gtkmm中。我查看了gtkmozembed,但是c ++包装器已经过时了,所以我试着用C语言编写它,但我已经承诺使用Gtk + 3.0,并且gtkmozembed不适用于Gtk + 3.0。有没有办法只扩展Gtk :: Widget并在其中放置一个gecko解析器?无法找到任何壁虎文档,我一直被重定向到gtkmozembed。
非常感谢任何想法/建议。
编辑: @Mark尝试使用Webkitgtk后,我得到以下输出,应用程序崩溃。
** (ttocui_gtk:16360): DEBUG: NP_Initialize
** (ttocui_gtk:16360): DEBUG: NP_Initialize succeeded
** (ttocui_gtk:16360): DEBUG: NP_Initialize
** (ttocui_gtk:16360): DEBUG: NP_Initialize succeeded
** (ttocui_gtk:16360): DEBUG: NP_Initialize
** (ttocui_gtk:16360): DEBUG: NP_Initialize succeeded
** (ttocui_gtk:16360): DEBUG: NP_Initialize
** (ttocui_gtk:16360): DEBUG: NP_Initialize succeeded
** (ttocui_gtk:16360): DEBUG: NP_Initialize
** (ttocui_gtk:16360): DEBUG: NP_Initialize succeeded
** (ttocui_gtk:16360): DEBUG: NP_Initialize
** (ttocui_gtk:16360): DEBUG: NP_Initialize succeeded
** (ttocui_gtk:16360): DEBUG: NP_Initialize
** (ttocui_gtk:16360): DEBUG: NP_Initialize succeeded
** (ttocui_gtk:16360): DEBUG: NP_Initialize
** (ttocui_gtk:16360): DEBUG: NP_Initialize succeeded
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_foreach: assertion `hash_table != NULL' failed
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_insert_internal: assertion `hash_table != NULL' failed
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed
*** NSPlugin Wrapper *** ERROR: no valid NPP -> PluginInstance mapping found
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed
*** NSPlugin Wrapper *** ERROR: no valid NPP -> PluginInstance mapping found
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_insert_internal: assertion `hash_table != NULL' failed
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_insert_internal: assertion `hash_table != NULL' failed
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_find: assertion `hash_table != NULL' failed
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_insert_internal: assertion `hash_table != NULL' failed
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed
*** NSPlugin Wrapper *** ERROR: no valid NPP -> PluginInstance mapping found
(ttocui_gtk:16360): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed
ttocui_gtk: /build/buildd/nspluginwrapper-1.2.2/src/npw-rpc.c:1225: do_recv_NPObject: Assertion `npobj != ((void *)0)' failed.
*** NSPlugin Viewer *** ERROR: NPN_GetProperty() wait for reply: Connection reset by peer
*** NSPlugin Viewer *** WARNING:(/build/buildd/nspluginwrapper-1.2.2/src/npw-viewer.c:898):invoke_NPN_GetValue: assertion failed: (rpc_method_invoke_possible(g_rpc_connection))
Aborted
*** NSPlugin Viewer *** WARNING: unhandled variable 18 (<unknown variable>) in NPN_GetValue()
*** NSPlugin Viewer *** WARNING:(/build/buildd/nspluginwrapper-1.2.2/src/npw-viewer.c:898):invoke_NPN_GetValue: assertion failed: (rpc_method_invoke_possible(g_rpc_connection))
.js文件包含在我的html页面的head标签中......
<link rel="stylesheet" type="text/css" href="/ext3.2.1/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css" href="/ext3.2.1/resources/css/xtheme-access.css"/>
<script type="text/javascript" src="/ext3.2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="/ext3.2.1/ext-all-debug.js"></script>
答案 0 :(得分:8)
如果我的记忆能为我服务,gtkmozembed也不能使用新版本的Gecko。您正在寻找的是WebkitGTK,至少如果您没有与Gecko特别关联。
答案 1 :(得分:4)
作为@ ptomato答案的附录。 WebKitGTK是要走的路。我不知道它的gtkmm / C ++包装器,但我目前在gtkmm项目中使用它非常成功(幸运的是,gtkmm / C ++允许你很容易地混合使用C gtk):
WebKitWebView* pWebKitView = WEBKIT_WEB_VIEW (webkit_web_view_new ());
gtk_container_add (GTK_CONTAINER (pSomeContainer->gobj()), GTK_WIDGET (pWebKitView));
然后你走了......
答案 2 :(得分:2)
以为我会回来让任何关心的人知道我们的解决方案是使用Gtkmozembed。唯一的问题是Gtkmozembed只运行使用gtk + 2而我使用gtk + 3.这两个不能存在于同一个进程中,而且我不会迁移任何一个项目。所以我在一个使用管道与之通信的子进程中运行gtkmozembed,以及在我的项目中呈现该小部件的GtkPlug。
这个解决方案有点蠢,但它完成了工作,浏览器已嵌入。