ui

package
v0.0.0-...-4b023fb Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package ui provides the GTK4/libadwaita popup window for calbar.

Package ui provides UI backends for calbar (GTK popup or dmenu-style launchers).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatReminderDetails

func FormatReminderDetails(event calendar.Event, notificationBefore []time.Duration) string

FormatReminderDetails returns reminder text for callers outside the ui package.

func GTKAvailable

func GTKAvailable() bool

GTKAvailable returns true if GTK is available. For puregotk builds, GTK is always "available" at the code level. If GTK libraries aren't installed, the program will panic on startup with a clear error message from puregotk about missing libraries. Use the 'nogtk' build tag to build without GTK support for systems that don't have GTK4 installed.

Types

type Action

type Action struct {
	Type ActionType
	URL  string // For ActionOpenURL
}

Action represents a user action from the UI.

type ActionType

type ActionType int

ActionType identifies the type of action.

const (
	// ActionOpenURL indicates the user wants to open a URL.
	ActionOpenURL ActionType = iota
	// ActionSync indicates the user wants to trigger a sync.
	ActionSync
)

type Config

type Config struct {
	TimeRange          time.Duration
	EventEndGrace      time.Duration // Keep events visible after they end
	HoverDismissDelay  time.Duration // Delay before dismiss on pointer-leave (0 = never auto-dismiss)
	NotificationBefore []time.Duration
	CSSFile            string
}

Config holds UI configuration.

type GTK

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

GTK wraps the Popup to implement the UI interface.

func NewGTK

func NewGTK(cfg Config) *GTK

NewGTK creates a new GTK UI backend.

func (*GTK) Hide

func (g *GTK) Hide()

Hide hides the popup.

func (*GTK) Init

func (g *GTK) Init() error

Init initializes the GTK UI.

func (*GTK) OnAction

func (g *GTK) OnAction(fn func(Action))

OnAction sets the callback for user actions.

func (*GTK) OnHide

func (g *GTK) OnHide(fn func(uid string))

OnHide sets the callback for when the user hides an event.

func (*GTK) OnUnhide

func (g *GTK) OnUnhide(fn func(uid string))

OnUnhide sets the callback for when the user unhides an event.

func (*GTK) Search

func (g *GTK) Search()

Search displays the popup and focuses search.

func (*GTK) SetEvents

func (g *GTK) SetEvents(events []calendar.Event)

SetEvents updates the event list.

func (*GTK) SetHiddenEvents

func (g *GTK) SetHiddenEvents(events []calendar.Event)

SetHiddenEvents updates the list of hidden events.

func (*GTK) SetLoading

func (g *GTK) SetLoading(loading bool)

SetLoading marks the popup as actively syncing.

func (*GTK) SetStale

func (g *GTK) SetStale(stale bool)

SetStale marks the data as potentially stale.

func (*GTK) SetSyncErrors

func (g *GTK) SetSyncErrors(messages []string)

SetSyncErrors updates the visible sync failure messages.

func (*GTK) Show

func (g *GTK) Show()

Show displays the popup.

func (*GTK) Toggle

func (g *GTK) Toggle()

Toggle shows or hides the popup.

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

Popup is the main popup window showing upcoming events.

func NewPopup

func NewPopup(timeRange, eventEndGrace, hoverDismissDelay time.Duration, notificationBefore []time.Duration, cssFile string) *Popup

NewPopup creates a new popup window.

func (*Popup) Hide

func (p *Popup) Hide()

Hide hides the popup window.

func (*Popup) Init

func (p *Popup) Init()

Init initializes the GTK widgets. Must be called from GTK main thread.

func (*Popup) OnHide

func (p *Popup) OnHide(fn func(uid string))

OnHide sets the callback for when the user hides an event.

func (*Popup) OnJoin

func (p *Popup) OnJoin(fn func(url string))

OnJoin sets the callback for when a join button is clicked.

func (*Popup) OnSync

func (p *Popup) OnSync(fn func())

OnSync sets the callback for when the user requests a manual sync.

func (*Popup) OnUnhide

func (p *Popup) OnUnhide(fn func(uid string))

OnUnhide sets the callback for when the user unhides an event.

func (*Popup) Search

func (p *Popup) Search()

Search shows the popup window and focuses the search field.

func (*Popup) SetEvents

func (p *Popup) SetEvents(events []calendar.Event)

SetEvents updates the event list.

func (*Popup) SetHiddenEvents

func (p *Popup) SetHiddenEvents(events []calendar.Event)

SetHiddenEvents updates the list of hidden events.

func (*Popup) SetLoading

func (p *Popup) SetLoading(loading bool)

SetLoading marks the popup as actively syncing.

func (*Popup) SetStale

func (p *Popup) SetStale(stale bool)

SetStale marks the data as potentially stale.

func (*Popup) SetSyncErrors

func (p *Popup) SetSyncErrors(messages []string)

SetSyncErrors updates the visible sync failure messages.

func (*Popup) Show

func (p *Popup) Show()

Show shows the popup window.

func (*Popup) Toggle

func (p *Popup) Toggle()

Toggle shows or hides the popup.

type UI

type UI interface {
	// Init initializes the UI. Must be called before other methods.
	Init() error

	// Show displays the UI with current events.
	Show()

	// Hide hides the UI.
	Hide()

	// Toggle shows or hides the UI.
	Toggle()

	// Search displays the UI and focuses search when the backend supports it.
	Search()

	// SetEvents updates the event list.
	SetEvents(events []calendar.Event)

	// SetHiddenEvents updates the list of hidden events.
	SetHiddenEvents(events []calendar.Event)

	// SetStale marks the data as potentially stale.
	SetStale(stale bool)

	// SetLoading marks the UI as actively syncing.
	SetLoading(loading bool)

	// SetSyncErrors updates the user-visible sync failure messages.
	SetSyncErrors(messages []string)

	// OnAction sets the callback for when a user performs an action.
	OnAction(fn func(Action))

	// OnHide sets the callback for when the user hides an event.
	OnHide(fn func(uid string))

	// OnUnhide sets the callback for when the user unhides an event.
	OnUnhide(fn func(uid string))
}

UI is the interface for displaying calendar events to the user.

Directories

Path Synopsis
Package menu provides a dmenu-style UI backend for calbar.
Package menu provides a dmenu-style UI backend for calbar.

Jump to

Keyboard shortcuts

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