webkit

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotImplemented indicates a feature is not yet implemented
	ErrNotImplemented = errors.New("webkit: not implemented")

	// ErrWebViewNotInitialized indicates the WebView was not properly initialized
	ErrWebViewNotInitialized = errors.New("webkit: webview not initialized")

	// ErrWebViewDestroyed indicates the WebView has been destroyed
	ErrWebViewDestroyed = errors.New("webkit: webview destroyed")

	// ErrInvalidURL indicates an invalid URL was provided
	ErrInvalidURL = errors.New("webkit: invalid URL")

	// ErrMainThreadRequired indicates an operation must be called from the main thread
	ErrMainThreadRequired = errors.New("webkit: operation must be called from main thread")
)

Functions

func AddCSSProvider added in v0.9.0

func AddCSSProvider(css string) error

AddCSSProvider adds a CSS provider for styling

func ApplyFiltersToWebView added in v0.12.0

func ApplyFiltersToWebView(view *WebView, filterJSON []byte) error

ApplyFiltersToWebView applies content blocking filters to a WebView

func ApplyURISchemeHandlers added in v0.12.0

func ApplyURISchemeHandlers(view *webkit.WebView) error

ApplyURISchemeHandlers registers all pending URI schemes on the WebContext This should be called after creating the first WebView

func CleanupExpiredCertificateValidations added in v0.12.0

func CleanupExpiredCertificateValidations() error

CleanupExpiredCertificateValidations removes expired certificate validations from the database This should be called on application startup

func EvaluateJavascript added in v0.12.0

func EvaluateJavascript(view *webkit.WebView, script string)

EvaluateJavascript executes JavaScript code in the WebView in the default world This is a wrapper around webkit_web_view_evaluate_javascript that wasn't generated by gotk4

func EvaluateJavascriptInWorld added in v0.12.0

func EvaluateJavascriptInWorld(view *webkit.WebView, script string, worldName string)

EvaluateJavascriptInWorld executes JavaScript code in a specific world Pass empty string for worldName to use the main/page world

func FaviconFinishSafe added in v0.12.1

func FaviconFinishSafe(database *webkit.FaviconDatabase, result gio.AsyncResulter) (*gdk.Texture, error)

FaviconFinishSafe mirrors gotk4's FaviconFinish but guards against NULL returns.

func FinishURISchemeRequest added in v0.12.0

func FinishURISchemeRequest(req *webkit.URISchemeRequest, mimeType string, data []byte) error

FinishURISchemeRequest finishes a URI scheme request with data

func GetGlobalNetworkSession added in v0.12.0

func GetGlobalNetworkSession() *webkit.NetworkSession

GetGlobalNetworkSession returns the global network session. Returns nil if InitPersistentSession hasn't been called successfully.

func HashURL added in v0.12.1

func HashURL(pageURL string) []byte

HashURL generates an MD5 hash of a URL for filename generation

func IdleAdd added in v0.9.0

func IdleAdd(fn func() bool) uint

IdleAdd adds a function to be called in an idle callback Returns an idle source ID that can be used with IdleRemove

func IdleRemove added in v0.11.0

func IdleRemove(sourceID uint)

IdleRemove removes an idle callback by its source ID

func InitMainThread added in v0.11.0

func InitMainThread()

InitMainThread locks the current goroutine to the OS thread for GTK operations and initializes GTK. This must be called before any GTK operations.

func InitPersistentSession added in v0.12.0

func InitPersistentSession(dataDir, cacheDir string) error

InitPersistentSession creates and initializes a persistent NetworkSession with the provided data and cache directories. This should be called before creating any WebViews to ensure they use persistent storage. Returns an error if initialization fails.

IMPORTANT: Once created, this session is stored globally and will be used by all WebViews created afterward, as per WebKitGTK 6.0's design where the first created session becomes the default for the network process.

func InitWebKitLogCapture added in v0.5.0

func InitWebKitLogCapture() error

InitWebKitLogCapture initializes WebKit log capture In gotk4, WebKit logging is handled differently

func IsMainThread added in v0.11.0

func IsMainThread() bool

IsMainThread returns true if called from the GTK main thread.

func IsNativeAvailable

func IsNativeAvailable() bool

IsNativeAvailable returns true if the native GTK/WebKit libraries are available In gotk4, this is always true if the import succeeded

func JSCValueToString added in v0.12.0

func JSCValueToString(value interface{}) string

