windows

package
v0.0.0-...-75f61f4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Rendered for windows/amd64

Overview

Package windows implements the Windows Notifications.

See https://msdn.microsoft.com/en-us/library/windows/desktop/ee330740(v=vs.85).aspx for details.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGUID = errors.New("notify: invalid GUID format")
	ErrIcon = errors.New("notify: unknown icon type")
)

Functions

func NewNotifier

func NewNotifier(name string, icon *Icon) (notify.Notifier, error)

NewNotifier returns a new Notifier.

Register supports following icon types:

  • uint16
  • image.Image
  • IconType
  • *Icon

Register accepts following keys and value types:

  • windows:fallback-icon IconType This is used on Windows XP or earlier if the specified icon is *Icon.
  • windows:sound bool This is ignored on Windows 2000 or earlier.

Types

type BalloonEvent

type BalloonEvent uint

BalloonEvent represents an event of the notification balloon.

const (
	// BalloonShown represents the NIN_BALLOONSHOW message.
	BalloonShown BalloonEvent = iota

	// BalloonClosed represents the NIN_BALLOONHIDE or NIN_BALLOONTIMEOUT message.
	BalloonClosed

	// BalloonClicked represents the NIN_BALLOONUSERCLICK message.
	BalloonClicked
)

List of events for the notification balloon.

func (BalloonEvent) String

func (i BalloonEvent) String() string

type GUID

type GUID string

GUID represents a textual representation of the GUID.

The following formats are supported ("x" represents a hexadecimal digit):

  • xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  • xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  • {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

type Icon

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

Icon represents a handle of the icon.

func LoadIcon

func LoadIcon(i uint16) (icon *Icon, err error)

LoadIcon returns a new Icon from the specified icon resource.

func LoadImage

func LoadImage(img image.Image) (icon *Icon, err error)

LoadImage returns a new Icon from the specified img.

func (*Icon) Close

func (icon *Icon) Close() error

Close destroys the Icon.

type IconType

type IconType uint8

IconType represents an icon type of the Notification.

const (
	IconNone  IconType = sys.NIIF_NONE
	IconInfo  IconType = sys.NIIF_INFO
	IconWarn  IconType = sys.NIIF_WARNING
	IconError IconType = sys.NIIF_ERROR
	IconUser  IconType = sys.NIIF_USER // requires Windows XP SP2 or later
)

List of icon types for the Notification.

func (IconType) String

func (i IconType) String() string
type Menu struct {
	// contains filtered or unexported fields
}

Menu represents a context menu of the NotifyIcon.

func (m *Menu) Item(text string, id uint)

Item appends an item to the context menu.

func (m *Menu) Sep()

Sep appends a separator to the context menu.

func (m *Menu) Submenu(text string) *Menu

Submenu appends a submenu to the context menu.

type MenuEvent struct {
	ID uint16
}

MenuEvent represents an event of the context menu.

type Notification

type Notification struct {
	Title    string
	Body     string
	IconType IconType
	Icon     *Icon // requires Windows Vista or later
	Sound    bool
}

Notification represents a notification.

type NotifyIcon

type NotifyIcon struct {
	Icon    *Icon
	GUID    GUID              // requires Windows 7 or later
	Balloon chan BalloonEvent // requires Windows XP or later
	Menu    chan MenuEvent
	// contains filtered or unexported fields
}

NotifyIcon represents a notification icon in the notification area.

func New

func New(name string) (ni *NotifyIcon, err error)

New returns a new NotifyIcon.

func (*NotifyIcon) Add

func (ni *NotifyIcon) Add() error

Add adds the NotifyIcon to the notification area.

func (*NotifyIcon) Close

func (ni *NotifyIcon) Close() error

Close deletes the NotifyIcon from the notification area.

func (*NotifyIcon) CreateMenu

func (ni *NotifyIcon) CreateMenu() *Menu

CreateMenu creates a new context menu.

func (*NotifyIcon) Modify

func (ni *NotifyIcon) Modify() error

Modify modifies the NotifyIcon in the notification area.

func (*NotifyIcon) Notify

func (ni *NotifyIcon) Notify(n *Notification) error

Notify displays a notification.

type VersionError

type VersionError string

VersionError represents that it requires newer Windows version to perform the specified operation.

func (VersionError) Error

func (e VersionError) Error() string

Jump to

Keyboard shortcuts

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