Documentation ¶
Overview ¶
Example ¶
package main import ( "fmt" "runtime" "github.com/gotk3/gotk3/glib" "github.com/gotk3/gotk3/gtk" "github.com/sourcegraph/go-webkit2/webkit2" ) func main() { runtime.LockOSThread() gtk.Init(nil) webView := webkit2.NewWebView() defer webView.Destroy() webView.Connect("load-failed", func() { fmt.Println("Load failed.") }) webView.Connect("load-changed", func(_ *glib.Object, i int) { loadEvent := webkit2.LoadEvent(i) switch loadEvent { case webkit2.LoadFinished: fmt.Println("Load finished.") fmt.Printf("Title: %q\n", webView.Title()) fmt.Printf("URI: %s\n", webView.URI()) } }) glib.IdleAdd(func() bool { webView.LoadURI("https://status.github.com/") return false }) gtk.Main() }
Output: Load finished. Title: "GitHub System Status" URI: https://status.github.com/ Hostname (from JavaScript): "status.github.com"
Index ¶
- type CacheModel
- type LoadEvent
- type Settings
- func (s *Settings) GetAutoLoadImages() bool
- func (s *Settings) GetEnableWriteConsoleMessagesToStdout() bool
- func (s *Settings) SetAutoLoadImages(autoLoad bool)
- func (s *Settings) SetEnableWriteConsoleMessagesToStdout(write bool)
- func (s *Settings) SetUserAgentWithApplicationDetails(appName, appVersion string)
- type WebContext
- type WebView
- func (v *WebView) Context() *WebContext
- func (v *WebView) Destroy()
- func (v *WebView) GetSnapshot(resultCallback func(result *image.RGBA, err error))
- func (v *WebView) LoadHTML(content, baseURI string)
- func (v *WebView) LoadURI(uri string)
- func (v *WebView) Settings() *Settings
- func (v *WebView) Title() string
- func (v *WebView) URI() string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheModel ¶
type CacheModel int
CacheModel describes the caching behavior.
See also: WebKitCacheModel at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebContext.html#WebKitCacheModel.
const ( DocumentViewerCacheModel CacheModel = iota WebBrowserCacheModel DocumentBrowserCacheModel )
CacheModel enum values are described at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebContext.html#WebKitCacheModel.
type LoadEvent ¶
type LoadEvent int
LoadEvent denotes the different events that happen during a WebView load operation.
See also: WebKitLoadEvent at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#WebKitLoadEvent.
LoadEvent enum values are described at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#WebKitLoadEvent.
type Settings ¶
func (*Settings) GetAutoLoadImages ¶
GetAutoLoadImages returns the "auto-load-images" property.
See also: webkit_settings_get_auto_load_images at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html#webkit-settings-get-auto-load-images
func (*Settings) GetEnableWriteConsoleMessagesToStdout ¶
GetEnableWriteConsoleMessagesToStdout returns the "enable-write-console-messages-to-stdout" property.
See also: webkit_settings_get_enable_write_console_messages_to_stdout at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html#webkit-settings-get-enable-write-console-messages-to-stdout
func (*Settings) SetAutoLoadImages ¶
SetAutoLoadImages sets the "auto-load-images" property.
See also: webkit_settings_get_auto_load_images at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html#webkit-settings-set-auto-load-images
func (*Settings) SetEnableWriteConsoleMessagesToStdout ¶
SetEnableWriteConsoleMessagesToStdout sets the "enable-write-console-messages-to-stdout" property.
See also: webkit_settings_set_enable_write_console_messages_to_stdout at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html#webkit-settings-set-enable-write-console-messages-to-stdout
func (*Settings) SetUserAgentWithApplicationDetails ¶
SetUserAgentWithApplicationDetails sets the "user-agent" property by appending the application details to the default user agent.
See also: webkit_settings_set_user_agent_with_application_details at http://webkitgtk.org/reference/webkit2gtk/unstable/WebKitSettings.html#webkit-settings-set-user-agent-with-application-details
type WebContext ¶
type WebContext struct {
// contains filtered or unexported fields
}
WebContext manages all aspects common to all WebViews.
See also: WebKitWebContext at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebContext.html.
func DefaultWebContext ¶
func DefaultWebContext() *WebContext
DefaultWebContext returns the default WebContext.
See also: webkit_web_context_get_default at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebContext.html#webkit-web-context-get-default.
func (*WebContext) CacheModel ¶
func (wc *WebContext) CacheModel() CacheModel
CacheModel returns the current cache model.
See also: webkit_web_context_get_cache_model at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebContext.html#webkit-web-context-get-cache-model.
func (*WebContext) ClearCache ¶
func (wc *WebContext) ClearCache()
ClearCache clears all resources currently cached.
See also: webkit_web_context_clear_cache at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebContext.html#webkit-web-context-clear-cache.
func (*WebContext) SetCacheModel ¶
func (wc *WebContext) SetCacheModel(model CacheModel)
SetCacheModel sets the current cache model.
See also: webkit_web_context_set_cache_model at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebContext.html#webkit-web-context-set-cache-model.
type WebView ¶
WebView represents a WebKit WebView.
See also: WebView at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html.
func NewWebView ¶
func NewWebView() *WebView
NewWebView creates a new WebView with the default WebContext and the default WebViewGroup.
See also: webkit_web_view_new at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-new.
func NewWebViewWithContext ¶
func NewWebViewWithContext(ctx *WebContext) *WebView
NewWebViewWithContext creates a new WebView with the given WebContext and the default WebViewGroup.
See also: webkit_web_view_new_with_context at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-new-with-context.
func (*WebView) Context ¶
func (v *WebView) Context() *WebContext
Context returns the current WebContext of the WebView.
See also: webkit_web_view_get_context at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-get-context.
func (*WebView) Destroy ¶
func (v *WebView) Destroy()
Destroy destroys the WebView's corresponding GtkWidget and marks its internal WebKitWebView as nil so that it can't be accidentally reused.
func (*WebView) GetSnapshot ¶
GetSnapshot runs asynchronously, taking a snapshot of the WebView. Upon completion, resultCallback will be called with a copy of the underlying bitmap backing store for the frame, or with an error encountered during execution.
See also: webkit_web_view_get_snapshot at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-get-snapshot
func (*WebView) LoadHTML ¶
LoadHTML loads the given content string with the specified baseURI. The MIME type of the document will be "text/html".
See also: webkit_web_view_load_html at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-load-html
func (*WebView) LoadURI ¶
LoadURI requests loading of the specified URI string.
See also: webkit_web_view_load_uri at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-load-uri
func (*WebView) Settings ¶
Settings returns the current active settings of this WebView's WebViewGroup.
See also: webkit_web_view_get_settings at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-get-settings.
func (*WebView) Title ¶
Title returns the current active title of the WebView.
See also: webkit_web_view_get_title at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-get-title.
func (*WebView) URI ¶
URI returns the current active URI of the WebView.
See also: webkit_web_view_get_uri at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-get-uri.