JSCValueToString converts a JSCValue from a GTK signal to a Go string

func NewBareRelatedWebView added in v0.12.0

func NewBareRelatedWebView(parentView *webkit.WebView) *webkit.WebView

NewBareRelatedWebView creates a bare gotk4 WebView with the related-view property set This ensures the popup shares the same session/process context as the parent The returned WebView is bare (no wrapper, no initialization) and must be initialized later

Since gotk4-webkitgtk's wrapWebView() is internal and cannot be accessed, we manually construct the WebView struct hierarchy using CGO.

func ParseURL added in v0.12.1

func ParseURL(rawURL string) (*url.URL, error)

ParseURL is a convenience wrapper around url.Parse

func ParseWebViewID added in v0.12.0

func ParseWebViewID(idStr string) uint64

ParseWebViewID converts a string WebView ID to uint64 Returns 0 if the string cannot be parsed

func PrefersDarkTheme added in v0.10.0

func PrefersDarkTheme() bool

PrefersDarkTheme checks if the system prefers dark theme

func PrefetchDNS added in v0.13.0

func PrefetchDNS(hostname string)

PrefetchDNS prefetches DNS for the given hostname to speed up future requests. This is useful for preloading DNS for links that the user might click. Safe to call even if the hostname is invalid or session is not initialized.

func QuitMainLoop

func QuitMainLoop()

QuitMainLoop stops the GTK main event loop.

func RegisterURIScheme added in v0.12.0

func RegisterURIScheme(scheme string, callback URISchemeRequestCallback)

RegisterURIScheme registers a custom URI scheme handler In WebKitGTK 6.0, this must be called BEFORE creating any WebViews The actual registration happens in InitPersistentSession

func RunMainLoop

func RunMainLoop()

RunMainLoop starts the GTK main event loop. This function blocks until QuitMainLoop is called.

func RunOnMainThread added in v0.12.0

func RunOnMainThread(fn func())

RunOnMainThread executes a function on the GTK main thread. If already on the main thread, executes immediately. Otherwise, schedules the function via glib.IdleAdd.

func SaveTextureAsPNG added in v0.12.1

func SaveTextureAsPNG(texture *gdk.Texture, path string, targetSize int) error

SaveTextureAsPNG saves a GdkTexture as a PNG file at target size WebKit provides GdkTexture which can be any format (ICO, PNG, JPEG, SVG) This function normalizes everything to PNG at the target size (32x32)

func ScaleTexture added in v0.12.1

func ScaleTexture(texture *gdk.Texture, targetWidth, targetHeight int) *gdk.Texture

ScaleTexture scales a texture to the target size using GdkPixbuf Uses high-quality bilinear interpolation

func SetupUserContentManager added in v0.12.0

func SetupUserContentManager(view *webkit.WebView, appearanceConfigJSON string, webviewID uint64) error

SetupUserContentManager configures UserContentManager for the WebView This injects GUI scripts at document-start and registers message handlers

func SetupWebKitDebugLogging added in v0.7.0

func SetupWebKitDebugLogging()

SetupWebKitDebugLogging enables WebKit debug logging

func StartWebKitOutputCapture added in v0.5.0

func StartWebKitOutputCapture()

StartWebKitOutputCapture starts capturing WebKit output

func StopWebKitLogCapture added in v0.5.0

func StopWebKitLogCapture()

StopWebKitLogCapture stops WebKit log capture

func TextureFromImageBytes added in v0.12.1

func TextureFromImageBytes(data []byte) (*gdk.Texture, error)

TextureFromImageBytes creates a texture from raw image bytes. Supported formats depend on the available GdkPixbuf loaders (PNG, SVG, etc.).

func WidgetAddCSSClass added in v0.9.0

func WidgetAddCSSClass(w gtk.Widgetter, className string)

WidgetAddCSSClass adds a CSS class to a widget

func WidgetAddController added in v0.12.0

func WidgetAddController(w gtk.Widgetter, controller gtk.EventControllerer)

WidgetAddController adds an event controller to a widget

func WidgetAddFocusController added in v0.11.0

func WidgetAddFocusController(w gtk.Widgetter, onEnter, onLeave func()) *gtk.EventControllerFocus

WidgetAddFocusController adds a focus event controller to a widget

func WidgetAddHoverHandler added in v0.9.0

func WidgetAddHoverHandler(w gtk.Widgetter, fn func()) *gtk.EventControllerMotion

