webkit

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: EPL-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webkit binds WebKitGTK 4.1 (GTK 3) through purego, without cgo. gen_funcs.go holds the prototypes generated from GIR by tooling/webkitgen; the rest is written from the WebKitGTK, GObject and Soup reference documentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearSessionCookies

func ClearSessionCookies(done func())

ClearSessionCookies deletes the cookies that have no expiry date.

func GetCookies

func GetCookies(url string, done func([]Cookie))

GetCookies reports the cookies the stored jar would send to url.

func Load

func Load() error

Load opens WebKitGTK and binds every generated function; the error names the missing package.

func SetCookie

func SetCookie(url, header string, done func(ok bool))

SetCookie stores header, a Set-Cookie value without the name of the field, as if url had sent it.

Types

type Config

type Config struct {
	Schemes     []string
	Scripts     []string
	Inspectable bool
}

Config is fixed at New: WebKitGTK registers schemes on the context, so they cannot follow the view.

type Cookie struct{ Name, Value string }

Cookie is the part of a cookie the webview package reports.

type View

type View struct {
	Message      func(string)
	NavStarted   func(url string)
	NavFinished  func(url string)
	NavFailed    func(url, msg string)
	TitleChanged func(string)
	// Scheme answers a request on one of Config.Schemes; Content-Type goes in headers.
	Scheme func(url, method string) (status int, headers map[string]string, body []byte)
	// Decide is asked before each navigation; false cancels it. WebKitGTK does not say which frame
	// navigates, so mainFrame is always true.
	Decide func(url string, mainFrame bool) bool
	// Call answers window.gowt.call(msg) from the page, which blocks in window.prompt meanwhile.
	Call func(msg string) string
	// NewWindow is asked when the page opens a window (window.open, target=_blank) and returns the view
	// that takes the page, made by NewRelated inside the call; nil refuses the window.
	NewWindow func(url string) *View
	// Show fires once a window opened by the page is ready to be shown.
	Show func(WindowFeatures)
	// Close fires when the page asks to close its window (window.close).
	Close func()
	// Status gets the link under the pointer, "" when the pointer leaves it.
	Status func(text string)
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*View, error)

func NewRelated

func NewRelated(opener *View, cfg Config) (*View, error)

NewRelated makes the view for a window the page of opener opens; call it inside opener.NewWindow. It shares the process, the context and the user content manager (scripts and message handler) of opener, so cfg.Scripts and cfg.Schemes are ignored.

func (*View) AddScript

func (v *View) AddScript(js string)

AddScript runs js at document start in every frame of pages loaded from now on.

func (*View) Attach

func (v *View) Attach(container uintptr)

Attach adds the view to a GtkContainer and shows it.

func (*View) CanGoBack

func (v *View) CanGoBack() bool

func (*View) CanGoForward

func (v *View) CanGoForward() bool

func (*View) Dispose

func (v *View) Dispose()

func (*View) Eval

func (v *View) Eval(js string, done func(result, err string))

Eval runs js; done gets the value as text ("" for undefined) or the error message.

func (*View) GoBack

func (v *View) GoBack()

func (*View) GoForward

func (v *View) GoForward()

func (*View) LoadBytes

func (v *View) LoadBytes(data []byte, mimeType, encoding, baseURL string)

LoadBytes shows data as a page of mimeType in encoding ("" lets WebKit decide), with baseURL as its address.

func (*View) LoadHTML

func (v *View) LoadHTML(html, baseURL string)

func (*View) LoadRequest

func (v *View) LoadRequest(url string, headers map[string]string)

LoadRequest loads url with extra request headers (GET only: WebKitGTK has no API for another method).

func (*View) LoadURL

func (v *View) LoadURL(url string)

func (*View) Reload

func (v *View) Reload()

func (*View) SetScriptEnabled

func (v *View) SetScriptEnabled(on bool)

SetScriptEnabled switches the page scripts of this view for the pages loaded from now on. A view opened by the page gets settings of its own first, as WebKitGTK shares the opener's.

func (*View) SetSize

func (v *View) SetSize(w, h int)

func (*View) Stop

func (v *View) Stop()

func (*View) URL

func (v *View) URL() string

func (*View) Widget

func (v *View) Widget() uintptr

Widget is the GtkWidget to put in a container.

type WindowFeatures

type WindowFeatures struct {
	X, Y, Width, Height                      int
	MenuBar, StatusBar, ToolBar, LocationBar bool
}

WindowFeatures are the window.open features of a window opened by the page; a zero Width and Height mean none were asked for.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL