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 ¶
- func FormatReminderDetails(event calendar.Event, notificationBefore []time.Duration) string
- func GTKAvailable() bool
- type Action
- type ActionType
- type Config
- type GTK
- func (g *GTK) Hide()
- func (g *GTK) Init() error
- func (g *GTK) OnAction(fn func(Action))
- func (g *GTK) OnHide(fn func(uid string))
- func (g *GTK) OnUnhide(fn func(uid string))
- func (g *GTK) Search()
- func (g *GTK) SetEvents(events []calendar.Event)
- func (g *GTK) SetHiddenEvents(events []calendar.Event)
- func (g *GTK) SetLoading(loading bool)
- func (g *GTK) SetStale(stale bool)
- func (g *GTK) SetSyncErrors(messages []string)
- func (g *GTK) Show()
- func (g *GTK) Toggle()
- type Popup
- func (p *Popup) Hide()
- func (p *Popup) Init()
- func (p *Popup) OnHide(fn func(uid string))
- func (p *Popup) OnJoin(fn func(url string))
- func (p *Popup) OnSync(fn func())
- func (p *Popup) OnUnhide(fn func(uid string))
- func (p *Popup) Search()
- func (p *Popup) SetEvents(events []calendar.Event)
- func (p *Popup) SetHiddenEvents(events []calendar.Event)
- func (p *Popup) SetLoading(loading bool)
- func (p *Popup) SetStale(stale bool)
- func (p *Popup) SetSyncErrors(messages []string)
- func (p *Popup) Show()
- func (p *Popup) Toggle()
- type UI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatReminderDetails ¶
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 (*GTK) SetHiddenEvents ¶
SetHiddenEvents updates the list of hidden events.
func (*GTK) SetLoading ¶
SetLoading marks the popup as actively syncing.
func (*GTK) SetSyncErrors ¶
SetSyncErrors updates the visible sync failure messages.
type 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) Init ¶
func (p *Popup) Init()
Init initializes the GTK widgets. Must be called from GTK main thread.
func (*Popup) OnSync ¶
func (p *Popup) OnSync(fn func())
OnSync sets the callback for when the user requests a manual sync.
func (*Popup) Search ¶
func (p *Popup) Search()
Search shows the popup window and focuses the search field.
func (*Popup) SetHiddenEvents ¶
SetHiddenEvents updates the list of hidden events.
func (*Popup) SetLoading ¶
SetLoading marks the popup as actively syncing.
func (*Popup) SetSyncErrors ¶
SetSyncErrors updates the visible sync failure messages.
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.