platform

package
v1.0.31-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 10 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 platform holds what giode's platform packages share: the errors the root package re-exports. Each feature's per-platform code lives in a package under it (internal/platform/sound, .../tray...), and the root package keeps the public API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotSupported is giode.ErrNotSupported.
	ErrNotSupported = host.ErrNotSupported
	// ErrCanceled is giode.ErrCanceled.
	ErrCanceled = errors.New("giode: canceled by the user")
	// ErrDeclined is giode.ErrDeclined.
	ErrDeclined = errors.New("giode: the user declined")
	// ErrNotificationsOff is giode.ErrNotificationsOff.
	ErrNotificationsOff = errors.New("giode: notifications are turned off for this app")
	// ErrNotFound is giode.ErrNotFound.
	ErrNotFound = errors.New("giode: not found")
)
View Source
var KnownTypes = map[string]string{
	".md":       "text/markdown; charset=utf-8",
	".markdown": "text/markdown; charset=utf-8",
	".txt":      "text/plain; charset=utf-8",
	".csv":      "text/csv; charset=utf-8",
	".heic":     "image/heic",
	".heif":     "image/heif",
	".mp3":      "audio/mpeg",
	".wav":      "audio/wav",
	".m4a":      "audio/mp4",
	".ogg":      "audio/ogg",
	".flac":     "audio/flac",
	".mp4":      "video/mp4",
	".mov":      "video/quicktime",
	".zip":      "application/zip",
	".docx":     "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
	".xlsx":     "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
	".pptx":     "application/vnd.openxmlformats-officedocument.presentationml.presentation",
}

KnownTypes covers common files Go's built-in MIME table lacks; the system table that fills the gap on Linux isn't there on Windows or the phones.

Functions

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies src to a new file dst.

func MIMEType

func MIMEType(ext string) string

MIMEType returns the MIME type for a file extension, or "".

func NotLinked

func NotLinked(pkg string) error

NotLinked is the error of a feature whose opt-in package (see internal/optin) the app doesn't import.

func OnAndroidMain

func OnAndroidMain(ctx context.Context, h Host, fn func(view uintptr) error) error

OnAndroidMain runs fn with the GioView on the Android main thread and waits for it, or for ctx.

func OnMainThread

func OnMainThread() bool

OnMainThread reports false: only Apple platforms need the hops.

func PortalParent

func PortalParent(h Host) string

PortalParent is the window the XDG desktop portal's dialogs belong to: "x11:<id>" for an X11 window, "" otherwise (or without a host).

func SanitizeFileName

func SanitizeFileName(s string) string

SanitizeFileName replaces the characters file systems reject.

func UniquePath

func UniquePath(path string) string

UniquePath adds " (2)", " (3)" ... before the extension until path is free.

Types

type Host

type Host interface {
	// NativeHandle is the window's native handle (giode.App.NativeHandle):
	// an HWND, an NSView, a GioView..., or 0 before the window exists.
	NativeHandle() uintptr
	// NativeView is the window's view event (giode.App.NativeView), or
	// nil.
	NativeView() app.ViewEvent
	// Window is the app's Gio window.
	Window() *app.Window
	// Post runs f on the UI goroutine.
	Post(f func())
	// RunOnWindow runs f on the window's own thread (Gio's Window.Run)
	// and waits for it.
	RunOnWindow(f func())
	// Logf logs through the app's Logger.
	Logf(level Level, format string, args ...any)
	// Title is the app's title.
	Title() string
}

Host is what platform code needs of the app: its window and its UI goroutine. The root package implements it for giode.App.

type Level

type Level int

Level is a log message's level, as giode.LogLevel.

const (
	Debug Level = iota
	Info
	Warning
	Error
)

Directories

Path Synopsis
Package a11y exposes the UI's semantic tree to the platform's accessibility services: UI Automation, AT-SPI, NSAccessibility and UIAccessibility, and Android's AccessibilityNodeProvider.
Package a11y exposes the UI's semantic tree to the platform's accessibility services: UI Automation, AT-SPI, NSAccessibility and UIAccessibility, and Android's AccessibilityNodeProvider.
Package clipimage reads images from the system clipboard.
Package clipimage reads images from the system clipboard.
Package ctxmenu installs the app's actions in file managers' context menus: Explorer, Finder's Services, Nautilus, Dolphin, Caja and Nemo.
Package ctxmenu installs the app's actions in file managers' context menus: Explorer, Finder's Services, Nautilus, Dolphin, Caja and Nemo.
Package dirs finds the user's folders: Downloads, Pictures.
Package dirs finds the user's folders: Downloads, Pictures.
Package filedrag carries file drags between the app's window and the system: files dragged in from the file manager, and Draggable.Export dragging out.
Package filedrag carries file drags between the app's window and the system: files dragged in from the file manager, and Draggable.Export dragging out.
Package giopatch connects giode to the Gio patches the giode CLI builds with (the giode_gio* build tags): the window's first color, the keyboard's return key, AutoFill hints.
Package giopatch connects giode to the Gio patches the giode CLI builds with (the giode_gio* build tags): the window's first color, the keyboard's return key, AutoFill hints.
Package gl finds OpenGL functions and reads framebuffers, for Config.Underlay.
Package gl finds OpenGL functions and reads framebuffers, for Config.Underlay.
Package lifecycle reports the app going to the background and coming back, where the system rather than the window says so.
Package lifecycle reports the app going to the background and coming back, where the system rather than the window says so.
Package login registers the app to start when the user signs in.
Package login registers the app to start when the user signs in.
Package menubar installs the macOS menu bar.
Package menubar installs the macOS menu bar.
Package notify shows simple notifications.
Package notify shows simple notifications.
Package picker shows the system's pickers: files, folders, photos and media.
Package picker shows the system's pickers: files, folders, photos and media.
Package power reports the computer going to sleep and waking.
Package power reports the computer going to sleep and waking.
Package prefs reads the user's system preferences: dark mode, reduced motion, contrast, bold text and text size.
Package prefs reads the user's system preferences: dark mode, reduced motion, contrast, bold text and text size.
Package sandbox has what the macOS App Sandbox needs: the APIs it allows for opening files and URLs and for login items, and bookmarks keeping access to folders the user chose.
Package sandbox has what the macOS App Sandbox needs: the APIs it allows for opening files and URLs and for login items, and bookmarks keeping access to folders the user chose.
Package sharetarget receives what other apps share with this one.
Package sharetarget receives what other apps share with this one.
Package shell opens files, folders and URLs in the system's apps.
Package shell opens files, folders and URLs in the system's apps.
Package signin runs the platform's sign-in sheets and passkey prompts.
Package signin runs the platform's sign-in sheets and passkey prompts.
Package sound plays short WAV sounds on each platform, for giode.App.PlaySound.
Package sound plays short WAV sounds on each platform, for giode.App.PlaySound.
Package speech transcribes the microphone with the platform's speech recognizer.
Package speech transcribes the microphone with the platform's speech recognizer.
Package systray shows the app's icon and menu in the system tray (the notification area, the macOS menu bar, a StatusNotifierItem).
Package systray shows the app's icon and menu in the system tray (the notification area, the macOS menu bar, a StatusNotifierItem).
Package window places the app's window and sets its native chrome: position and screen, always on top, transparency and title bar buttons.
Package window places the app's window and sets its native chrome: position and screen, always on top, transparency and title bar buttons.

Jump to

Keyboard shortcuts

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