adapter

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package adapter provides UI-layer adapters that bridge domain services to GTK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FaviconAdapter

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

FaviconAdapter bridges the domain FaviconService to GTK by providing gdk.Texture conversion and WebKit FaviconDatabase integration.

func NewFaviconAdapter

func NewFaviconAdapter(service port.FaviconService, faviconDB port.FaviconDatabase, cfg FaviconAdapterConfig) *FaviconAdapter

NewFaviconAdapter creates a new FaviconAdapter. The faviconDB can be nil if a favicon database is not available.

func (*FaviconAdapter) Clear

func (a *FaviconAdapter) Clear()

Clear removes all entries from the texture cache.

func (*FaviconAdapter) Close

func (a *FaviconAdapter) Close()

Close shuts down the adapter and underlying service.

func (*FaviconAdapter) GetOrFetch

func (a *FaviconAdapter) GetOrFetch(ctx context.Context, pageURL string, callback func(*gdk.Texture))

GetOrFetch retrieves a favicon texture, checking caches and fetching if needed. The callback is invoked on the GTK main thread with the texture (or nil). For internal dumb:// URLs, returns the app logo texture.

func (*FaviconAdapter) GetTexture

func (a *FaviconAdapter) GetTexture(domain string) *gdk.Texture

GetTexture returns a cached texture for the domain, or nil if not cached.

func (*FaviconAdapter) GetTextureByURL

func (a *FaviconAdapter) GetTextureByURL(pageURL string) *gdk.Texture

GetTextureByURL returns a cached texture by extracting domain from URL. For internal dumb:// URLs, returns the app logo texture.

func (*FaviconAdapter) PreloadFromCache

func (a *FaviconAdapter) PreloadFromCache(pageURL string) *gdk.Texture

PreloadFromCache attempts to load a favicon from cache without fetching. Returns the texture if found in memory or disk cache, nil otherwise.

func (*FaviconAdapter) Service

func (a *FaviconAdapter) Service() port.FaviconService

Service returns the underlying favicon service. Used by CLI components that need disk paths.

func (*FaviconAdapter) Size

func (a *FaviconAdapter) Size() int

Size returns the number of entries in the texture cache.

func (*FaviconAdapter) StoreFromWebKit

func (a *FaviconAdapter) StoreFromWebKit(ctx context.Context, pageURL string, texture *gdk.Texture)

StoreFromWebKit stores a favicon texture received from WebKit signals. Also ensures the favicon is persisted to disk cache via the service.

func (*FaviconAdapter) StoreFromWebKitWithOrigin

func (a *FaviconAdapter) StoreFromWebKitWithOrigin(
	ctx context.Context, currentURL, originURL string, texture *gdk.Texture,
)

StoreFromWebKitWithOrigin stores a favicon for both current URL and original URL. Used when redirects occur (e.g., example.com → www.example.com).

type FaviconAdapterConfig added in v0.28.0

type FaviconAdapterConfig struct {
	// IsInternalURL reports whether a URL uses the internal app scheme (e.g. dumb://).
	IsInternalURL func(url string) bool
	// InternalDomain is the pseudo-domain used to cache the app logo favicon.
	InternalDomain string
	// NormalizedIconSize is the target size for dmenu/fuzzel icons (0 = skip).
	NormalizedIconSize int
	// GetLogoBytes returns the raw bytes of the app logo (nil = skip logo favicon).
	GetLogoBytes func() []byte
}

FaviconAdapterConfig holds optional configuration for FaviconAdapter. Zero values disable the corresponding features (internal-URL logo, sized-PNG creation).

Jump to

Keyboard shortcuts

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