WidgetAddHoverHandler registers a hover callback for the given widget and returns a controller that can be used to detach it later.

func WidgetAllocation added in v0.11.0

func WidgetAllocation(w gtk.Widgetter) (x, y, width, height int)

WidgetAllocation returns the widget's allocation (alias for WidgetGetAllocation)

func WidgetGetAllocation added in v0.11.0

func WidgetGetAllocation(w gtk.Widgetter) (x, y, width, height int)

WidgetGetAllocation returns the widget's allocated area

func WidgetGetBounds added in v0.9.0

func WidgetGetBounds(w gtk.Widgetter) (x, y, width, height float64)

WidgetGetBounds returns the widget's bounds relative to its parent

func WidgetGetParent added in v0.9.0

func WidgetGetParent(w gtk.Widgetter) gtk.Widgetter

WidgetGetParent returns the parent widget

func WidgetGrabFocus added in v0.9.0

func WidgetGrabFocus(w gtk.Widgetter)

WidgetGrabFocus gives focus to a widget

func WidgetHasCSSClass added in v0.11.0

func WidgetHasCSSClass(w gtk.Widgetter, className string) bool

WidgetHasCSSClass checks if a widget has a CSS class

func WidgetHide added in v0.11.0

func WidgetHide(w gtk.Widgetter)

WidgetHide makes a widget invisible

func WidgetIsValid added in v0.9.0

func WidgetIsValid(w gtk.Widgetter) bool

WidgetIsValid checks if a widget pointer is valid (non-nil)

func WidgetQueueAllocate added in v0.9.0

func WidgetQueueAllocate(w gtk.Widgetter)

WidgetQueueAllocate queues an allocate operation

func WidgetQueueDraw added in v0.11.0

func WidgetQueueDraw(w gtk.Widgetter)

WidgetQueueDraw queues a redraw operation

func WidgetQueueResize added in v0.11.0

func WidgetQueueResize(w gtk.Widgetter)

WidgetQueueResize queues a resize operation

func WidgetRealize added in v0.12.0

func WidgetRealize(w gtk.Widgetter)

WidgetRealize realizes a widget

func WidgetRealizeInContainer added in v0.9.0

func WidgetRealizeInContainer(w gtk.Widgetter, container gtk.Widgetter)

WidgetRealizeInContainer realizes a widget within a container

func WidgetRemoveCSSClass added in v0.9.0

func WidgetRemoveCSSClass(w gtk.Widgetter, className string)

WidgetRemoveCSSClass removes a CSS class from a widget

func WidgetRemoveFocusController added in v0.11.0

func WidgetRemoveFocusController(w gtk.Widgetter, controller *gtk.EventControllerFocus)

WidgetRemoveFocusController removes a focus event controller from a widget

func WidgetRemoveHoverHandler added in v0.9.0

func WidgetRemoveHoverHandler(w gtk.Widgetter, controller *gtk.EventControllerMotion)

WidgetRemoveHoverHandler removes a previously registered hover controller

func WidgetSetFocusChild added in v0.11.0

func WidgetSetFocusChild(w gtk.Widgetter, child gtk.Widgetter)

WidgetSetFocusChild sets the focus child of a widget

func WidgetSetHExpand added in v0.9.0

func WidgetSetHExpand(w gtk.Widgetter, expand bool)

WidgetSetHExpand sets whether the widget should expand horizontally

func WidgetSetMargin added in v0.11.0

func WidgetSetMargin(w gtk.Widgetter, margin int)

WidgetSetMargin sets all margins for a widget

func WidgetSetMarginBottom added in v0.11.0

func WidgetSetMarginBottom(w gtk.Widgetter, margin int)

WidgetSetMarginBottom sets the bottom margin for a widget

func WidgetSetMarginEnd added in v0.11.0

func WidgetSetMarginEnd(w gtk.Widgetter, margin int)

WidgetSetMarginEnd sets the end margin for a widget

func WidgetSetMarginStart added in v0.11.0

func WidgetSetMarginStart(w gtk.Widgetter, margin int)

WidgetSetMarginStart sets the start margin for a widget

func WidgetSetMarginTop added in v0.11.0

func WidgetSetMarginTop(w gtk.Widgetter, margin int)

WidgetSetMarginTop sets the top margin for a widget

func WidgetSetSizeRequest added in v0.11.0

func WidgetSetSizeRequest(w gtk.Widgetter, width, height int)

WidgetSetSizeRequest sets the minimum size request

