window

package
v0.0.0-...-96c2757 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT, Unlicense Imports: 2 Imported by: 3

Documentation

Overview

Package window provides types for manipulating Gio windows within skel.

Deprecated: This package should be avoided in favor of the approach implemented by package stream.

Primarily, this package provides Windower, a type that can supervise the creation/destruction of application windows by listening for requests on the application bus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWindow

func NewWindow(conn bus.Connection, fn WindowFunc, opt ...app.Option)

NewWindow creates a new OS window with provided options and executes the window handler against it.

func NewWindowForBus

func NewWindowForBus(bus bus.Bus, fn WindowFunc, opt ...app.Option)

NewWindowForBus creates a new OS window with provided options and executes the window handler against it. This helper takes care of creating a temporary bus channel on which to send the request.

func Update

func Update(win *app.Window, event any)

Update automatically handles window-related requests by calling the appropriate functions on the provided window. It is intended for use in the event loop for a window, and should be called with each update from the application bus connection.

Types

type CreateWindowRequest

type CreateWindowRequest struct {
	Options []app.Option
	WindowFunc
}

CreateWindowRequest signals for the application to create a new window with the provided options and handler function.

type InvalidateWindowRequest

type InvalidateWindowRequest struct{}

InvalidateWindowRequest signals for any window that receives it to invalidate itself.

type WindowCloseEvent

type WindowCloseEvent struct {
	*app.Window
	Err error
}

WindowCloseEvent indicates that an application window closed and provides the error from its closing (if any).

type WindowCreateEvent

type WindowCreateEvent struct {
	*app.Window
}

WindowCreateEvent indicates that the application has started creating a new window with the given handle. From the time that this event is issued, it is guaranteed that the window will recieve all bus events, though its actual event loop may not yet be running at the time of this event.

type WindowFunc

type WindowFunc func(win *app.Window, bus bus.Connection) error

WindowFunc is a function that runs the event loop for a window using the provided window handle and bus.

Consume window events to react to user inputs and subscribe to the bus to receive events from the rest of the application.

for {
	select {
	case event := <-win.Events():
		// handle window events
	case update := <-bus.Output():
		// handle application events
		win.Invalidate()
	}
}

type Windower

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

Windower wraps a bus and handles the creation and destruction of windows via that bus.

func NewWindower

func NewWindower(bus bus.Bus) Windower

NewWindower creates and starts a Windower on the provided bus. The windower will listen on the provided connection, and will use the bus reference to create new connections for new windows.

func (Windower) Run

func (w Windower) Run()

Run processes events on the bus. This call will block until all application windows are closed.

func (Windower) Start

func (w Windower) Start()

Start invokes Run() in a new goroutine.

func (Windower) Stop

func (w Windower) Stop()

Stop shuts down the event processing of the Windower.

Jump to

Keyboard shortcuts

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