我正在使用 go-webkit 并且我有一个 webkitsettings 实例,我该如何更改设置?
我正在尝试做这样的事情
main.go
webview := webkit.NewWebView()
settings := webview.GetSettings()
settings.SetEnableJavascript(false)
webview.SetSettings(settings)
来自https://github.com/mattn/go-webkit/blob/master/webkit/webkit.go#L370 的go-webkit片段
type WebSettings struct {
glib.GObject
}
func (settings *WebSettings) SetEnableJavascript (flag bool) {
//I tried various ways
//C.g_object_set?
}
func (v *WebView) SetSettings(settings *WebSettings) {
C.webkit_web_view_set_settings(v.getWebView(), C.to_WebKitWebSettings(settings.Object));
}
func (v *WebView) GetSettings() *WebSettings {
return &WebSettings{glib.GObject{unsafe.Pointer(C.webkit_web_view_get_settings(v.getWebView()))}}
}
func NewWebSettings() *WebSettings {
return &WebSettings{glib.GObject{unsafe.Pointer(C.webkit_web_settings_new())}}
}
Webkit API: 1.0 http://webkitgtk.org/reference/webkitgtk/stable/WebKitWebSettings.html
/* Create a new websettings and disable java script */
WebKitWebSettings *settings = webkit_web_settings_new ();
g_object_set (G_OBJECT(settings), "enable-scripts", FALSE, NULL);
/* Apply the result */
webkit_web_view_set_settings (WEBKIT_WEB_VIEW(my_webview), settings);
慕码人8056858
相关分类