func WidgetSetVExpand added in v0.9.0

func WidgetSetVExpand(w gtk.Widgetter, expand bool)

WidgetSetVExpand sets whether the widget should expand vertically

func WidgetSetVisible added in v0.11.0

func WidgetSetVisible(w gtk.Widgetter, visible bool)

WidgetSetVisible sets the visibility of a widget

func WidgetShow added in v0.9.0

func WidgetShow(w gtk.Widgetter)

WidgetShow makes a widget visible

func WidgetUnparent added in v0.9.0

func WidgetUnparent(w gtk.Widgetter)

WidgetUnparent removes a widget from its parent

Types

type Box added in v0.12.0

type Box struct {
	// contains filtered or unexported fields
}

Box wraps gtk.Box for layout management

func NewBox added in v0.11.0

func NewBox(orientation gtk.Orientation, spacing int) *Box

NewBox creates a new Box with the given orientation and spacing

func (*Box) Append added in v0.12.0

func (b *Box) Append(child gtk.Widgetter)

Append adds a child to the end of the box

func (*Box) AsWidget added in v0.12.0

func (b *Box) AsWidget() gtk.Widgetter

AsWidget returns the box as a Widgetter

func (*Box) InsertChildAfter added in v0.12.0

func (b *Box) InsertChildAfter(child, sibling gtk.Widgetter)

InsertChildAfter inserts a child after the specified sibling

func (*Box) Prepend added in v0.12.0

func (b *Box) Prepend(child gtk.Widgetter)

Prepend adds a child to the beginning of the box

func (*Box) Remove added in v0.12.0

func (b *Box) Remove(child gtk.Widgetter)

Remove removes a child from the box

type Config

type Config struct {
	// UserAgent string for the WebView
	UserAgent string

	// EnableJavaScript controls JavaScript execution
	EnableJavaScript bool

	// EnableWebGL controls WebGL support
	EnableWebGL bool

	// EnableMediaStream controls media stream support
	EnableMediaStream bool

	// HardwareAcceleration controls GPU acceleration
	HardwareAcceleration bool

	// DefaultFontSize in pixels
	DefaultFontSize int

	// MinimumFontSize in pixels
	MinimumFontSize int

	// Performance optimizations
	// EnablePageCache enables back/forward cache for instant navigation
	EnablePageCache bool

	// EnableSmoothScrolling enables smooth scrolling animations
	EnableSmoothScrolling bool

	// DataDir is the directory for persistent data (cookies, localStorage, etc.)
	DataDir string

	// CacheDir is the directory for HTTP cache
	CacheDir string

	// AppearanceConfigJSON is the JSON string for appearance configuration
	// This will be injected at document-start via UserContentManager
	AppearanceConfigJSON string

	// CreateWindow controls whether to create a standalone GTK Window for this WebView
	// Set to false for WebViews that will be embedded in workspace panes
	CreateWindow bool
}

Config holds WebView configuration

func GetDefaultConfig added in v0.12.0

func GetDefaultConfig() *Config

GetDefaultConfig returns a Config with sensible defaults

type ContentBlockingManager added in v0.12.0

type ContentBlockingManager struct {
	// contains filtered or unexported fields
}

ContentBlockingManager handles WebKit content filtering

func NewContentBlockingManager added in v0.12.0

func NewContentBlockingManager(storagePath string) (*ContentBlockingManager, error)

NewContentBlockingManager creates a new content blocking manager

func (*ContentBlockingManager) ApplyFiltersFromJSON added in v0.12.0

func (cbm *ContentBlockingManager) ApplyFiltersFromJSON(ucm *webkit.UserContentManager, identifier string, jsonRules []byte) error

ApplyFiltersFromJSON compiles and applies WebKit JSON filter rules to a UserContentManager The jsonRules parameter should be a JSON array of WebKit content blocker rules

func (*ContentBlockingManager) GetFilterStore added in v0.12.0

func (cbm *ContentBlockingManager) GetFilterStore() *webkit.UserContentFilterStore

GetFilterStore returns the underlying UserContentFilterStore

func (*ContentBlockingManager) RemoveAllFilters added in v0.12.0

func (cbm *ContentBlockingManager) RemoveAllFilters(ucm *webkit.UserContentManager)

RemoveAllFilters removes all content filters from a UserContentManager

type FaviconDatabase added in v0.12.1

type FaviconDatabase = webkit.FaviconDatabase

