linux

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 56 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package linux is NSGo's GTK 4 backend, on NSH's Linux design: every view is a widget of its own (NsgoView, a GtkWidget subclass) that its parent places at the core's frame and that draws itself with GtkSnapshot and Cairo, text the engine measured and laid out with Pango included. Inputs, web views, videos and the app's native components are native GtkEntry, WebKitWebView, GtkPicture and app widgets hosted in their view's widget, so they stack, clip, fade and transform with the views around them. GTK delivers the pointer, wheel and keyboard events and file drops to the surface; the backend hit tests them and the engine keeps the interaction state. Transitions, animated values, layout animations and animated images run on one frame clock that ticks only while something animates.

The backend is the one the roadmap asks for: GTK 4 through purego, no cgo and no hand-written C. It loads its libraries at run time, so an app built on macOS needs only Go and Xcode, and an app built for Linux needs GTK 4.14 or newer, Pango and Cairo where it runs. Web views also need WebKitGTK 6.0, which loads on the first one; without it a web view shows a placeholder, as NSH's does. Videos play through GTK's GStreamer media backend.

The application menu is a GTK menu bar above the surface. The backend does not select text, expose accessibility, draw window controls of its own or animate modals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstalledBy

func InstalledBy() string

InstalledBy names the sandbox whose store installed the app and updates it, Flatpak or Snap, as they mark their apps' environments; "" for any other install, a package manager's included, which nsgo.yaml's updates.channel tells apart.

func Run

func Run(app engine.App, opts Options)

Run opens a window showing app and runs GTK's main loop. Call it from main; it returns when the window closes.

Types

type Options

type Options struct {
	Title         string
	Width, Height driver.Points
	// Hidden keeps the backend's root window out of the screen while it
	// hosts app-level services such as tray icons.
	Hidden bool
	// ID names the app's directories and storage (engine.AppDirs).
	ID string
	// Name is the app's name, nsgo.yaml's (core.App().Name), "" where the tool set none; unlike Title, a surface's windows keep it.
	Name string
	// InstanceKey scopes the single-instance lock; empty keeps one lock per ID.
	InstanceKey string
	// Components are the native components Native elements name.
	Components driver.NativeComponents
	// Fonts are font files under the app's resources, registered before
	// the first view.
	Fonts []string
	// Appearance is the appearance the app starts in.
	Appearance driver.Appearance
	// Constraints limit the window (nsgo.WindowConstraints).
	Constraints driver.WindowConstraints
	// Transparent opens the window undecorated and clear wherever the app draws nothing, NoShadow without the shadow GTK draws, and SkipTaskbar off the X11 task list (look.go).
	Transparent, NoShadow, SkipTaskbar bool
	// Perf shows the performance monitor over the app (perf.go).
	Perf bool
	// Updates is how the app updates (updates.go).
	Updates updates.Config
	// LaunchedAtLogin says the login item started this process.
	LaunchedAtLogin bool
	// Host is what an embedding host gives the view (NewView).
	Host engine.HostOptions
	// contains filtered or unexported fields
}

Options configure the window.

type View

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

View is an app in a GtkWidget of an embedding host's window, which the host's own main loop runs (NewView).

func NewView

func NewView(app engine.App, opts Options) (*View, error)

NewView makes a GtkWidget showing app, for a host that has initialized GTK and runs its main loop itself. Its engine starts once GTK first allocates the widget, so settings made before that are in the app's first frame. Call it on GTK's thread; several views may show at once. It leaves the program name, which docks match the host's windows by, to the host.

func (*View) Close

func (v *View) Close()

Close stops the app, destroys its native components and lets the widget go, which the host removes from its parent.

func (*View) Handle

func (v *View) Handle() uintptr

Handle returns the GtkWidget, which the host adds to its widgets.

func (*View) SetHostEnvironment

func (v *View) SetHostEnvironment(env engine.HostEnvironment)

SetHostEnvironment sets what the host sets over the session's environment: its locale, text size and appearance.

func (*View) SetTokens

func (v *View) SetTokens(t engine.Tokens)

SetTokens sets the values the host themes the app with.

Jump to

Keyboard shortcuts

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