puregotk-webkit

command module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 7 Imported by: 0

README

puregotk-webkit

WebKitGTK 6 bindings for Go, built on top of puregotk.

Credits

This project is entirely based on the work of @jwijenbergh and their excellent puregotk library. The code generator, type system, and template engine are all from puregotk - this repository simply extends it to generate bindings for WebKitGTK 6.

All credit for the core implementation goes to the original author.

What is this?

Autogenerated WebKitGTK 6 bindings for Go leveraging purego - no Cgo required.

This package provides bindings for:

  • WebKit 6.0 - WebKitGTK web views, settings, and web content rendering
  • JavaScriptCore 6.0 - JavaScript engine bindings
  • Soup 3.0 - HTTP client/server library
  • WebKitWebProcessExtension 6.0 - Web process extensions

NOTE: This library is experimental. Some APIs might be incorrectly exposed.

Advantages

No Cgo needed, thus:

  • Easy cross compilation
  • No C toolchain needed
  • Much faster compile times

Installation

go get github.com/bnema/puregotk-webkit

Requires puregotk as a dependency.

Basic Example

package main

import (
	"os"

	"github.com/jwijenbergh/puregotk/v4/gio"
	"github.com/jwijenbergh/puregotk/v4/gtk"
	"github.com/bnema/puregotk-webkit/webkit"
)

func main() {
	app := gtk.NewApplication("com.example.webview", gio.GApplicationFlagsNoneValue)
	defer app.Unref()

	actcb := func(_ gio.Application) {
		activate(app)
	}
	app.ConnectActivate(&actcb)

	if code := app.Run(len(os.Args), os.Args); code > 0 {
		os.Exit(code)
	}
}

func activate(app *gtk.Application) {
	window := gtk.NewApplicationWindow(app)
	window.SetTitle("WebKit Example")
	window.SetDefaultSize(800, 600)

	webview := webkit.NewWebView()
	webkit.WebViewLoadUri(webview, "https://example.com")

	window.SetChild(&webview.Widget)
	window.Present()
}

Generating the Bindings

To regenerate the bindings from GIR files:

# Copy GIR files from system (requires WebKitGTK dev packages)
./copygir-webkit.sh

# Generate Go bindings
./gen.sh

Requirements:

  • Go >= 1.20
  • goimports
  • WebKitGTK 6 development files (for GIR files)

License

MIT

Acknowledgements

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
gir/pass
package pass implements the first and second pass to go from gir files to go files the first pass collects basic type information the second pass uses the basic type information to go over the gir files again and convert it to go files
package pass implements the first and second pass to go from gir files to go files the first pass collects basic type information the second pass uses the basic type information to go over the gir files again and convert it to go files
gir/types
package types implements types as found in gir XML files NOTE: This was copied largely from (the type definitions) from https://github.com/diamondburned/gotk4
package types implements types as found in gir XML files NOTE: This was copied largely from (the type definitions) from https://github.com/diamondburned/gotk4
gir/util
package util implements some utility functions for parsing/converting gir files TODO: Maybe some of this can more easily be done with regexes?
package util implements some utility functions for parsing/converting gir files TODO: Maybe some of this can more easily be done with regexes?
Package javascriptcore was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package javascriptcore was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package soup was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package soup was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package webkit was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package webkit was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package webkitwebprocessextension was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package webkitwebprocessextension was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT

Jump to

Keyboard shortcuts

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