FaviconDatabase is an alias for WebKit's FaviconDatabase

type GdkTexture added in v0.12.1

type GdkTexture = gdk.Texture

GdkTexture is an alias for gotk4's Texture type

type Image added in v0.12.0

type Image struct {
	// contains filtered or unexported fields
}

Image wraps gtk.Image for displaying images (e.g., favicons)

func NewImage added in v0.12.0

func NewImage() *Image

NewImage creates a new empty Image

func NewImageFromFile added in v0.12.0

func NewImageFromFile(filename string) *Image

NewImageFromFile creates a new Image from a file

func (*Image) AsWidget added in v0.12.0

func (i *Image) AsWidget() gtk.Widgetter

AsWidget returns the image as a Widgetter

func (*Image) SetFromFile added in v0.12.0

func (i *Image) SetFromFile(filename string)

SetFromFile loads an image from a file

func (*Image) SetPixelSize added in v0.12.0

func (i *Image) SetPixelSize(size int)

SetPixelSize sets the pixel size for the image

type Label added in v0.12.0

type Label struct {
	// contains filtered or unexported fields
}

Label wraps gtk.Label for text display

func NewLabel added in v0.11.0

func NewLabel(text string) *Label

NewLabel creates a new Label with the given text

func (*Label) AsWidget added in v0.12.0

func (l *Label) AsWidget() gtk.Widgetter

AsWidget returns the label as a Widgetter

func (*Label) GetText added in v0.12.0

func (l *Label) GetText() string

GetText returns the current label text

func (*Label) SetEllipsize added in v0.12.0

func (l *Label) SetEllipsize(mode pango.EllipsizeMode)

SetEllipsize sets the ellipsization mode

func (*Label) SetMaxWidthChars added in v0.12.0

func (l *Label) SetMaxWidthChars(nChars int)

SetMaxWidthChars sets the maximum width in characters

func (*Label) SetText added in v0.12.0

func (l *Label) SetText(text string)

SetText updates the label text

type Paned added in v0.12.0

type Paned struct {
	// contains filtered or unexported fields
}

Paned wraps gtk.Paned for split pane layouts

func NewPaned added in v0.9.0

func NewPaned(orientation gtk.Orientation) *Paned

NewPaned creates a new Paned widget with the given orientation

func (*Paned) AsWidget added in v0.12.0

func (p *Paned) AsWidget() gtk.Widgetter

AsWidget returns the paned as a Widgetter

func (*Paned) EndChild added in v0.12.0

func (p *Paned) EndChild() gtk.Widgetter

EndChild returns the end child

func (*Paned) GetPosition added in v0.12.0

func (p *Paned) GetPosition() int

GetPosition returns the divider position

func (*Paned) SetEndChild added in v0.12.0

func (p *Paned) SetEndChild(child gtk.Widgetter)

SetEndChild sets the second child of the paned

func (*Paned) SetPosition added in v0.12.0

func (p *Paned) SetPosition(pos int)

SetPosition sets the divider position

func (*Paned) SetResizeEndChild added in v0.12.0

func (p *Paned) SetResizeEndChild(resize bool)

SetResizeEndChild sets whether the end child should resize

func (*Paned) SetResizeStartChild added in v0.12.0

func (p *Paned) SetResizeStartChild(resize bool)

SetResizeStartChild sets whether the start child should resize

func (*Paned) SetStartChild added in v0.12.0

func (p *Paned) SetStartChild(child gtk.Widgetter)

SetStartChild sets the first child of the paned

func (*Paned) StartChild added in v0.12.0

func (p *Paned) StartChild() gtk.Widgetter

StartChild returns the start child

type TLSCertificateInfo added in v0.12.0

type TLSCertificateInfo struct {
	Subject   string
	Issuer    string
	NotBefore string
	NotAfter  string
	IsExpired bool
	Errors    []string
}

TLSCertificateInfo holds information about a TLS certificate for display

type URISchemeHandler added in v0.12.0

type URISchemeHandler struct {
	// contains filtered or unexported fields
}

URISchemeHandler stores registered URI scheme handlers

type URISchemeRequestCallback added in v0.12.0

type URISchemeRequestCallback func(request *webkit.URISchemeRequest)

URISchemeRequestCallback is called when a custom URI scheme is requested

type WebView

type WebView struct {
	// contains filtered or unexported fields
}

WebView wraps a WebKitGTK WebView

func NewWebView

