Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/malivvan/webkitgtk

pure Go WebKitGTK binding for Linux and FreeBSD
https://github.com/malivvan/webkitgtk

go golang gtk pure-go webkit webkitgtk

Last synced: 1 day ago
JSON representation

pure Go WebKitGTK binding for Linux and FreeBSD

Awesome Lists containing this project

README

        

# webkitgtk [![Go Reference](https://pkg.go.dev/badge/github.com/malivvan/webkitgtk.svg)](https://pkg.go.dev/github.com/malivvan/webkitgtk) [![Release](https://img.shields.io/github/v/release/malivvan/webkitgtk.svg?sort=semver)](https://github.com/malivvan/webkitgtk/releases/latest) [![Go Report Card](https://goreportcard.com/badge/github.com/malivvan/webkitgtk)](https://goreportcard.com/report/github.com/malivvan/webkitgtk) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
Pure Go WebKitGTK binding for **Linux** and **FreeBSD**.

> This is pre release software so expect bugs and potentially API breaking changes
> but each release will be tagged to avoid breaking people's code.

## Installation

```sh
# go 1.21.5+
go get github.com/malivvan/webkitgtk@latest
```

## Example
The following example shows how to create a simple GTK window with a button that closes the application when clicked.
```go
package main

import ui "github.com/malivvan/webkitgtk"

type API struct {
app *ui.App
}

func (a *API) Quit() error {
a.app.Quit()
return nil
}

func main() {
app := ui.New(ui.AppOptions{
Name: "example",
})
app.Open(ui.WindowOptions{
Title: "example",
HTML: `quit`,
Define: map[string]interface{}{
"app": &API{app: app},
},
})
if err := app.Run(); err != nil {
panic(err)
}
}
```
## Running / Building

Running / building defaults to debug mode outputting logs to stderr. To build in release mode use the `release` build tag.

```sh
go build -tags release -ldflags "-s -w" -trimpath
```

The resulting release binary will be about ~6MB in size and cam be compressed further with [UPX](https://upx.github.io/) to about ~2.5MB.

## Examples

- [echo](examples/echo/echo.go) - call go functions from javascript
- [dialog](examples/dialog/dialog.go) - application spawning different types of dialog windows
- [handle](examples/handle/handle.go) - handle requests on the app:// uri scheme to serve embedded files
- [notify](examples/notify/notify.go) - application sending different types of notifications
- [systray](examples/systray/systray.go) - example application showing how to use the systray

## Dependencies
Either
[`webkit2gtk-4.1`](https://pkgs.org/search/?q=webkit2gtk-4.1&on=name)
([*stable*](https://webkitgtk.org/reference/webkit2gtk/stable/)) or
[`webkitgtk-6.0`](https://pkgs.org/search/?q=webkitgtk-6.0&on=name)
([*unstable*](https://webkitgtk.org/reference/webkitgtk/unstable/index.html))
is required at runtime. If both are installed the stable version will be used.


Debian / Ubuntu
apt install libwebkit2gtk-4.1
apt install libwebkitgtk-6.0


RHEL / Fedora
dnf install webkitgtk4
dnf install webkitgtk3


Arch
pacman -S webkit2gtk-4.1
pacman -S webkitgtk-6.0


Alpine
apk add webkit2gtk
apk add webkit2gtk-6.0


Gentoo
emerge -av net-libs/webkit-gtk


FreeBSD
pkg install webkit2-gtk3
pkg install webkit2-gtk4

## License
This project is licensed under the [MIT License](LICENSE).