appindicator

package module
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 4 Imported by: 4

README

go-appindicator

Go Report Card GoDoc Mentioned in Awesome Go

Go bindings for libappindicator3 C library.

Libappindicator is a library to allow applications to export a menu into the Unity Menu bar. Based on KSNI it also works in KDE and will fallback to generic Systray support if none of those are available.

Also it works in:

This package aims to be interoperable with Go gtk3 bindings.

3 in the name means that it's GTK3 version.

Dependencies

On Debian-based distributions:

apt install libappindicator3-dev libgtk-3-dev

And of course go with cgo is required.

Building

Refer to gotk3 wiki

...or simply run build.sh script that will try to detect currently installed version of GTK, pass along given go build flags and execute it.

For example to build one of examples:

./build.sh -v examples/simple/main.go

Examples

Examples are located in examples directory

Documentation

Index

Constants

View Source
const (
	// SignalNewIcon defines that indicator has new icon.
	SignalNewIcon = C.APP_INDICATOR_SIGNAL_NEW_ICON
	// SignalNewAttentionIcon defines that indicator has new attention icon.
	SignalNewAttentionIcon = C.APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON
	// SignalNewStatus defines that indicator has new status.
	SignalNewStatus = C.APP_INDICATOR_SIGNAL_NEW_STATUS
	// SignalNewLabel defines that indicator has new label.
	SignalNewLabel = C.APP_INDICATOR_SIGNAL_NEW_LABEL
	// SignalConnectionChanged defines that indicator's connection has changed.
	SignalConnectionChanged = C.APP_INDICATOR_SIGNAL_CONNECTION_CHANGED
	// SignalNewIconThemePath defines that indicator has new icon theme path.
	SignalNewIconThemePath = C.APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH
	// SignalScrollEvent defines that user scrolled on indicator.
	SignalScrollEvent = C.APP_INDICATOR_SIGNAL_SCROLL_EVENT
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category int

Category represents a category of indicator.

const (
	// CategoryApplicationStatus defines that indicator's category is
	// an application status.
	CategoryApplicationStatus Category = C.APP_INDICATOR_CATEGORY_APPLICATION_STATUS
	// CategoryCommunications defines that indicator's category is
	// communications.
	CategoryCommunications Category = C.APP_INDICATOR_CATEGORY_COMMUNICATIONS
	// CategorySystemServices defines that indicator's category is
	// system services.
	CategorySystemServices Category = C.APP_INDICATOR_CATEGORY_SYSTEM_SERVICES
	// CategoryHardware defines that indicator's category is
	// hardware.
	CategoryHardware Category = C.APP_INDICATOR_CATEGORY_HARDWARE
	// CategoryOther defines that indicator's category is
	// something else.
	CategoryOther Category = C.APP_INDICATOR_CATEGORY_OTHER
)

type Indicator

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

Indicator represents a single indicator object.

It holds only a pointer to C counterpart.

func New

func New(id, iconName string, category Category) *Indicator

New creates a fresh indicator.

func NewWithPath

func NewWithPath(id, iconName string, category Category, iconThemePath string) *Indicator

NewWithPath creates a fresh indicator with custom icon theme path.

func (*Indicator) BuildMenuFromDesktop

func (indicator *Indicator) BuildMenuFromDesktop(desktopFile, desktopProfile string)

BuildMenuFromDesktop builds whole menu with items from desktop file.

To be honest I don't know how it works.

func (*Indicator) GetAttentionIcon

func (indicator *Indicator) GetAttentionIcon() string

GetAttentionIcon returns current attention icon of indicator.

func (*Indicator) GetAttentionIconDesc

func (indicator *Indicator) GetAttentionIconDesc() string

GetAttentionIconDesc returns current attention icon description of indicator.

func (*Indicator) GetCategory

func (indicator *Indicator) GetCategory() Category

GetCategory returns the category of indicator specified in New() or NewWithPath().

func (*Indicator) GetIcon

func (indicator *Indicator) GetIcon() string

GetIcon returns current icon of indicator.

func (*Indicator) GetIconDesc

func (indicator *Indicator) GetIconDesc() string

GetIconDesc returns current icon description of indicator.

func (*Indicator) GetIconThemePath

func (indicator *Indicator) GetIconThemePath() string

GetIconThemePath returns current icon theme path of indicator.

func (*Indicator) GetId

func (indicator *Indicator) GetId() string

GetId returns the ID of indicator specified in New() or NewWithPath().

func (*Indicator) GetLabel

func (indicator *Indicator) GetLabel() string

GetLabel returns current label of indicator.

func (*Indicator) GetLabelGuide

func (indicator *Indicator) GetLabelGuide() string

GetLabelGuide returns current label guide of indicator.

func (*Indicator) GetMenu

func (indicator *Indicator) GetMenu() *gtk.Menu

GetMenu returns pointer to gtk.Menu.

func (*Indicator) GetOrderingIndex

func (indicator *Indicator) GetOrderingIndex() uint

GetOrderingIndex returns current ordering index of indicator.

func (*Indicator) GetSecondaryActivateTarget

func (indicator *Indicator) GetSecondaryActivateTarget() *gtk.MenuItem

GetSecondaryActivateTarget returns pointer to gtk.MenuItem which connected callback is activated when middle clicked indicator.

func (*Indicator) GetStatus

func (indicator *Indicator) GetStatus() Status

GetStatus returns current status of indicator.

func (*Indicator) GetTitle

func (indicator *Indicator) GetTitle() string

GetTitle returns current title of indicator.

func (*Indicator) Object

func (indicator *Indicator) Object() *glib.Object

Object returns a pointer to glib.Object of indicator.

Useful for connecting signals to indicator for example.

func (*Indicator) SetAttentionIcon

func (indicator *Indicator) SetAttentionIcon(iconName string)

SetAttentionIcon sets attention icon of indicator.

func (*Indicator) SetAttentionIconFull

func (indicator *Indicator) SetAttentionIconFull(iconName, iconDesc string)

SetAttentionIconFull sets attention icon of indicator with description.

func (*Indicator) SetIcon

func (indicator *Indicator) SetIcon(iconName string)

SetIcon sets icon of indicator.

func (*Indicator) SetIconFull

func (indicator *Indicator) SetIconFull(iconName, iconDesc string)

SetIconFull sets icon of indicator with description.

func (*Indicator) SetIconThemePath

func (indicator *Indicator) SetIconThemePath(iconThemePath string)

SetIconThemePath sets icon theme path of indicator.

func (*Indicator) SetLabel

func (indicator *Indicator) SetLabel(label, guide string)

SetLabel sets label of indicator.

Second parameter "guide" is used to set maximum width for label. Don't know if it works. Feel free to pass empty string.

func (*Indicator) SetMenu

func (indicator *Indicator) SetMenu(menu *gtk.Menu)

SetMenu sets gtk.Menu for indicator.

Note that this is mandatory for indicator to show and work properly.

func (*Indicator) SetOrderingIndex

func (indicator *Indicator) SetOrderingIndex(orderingIndex uint)

SetOrderingIndex sets ordering index of indicator.

It may or may not work.

func (*Indicator) SetSecondaryActivateTarget

func (indicator *Indicator) SetSecondaryActivateTarget(menuItem *gtk.MenuItem)

SetSecondaryActivateTarget sets which menu item's callback will be activated when middle clicked indicator.

func (*Indicator) SetStatus

func (indicator *Indicator) SetStatus(status Status)

SetStatus sets status of indicator.

func (*Indicator) SetTitle

func (indicator *Indicator) SetTitle(title string)

SetTitle sets title of indicator.

type Status

type Status int

Status represents status of indicator.

const (
	// StatusActive defines that indicator is active.
	StatusActive Status = C.APP_INDICATOR_STATUS_ACTIVE
	// StatusPassive defines that indicator is not active.
	StatusPassive Status = C.APP_INDICATOR_STATUS_PASSIVE
	// StatusAttention defines that indicator wants a bag of attention.
	StatusAttention Status = C.APP_INDICATOR_STATUS_ATTENTION
)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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