webview

package module
v0.0.0-...-56264b1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 5 Imported by: 0

README

Requirements

A webview fork with additional ability to set user-agent.

Right now supports setting user-agent only on linux 

Tools

  • Cmake
  • Ninja

Packages

  • Debian:
    • WebKitGTK 6.0, GTK 4:
      • Development: apt install libgtk-4-dev libwebkitgtk-6.0-dev
      • Production: apt install libgtk-4-1 libwebkitgtk-6.0-4
    • WebKitGTK 4.1, GTK 3, libsoup 3:
      • Development: apt install libgtk-3-dev libwebkit2gtk-4.1-dev
      • Production: apt install libgtk-3-0 libwebkit2gtk-4.1-0
    • WebKitGTK 4.0, GTK 3, libsoup 2:
      • Development: apt install libgtk-3-dev libwebkit2gtk-4.0-dev
      • Production: apt install libgtk-3-0 libwebkit2gtk-4.0-37
  • Fedora:
    • WebKitGTK 6.0, GTK 4:
      • Development: dnf install gtk4-devel webkitgtk6.0-devel
      • Production: dnf install gtk4 webkitgtk6.0
    • WebKitGTK 4.1, GTK 3, libsoup 3:
      • Development: dnf install gtk3-devel webkit2gtk4.1-devel
      • Production: dnf install gtk3 webkit2gtk4.1
    • WebKitGTK 4.0, GTK 3, libsoup 2:
      • Development: dnf install gtk3-devel webkit2gtk4.0-devel
      • Production: dnf install gtk3 webkit2gtk4.0
  • FreeBSD:
    • GTK 4: pkg install webkit2-gtk4
    • GTK 3: pkg install webkit2-gtk3

Development Dependencies

In addition to the dependencies mentioned earlier in this document for developing with the webview library, the following are used during development of the webview library.

  • Amalgamation:
    • Python >= 3.9
  • Checks:
    • clang-format
    • clang-tidy
  • Documentation:
    • Doxygen
    • Graphvis

How to compile

make build

Documentation

Index

Constants

View Source
const (
	// Width and height are default size
	HintNone = 0

	// Window size can not be changed by a user
	HintFixed = 1

	// Width and height are minimum bounds
	HintMin = 2

	// Width and height are maximum bounds
	HintMax = 3
)

Variables

View Source
var Swig_escape_always_false bool
View Source
var Swig_escape_val interface{}
View Source
var WEBVIEW_HINT_FIXED int = _swig_getWEBVIEW_HINT_FIXED()
View Source
var WEBVIEW_HINT_MAX int = _swig_getWEBVIEW_HINT_MAX()
View Source
var WEBVIEW_HINT_MIN int = _swig_getWEBVIEW_HINT_MIN()
View Source
var WEBVIEW_HINT_NONE int = _swig_getWEBVIEW_HINT_NONE()

Functions

func Swig_free

func Swig_free(arg1 uintptr)

func Swig_malloc

func Swig_malloc(arg1 int) (_swig_ret uintptr)

func Webview_bind

func Webview_bind(arg1 uintptr, arg2 string, arg3 _swig_fnptr, arg4 uintptr)

func Webview_create

func Webview_create(arg1 int, arg2 uintptr) (_swig_ret uintptr)

func Webview_destroy

func Webview_destroy(arg1 uintptr)

func Webview_dispatch

func Webview_dispatch(arg1 uintptr, arg2 _swig_fnptr, arg3 uintptr)

func Webview_eval

func Webview_eval(arg1 uintptr, arg2 string)

func Webview_get_native_handle

func Webview_get_native_handle(arg1 uintptr, arg2 Webview_native_handle_kind_t) (_swig_ret uintptr)

func Webview_get_window

func Webview_get_window(arg1 uintptr) (_swig_ret uintptr)

func Webview_init

func Webview_init(arg1 uintptr, arg2 string)

func Webview_navigate

func Webview_navigate(arg1 uintptr, arg2 string)

func Webview_return

func Webview_return(arg1 uintptr, arg2 string, arg3 int, arg4 string)

func Webview_run

func Webview_run(arg1 uintptr)

func Webview_set_html

func Webview_set_html(arg1 uintptr, arg2 string)

func Webview_set_size

func Webview_set_size(arg1 uintptr, arg2 int, arg3 int, arg4 Webview_hint_t)

func Webview_set_title

func Webview_set_title(arg1 uintptr, arg2 string)

func Webview_set_user_agent

func Webview_set_user_agent(arg1 uintptr, arg2 string)

func Webview_terminate

func Webview_terminate(arg1 uintptr)

func Webview_unbind

func Webview_unbind(arg1 uintptr, arg2 string)

Types

type Hint

type Hint int

Hints are used to configure window sizing and resizing

type SwigcptrWebview_native_handle_kind_t

type SwigcptrWebview_native_handle_kind_t uintptr

func (SwigcptrWebview_native_handle_kind_t) Swigcptr

type WebView

type WebView interface {

	// Run runs the main loop until it's terminated. After this function exits -
	// you must destroy the webview.
	Run()

	// Terminate stops the main loop. It is safe to call this function from
	// a background thread.
	Terminate()

	// Destroy destroys a webview and closes the native window.
	Destroy()

	// Window returns a native window handle pointer. When using GTK backend the
	// pointer is GtkWindow pointer, when using Cocoa backend the pointer is
	// NSWindow pointer, when using Win32 backend the pointer is HWND pointer.
	Window() unsafe.Pointer

	// SetTitle updates the title of the native window. Must be called from the UI
	// thread.
	SetTitle(title string)

	// SetSize updates native window size. See Hint constants.
	SetSize(w int, h int, hint Hint)

	// Navigate navigates webview to the given URL. URL may be a properly encoded data.
	// URI. Examples:
	// w.Navigate("https://github.com/webview/webview")
	// w.Navigate("data:text/html,%3Ch1%3EHello%3C%2Fh1%3E")
	// w.Navigate("data:text/html;base64,PGgxPkhlbGxvPC9oMT4=")
	Navigate(url string)

	SetUserAgent(userAgent string)

	// SetHtml sets the webview HTML directly.
	// Example: w.SetHtml(w, "<h1>Hello</h1>");
	SetHtml(html string)

	// Init injects JavaScript code at the initialization of the new page. Every
	// time the webview will open a the new page - this initialization code will
	// be executed. It is guaranteed that code is executed before window.onload.
	Init(js string)

	// Eval evaluates arbitrary JavaScript code. Evaluation happens asynchronously,
	// also the result of the expression is ignored. Use RPC bindings if you want
	// to receive notifications about the results of the evaluation.
	Eval(js string)
}

func New

func New(debug bool) WebView

New calls NewWindow to create a new window and a new webview instance. If debug is non-zero - developer tools will be enabled (if the platform supports them).

func NewWindow

func NewWindow(debug bool, window unsafe.Pointer) WebView

NewWindow creates a new webview instance. If debug is non-zero - developer tools will be enabled (if the platform supports them). Window parameter can be a pointer to the native window handle. If it's non-null - then child WebView is embedded into the given parent window. Otherwise a new window is created. Depending on the platform, a GtkWindow, NSWindow or HWND pointer can be passed here.

type Webview_hint_t

type Webview_hint_t int

type Webview_native_handle_kind_t

type Webview_native_handle_kind_t interface {
	Swigcptr() uintptr
}

Jump to

Keyboard shortcuts

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