func NewWebView(cfg *Config) (*WebView, error)

NewWebView creates a new WebView with the given configuration

func WrapBareWebView added in v0.12.0

func WrapBareWebView(bareView *webkit.WebView) *WebView

WrapBareWebView creates a minimal WebView wrapper around a bare gotk4 WebView This is used during popup creation to return a WebView to WebKit before initialization Full initialization (container, scripts, event handlers) should be done later

func (*WebView) AsWidget added in v0.12.0

func (w *WebView) AsWidget() gtk.Widgetter

AsWidget returns the WebView as a gtk.Widgetter

func (*WebView) AttachKeyboardBridge added in v0.12.0

func (w *WebView) AttachKeyboardBridge()

TODO(#8): Refactor this function to reduce cyclomatic complexity (52 -> <30)

AttachKeyboardBridge attaches an EventControllerKey to bridge keyboard events to JavaScript This is critical for allowing JavaScript KeyboardService to receive keyboard events that would otherwise be consumed by GTK shortcuts

func (*WebView) AttachMouseGestures added in v0.12.1

func (w *WebView) AttachMouseGestures()

AttachMouseGestures attaches mouse button gesture handling to the WebView This enables hardware mouse button navigation (back/forward buttons)

func (*WebView) AttachTouchpadGestures added in v0.12.1

func (w *WebView) AttachTouchpadGestures()

AttachTouchpadGestures attaches touchpad swipe gesture handling to the WebView This enables two-finger swipe navigation (left/right for back/forward)

func (*WebView) Destroy

func (w *WebView) Destroy() error

Destroy destroys the WebView and releases resources

func (*WebView) DispatchCustomEvent added in v0.9.0

func (w *WebView) DispatchCustomEvent(eventName string, data interface{}) error

DispatchCustomEvent dispatches a custom event via JavaScript

func (*WebView) GetCurrentURL

func (w *WebView) GetCurrentURL() string

GetCurrentURL returns the current URL

func (*WebView) GetFaviconDatabase added in v0.12.1

func (w *WebView) GetFaviconDatabase() *webkit.FaviconDatabase

GetFaviconDatabase returns the WebKit FaviconDatabase for this WebView Returns nil if the favicon database is not available

func (*WebView) GetTitle added in v0.11.0

func (w *WebView) GetTitle() string

GetTitle returns the current page title

func (*WebView) GetWebView added in v0.12.0

func (w *WebView) GetWebView() *webkit.WebView

GetWebView returns the underlying webkit.WebView for advanced operations

func (*WebView) GetZoom

func (w *WebView) GetZoom() float64

GetZoom returns the current zoom level

func (*WebView) GoBack

func (w *WebView) GoBack() error

GoBack navigates back in history

func (*WebView) GoForward

func (w *WebView) GoForward() error

GoForward navigates forward in history

func (*WebView) GtkWebView added in v0.12.0

func (w *WebView) GtkWebView() *webkit.WebView

GtkWebView returns the underlying gotk4 WebView for advanced operations This is used when creating related views (popups) that need to share the same session

func (*WebView) Hide

func (w *WebView) Hide() error

Hide makes the WebView invisible

func (*WebView) ID added in v0.9.0

func (w *WebView) ID() uint64

ID returns the unique identifier for this WebView

func (*WebView) IDString added in v0.12.0

func (w *WebView) IDString() string

IDString returns the WebView ID as a string This is a convenience method for compatibility with code expecting string IDs

func (*WebView) InitializeContentBlocking added in v0.8.0

func (w *WebView) InitializeContentBlocking(filterJSON []byte) error

InitializeContentBlocking initializes content blocking with filter lists

func (*WebView) InitializeFromBare added in v0.12.0

func (w *WebView) InitializeFromBare(cfg *Config) error

InitializeFromBare completes initialization of a bare WebView wrapper This should be called in ready-to-show after WebKit has configured the view

func (*WebView) InjectScript

func (w *WebView) InjectScript(script string) error

InjectScript executes JavaScript in the WebView

func (*WebView) IsActive added in v0.9.0

func (w *WebView) IsActive() bool

IsActive returns whether this WebView is currently active/focused

func (*WebView) IsDestroyed added in v0.10.0

func (w *WebView) IsDestroyed() bool

IsDestroyed returns true if the WebView has been destroyed

func (*WebView) LoadURL

func (w *WebView) LoadURL(url string) error

LoadURL loads the given URL in the WebView

func (*WebView) OnNavigate added in v0.8.0

func (w *WebView) OnNavigate(handler func(url string))

OnNavigate registers a navigation handler

func (*WebView) OnWindowTypeDetected added in v0.9.0

func (w *WebView) OnWindowTypeDetected(handler func(WindowType, *WindowFeatures))

OnWindowTypeDetected registers a handler for window type detection

func (*WebView) RegisterCloseHandler added in v0.9.0

func (w *WebView) RegisterCloseHandler(handler func())

RegisterCloseHandler registers a handler for close requests

func (*WebView) RegisterFaviconChangedHandler added in v0.10.0

func (w *WebView) RegisterFaviconChangedHandler(handler func([]byte))

RegisterFaviconChangedHandler registers a handler for favicon changes

func (*WebView) RegisterFaviconURIChangedHandler added in v0.10.0

func (w *WebView) RegisterFaviconURIChangedHandler(handler func(pageURI, faviconURI string))

RegisterFaviconURIChangedHandler registers a handler for favicon URI changes

func (*WebView) RegisterKeyboardShortcut

func (w *WebView) RegisterKeyboardShortcut(key string, modifiers uint, handler func()) error

RegisterKeyboardShortcut registers a keyboard shortcut handler This is a compatibility method - actual shortcut handling is done at the window level

func (*WebView) RegisterNavigationPolicyHandler added in v0.11.0

func (w *WebView) RegisterNavigationPolicyHandler(handler func(url string, isUserGesture bool) bool)

RegisterNavigationPolicyHandler registers a handler for navigation policy decisions

func (*WebView) RegisterPaneModeHandler added in v0.12.0

func (w *WebView) RegisterPaneModeHandler(handler func(action string) bool, isActiveChecker func() bool)

RegisterPaneModeHandler registers a handler for pane mode shortcuts The handler receives the action ("enter", "close", "split-right", etc.) and returns true if handled

func (*WebView) RegisterPopupCreateHandler added in v0.12.0

func (w *WebView) RegisterPopupCreateHandler(handler func(*webkit.NavigationAction) *WebView)

RegisterPopupCreateHandler registers a handler for WebKit's create signal This is called when JavaScript calls window.open() or a link with target="_blank" is clicked The handler should create and return a new WebView for the popup, or return nil to block it The returned WebView should NOT be shown yet - WebKit will emit ready-to-show when it's ready

func (*WebView) RegisterReadyToShowHandler added in v0.12.0

func (w *WebView) RegisterReadyToShowHandler(handler func())

RegisterReadyToShowHandler registers a handler for WebKit's ready-to-show signal This is called when a popup WebView is ready to be displayed At this point it's safe to insert the popup into the UI (workspace, window, etc.)

func (*WebView) RegisterScriptMessageHandler

func (w *WebView) RegisterScriptMessageHandler(handler func(string))

RegisterScriptMessageHandler registers a handler for script messages

func (*WebView) RegisterTitleChangedHandler

func (w *WebView) RegisterTitleChangedHandler(handler func(string))

RegisterTitleChangedHandler registers a handler for title changes

func (*WebView) RegisterURIChangedHandler

func (w *WebView) RegisterURIChangedHandler(handler func(string))

RegisterURIChangedHandler registers a handler for URI changes

func (*WebView) RegisterWorkspaceNavigationHandler added in v0.12.0

func (w *WebView) RegisterWorkspaceNavigationHandler(handler func(direction string) bool)

RegisterWorkspaceNavigationHandler registers a handler for workspace pane navigation The handler receives the direction ("up", "down", "left", "right") and returns true if handled

func (*WebView) RegisterZoomChangedHandler added in v0.3.0

func (w *WebView) RegisterZoomChangedHandler(handler func(float64))

RegisterZoomChangedHandler registers a handler for zoom changes

func (*WebView) Reload added in v0.6.0

func (w *WebView) Reload() error

Reload reloads the current page

func (*WebView) ReloadBypassCache added in v0.6.0

func (w *WebView) ReloadBypassCache() error

ReloadBypassCache reloads the current page, bypassing cache

func (*WebView) RootWidget added in v0.9.0

func (w *WebView) RootWidget() gtk.Widgetter

RootWidget returns the root container widget for this WebView This is the GtkBox container that holds the WebView and can be reparented

func (*WebView) RunOnMainThread added in v0.9.0

func (w *WebView) RunOnMainThread(fn func())

RunOnMainThread executes a function on the GTK main thread

func (*WebView) SeedDomZoom added in v0.9.0

func (w *WebView) SeedDomZoom(zoom float64) error

SeedDomZoom is a no-op in gotk4 as we use viewport zoom

func (*WebView) SetWindowFeatures added in v0.9.0

func (w *WebView) SetWindowFeatures(features *WindowFeatures)

SetWindowFeatures sets window features for popup windows

func (*WebView) SetZoom

func (w *WebView) SetZoom(zoom float64) error

SetZoom sets the zoom level of the WebView

func (*WebView) Show

func (w *WebView) Show() error

Show makes the WebView visible

func (*WebView) ShowDevTools

func (w *WebView) ShowDevTools() error

ShowDevTools opens the WebKit inspector/developer tools

func (*WebView) ShowPrintDialog added in v0.10.0

func (w *WebView) ShowPrintDialog() error

ShowPrintDialog shows the print dialog for the current page

func (*WebView) UpdateContentFilters added in v0.8.0

func (w *WebView) UpdateContentFilters(rules string) error

UpdateContentFilters updates the content filtering rules

func (*WebView) UsesDomZoom added in v0.9.0

func (w *WebView) UsesDomZoom() bool

UsesDomZoom indicates if this WebView uses DOM-based zoom In gotk4/WebKitGTK, zoom is always viewport-based

func (*WebView) Widget added in v0.9.0

func (w *WebView) Widget() gtk.Widgetter

Widget returns the WebView widget (for compatibility with old code expecting uintptr) Deprecated: Use AsWidget() instead

func (*WebView) Window

func (w *WebView) Window() *Window

Window returns the parent Window of this WebView

type Window

type Window struct {
	// contains filtered or unexported fields
}

Window wraps a GTK Window for the browser

func NewWindow

func NewWindow(title string) (*Window, error)

NewWindow creates a new GTK window with the given title

func (*Window) AsWindow added in v0.12.0

func (w *Window) AsWindow() *gtk.Window

AsWindow returns the underlying gtk.Window for advanced operations

func (*Window) Close added in v0.12.0

func (w *Window) Close()

Close destroys the window

func (*Window) Destroy added in v0.12.0

func (w *Window) Destroy()

Destroy destroys the window

func (*Window) InitializeGlobalShortcuts added in v0.9.0

func (w *Window) InitializeGlobalShortcuts(shortcuts map[string]func())

InitializeGlobalShortcuts initializes global keyboard shortcuts for a window

func (*Window) Present added in v0.12.0

func (w *Window) Present()

Present brings the window to the front

func (*Window) SetChild added in v0.9.0

func (w *Window) SetChild(child gtk.Widgetter)

SetChild sets the child widget of the window

func (*Window) SetDefaultSize added in v0.12.0

func (w *Window) SetDefaultSize(width, height int)

SetDefaultSize sets the default window size

func (*Window) SetTitle

func (w *Window) SetTitle(title string)

SetTitle updates the window title

func (*Window) Show added in v0.12.0

func (w *Window) Show()

Show makes the window visible Note: In GTK4, Show() is deprecated. Use SetVisible(true) instead.

type WindowFeatures added in v0.9.0

type WindowFeatures struct {
	Width              int
	Height             int
	ToolbarVisible     bool
	LocationbarVisible bool
	MenubarVisible     bool
	Resizable          bool
}

WindowFeatures describes the window features detected from WebKitWindowProperties

type WindowShortcuts added in v0.9.0

type WindowShortcuts struct {
	// contains filtered or unexported fields
}

WindowShortcuts manages keyboard shortcuts for a window

func NewWindowShortcuts added in v0.12.0

func NewWindowShortcuts(win *Window) *WindowShortcuts

NewWindowShortcuts creates a new WindowShortcuts manager

func (*WindowShortcuts) RegisterShortcut added in v0.12.0

func (ws *WindowShortcuts) RegisterShortcut(accelerator string, handler func())

RegisterShortcut registers a keyboard shortcut

type WindowType added in v0.9.0

type WindowType int

WindowType indicates how a new WebView should be treated

const (
	// WindowTypeTab represents an independent WebView (future: tab)
	WindowTypeTab WindowType = iota
	// WindowTypePopup represents a related WebView (shares process/context)
	WindowTypePopup
	// WindowTypeUnknown indicates type not detected yet
	WindowTypeUnknown
)

Jump to

Keyboard shortcuts

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