menuet

package module
v0.0.0-...-6120d33 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2019 License: MIT Imports: 20 Imported by: 0

README

Menuet

Golang library to create menubar apps- programs that live only in OSX's NSStatusBar

Development Status

Under active development. API still changing rapidly.

Changed in this fork

Example binaries are removed for reduce repository size. It means faster "go get" than original.

Installation

menuet requires OS X.

go get github.com/chikamim/menuet

Documentation

https://godoc.org/github.com/caseymrm/menuet

Usage Example

https://github.com/caseymrm/menuet

License

Menuet is licensed under the MIT license, so you are welcome to make closed source menubar apps with it as long as you preserve the copyright. For details see the LICENSE file.

Documentation

Index

Constants

View Source
const (
	// WeightUltraLight is equivalent to NSFontWeightUltraLight
	WeightUltraLight FontWeight = -0.8
	// WeightThin is equivalent to NSFontWeightThin
	WeightThin = -0.6
	// WeightLight is equivalent to NSFontWeightLight
	WeightLight = -0.4
	// WeightRegular is equivalent to NSFontWeightRegular, and is the default
	WeightRegular = 0
	// WeightMedium is equivalent to NSFontWeightMedium
	WeightMedium = 0.23
	// WeightSemibold is equivalent to NSFontWeightSemibold
	WeightSemibold = 0.3
	// WeightBold is equivalent to NSFontWeightBold
	WeightBold = 0.4
	// WeightHeavy is equivalent to NSFontWeightHeavy
	WeightHeavy = 0.56
	// WeightBlack is equivalent to NSFontWeightBlack
	WeightBlack = 0.62
)
View Source
const (
	// Regular is a normal item with text and optional callback
	Regular ItemType = ""
	// Separator is a horizontal line
	Separator = "separator"
	// Root is the top level menu directly off the menubar
	Root = "root"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	MessageText     string
	InformativeText string
	Buttons         []string
	Inputs          []string
}

Alert represents an NSAlert

type AlertClicked

type AlertClicked struct {
	Button int
	Inputs []string
}

AlertClicked represents a selected alert button

type Application

type Application struct {
	Name  string
	Label string

	// Children returns the top level children
	Children func() []MenuItem

	// If Version and Repo are set, checks for updates every day
	AutoUpdate struct {
		Version string
		Repo    string // For example "caseymrm/menuet"
	}

	// NotificationResponder is a handler called when notification respond
	NotificationResponder func(id, response string)
	// contains filtered or unexported fields
}

Application represents the OSX application

func App

func App() *Application

App returns the application singleton

func (*Application) Alert

func (a *Application) Alert(alert Alert) AlertClicked

Alert shows an alert, and returns the index of the button pressed, or -1 if none

func (*Application) MenuChanged

func (a *Application) MenuChanged()

MenuChanged refreshes any open menus

func (*Application) Notification

func (a *Application) Notification(notification Notification)

Notification shows a notification to the user. Note that you have to be part of a proper application bundle for them to show up.

func (*Application) RunApplication

func (a *Application) RunApplication()

RunApplication does not return

func (*Application) SetMenuState

func (a *Application) SetMenuState(state *MenuState)

SetMenuState changes what is shown in the dropdown

type FontWeight

type FontWeight float64

FontWeight represents the weight of the font

type ItemType

type ItemType string

ItemType represents what type of menu item this is

type MenuItem struct {
	Type ItemType

	Text       string
	Image      string // In Resources dir or URL, should have height 16
	FontSize   int    // Default: 14
	FontWeight FontWeight
	State      bool // shows checkmark when set

	Clicked  func()            `json:"-"`
	Children func() []MenuItem `json:"-"`
}

MenuItem represents one item in the dropdown

type MenuState struct {
	Title string
	Image string // // In Resources dir or URL, should have height 22
}

MenuState represents the title and drop down,

type Notification

type Notification struct {
	// The basic text of the notification
	Title    string
	Subtitle string
	Message  string

	// These add an optional action button, change what the close button says, and adds an in-line reply
	ActionButton        string
	CloseButton         string
	ResponsePlaceholder string

	// Duplicate identifiers do not re-display, but instead update the notification center
	Identifier string

	// If true, the notification is shown, but then deleted from the notification center
	RemoveFromNotificationCenter bool
}

Notification represents an NSUserNotification

type UserDefaults

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

UserDefaults represents values stored in NSUserDefaults

func Defaults

func Defaults() *UserDefaults

Defaults returns the userDefaults singleton

func (*UserDefaults) Boolean

func (u *UserDefaults) Boolean(key string) bool

Boolean gets a boolean default, 0 if not set

func (*UserDefaults) Integer

func (u *UserDefaults) Integer(key string) int

Integer gets an integer default, 0 if not set

func (*UserDefaults) Marshal

func (u *UserDefaults) Marshal(key string, v interface{}) error

Marshal marshals an object into JSON and stores it in user defaults, see json.Marshal docs

func (*UserDefaults) SetBoolean

func (u *UserDefaults) SetBoolean(key string, value bool)

SetBoolean sets a boolean default

func (*UserDefaults) SetInteger

func (u *UserDefaults) SetInteger(key string, value int)

SetInteger sets an integer default

func (*UserDefaults) SetString

func (u *UserDefaults) SetString(key, value string)

SetString sets a string default

func (*UserDefaults) String

func (u *UserDefaults) String(key string) string

String gets a string default, "" if not set

func (*UserDefaults) Unmarshal

func (u *UserDefaults) Unmarshal(key string, v interface{}) error

Unmarshal unmarshals an object from JSON that was stored in user defaults, see json.Unmarshal docs

Jump to

Keyboard shortcuts

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