Documentation
¶
Overview ¶
Package desktop holds the pieces of the Windows application that do not need Win32.
Index ¶
- Constants
- func AutostartEnabled() bool
- func DIBFromIcon(ico []byte) []byte
- func FormatRate(bytesPerSec int64, bits bool) string
- func FormatRateIn(bytesPerSec int64, bits, english bool) string
- func HaveSessionBus() bool
- func Icon() []byte
- func LauncherPath() (string, error)
- func MakeDefault() error
- func Notify(title, text string) error
- func PNG(n int) []byte
- func PosVisible(x, y, vx, vy, vw, vh int) bool
- func SetAutostart(on, hidden bool) error
- func ValidDensity(d string) bool
- func WatchNotificationClicks(onClick func())
- type Size
- type WindowPrefs
Constants ¶
const ( DensityLarge = "large" DensityStandard = "standard" DensityCompact = "compact" )
Variables ¶
This section is empty.
Functions ¶
func AutostartEnabled ¶ added in v1.1.1
func AutostartEnabled() bool
AutostartEnabled reports whether the program starts when the user logs in.
func DIBFromIcon ¶
DIBFromIcon returns the image data of a single-image .ico (without the ICO header), which is what CreateIconFromResourceEx expects.
func FormatRate ¶
FormatRate writes a speed given in bytes per second, either as bytes (КБ/с, МБ/с: binary prefixes, like sizes) or as bits (Кб/с, Мб/с: decimal prefixes, the way networks are measured).
func FormatRateIn ¶ added in v1.0.25
FormatRateIn is FormatRate in Russian (english false) or in English (KB/s, Mb/s).
func HaveSessionBus ¶ added in v1.1.1
func HaveSessionBus() bool
HaveSessionBus reports whether the user's session bus is there to connect to. Without one, godbus would try to start one with dbus-launch, and the tray library would fail on a connection it never got: a desktop without D-Bus, or a program started over SSH, then runs with no tray and no notifications.
func Icon ¶
func Icon() []byte
Icon returns a 32x32 .ico image: equinox, drawn as a circle split into a sunlit half and a night half, tilted by Earth's axial tilt (23.4°), with a sun and a moon set into the two halves. It is drawn in code so the executable needs no resource files.
func LauncherPath ¶ added in v1.1.1
LauncherPath is the program file that a menu entry or the autostart should start. Inside an AppImage the running file is in a mount that changes on every start, so the AppImage itself ($APPIMAGE) is taken instead.
func MakeDefault ¶ added in v1.1.1
func MakeDefault() error
MakeDefault makes the program the one that opens .torrent files and magnet links (xdg-mime, which every desktop follows). The packages bring their own menu entry; an AppImage or a program unpacked by hand gets one made for the user, with the icon, so that the system has something to point at.
func PNG ¶
PNG returns the same picture as a PNG of the given size (for the executable's resources).
func PosVisible ¶ added in v1.0.1
PosVisible reports whether a window at (x, y) would still be reachable on a screen area (the whole desktop): a monitor that was unplugged must not leave the window out of sight.
func SetAutostart ¶ added in v1.1.1
SetAutostart turns starting at login on or off; hidden starts it in the tray without opening the browser.
func ValidDensity ¶ added in v1.0.1
ValidDensity reports whether d is one of the known densities.
func WatchNotificationClicks ¶ added in v1.1.1
func WatchNotificationClicks(onClick func())
WatchNotificationClicks calls onClick when the user clicks one of this program's notifications.
Types ¶
type Size ¶ added in v1.0.1
Size is in pixels.
func DefaultSize ¶ added in v1.0.1
DefaultSize is the client size of a window that has no remembered size.
type WindowPrefs ¶ added in v1.0.1
type WindowPrefs struct {
Density string `json:"density"`
HasPos bool `json:"hasPos"`
X int `json:"x"` // outer position
Y int `json:"y"`
Max bool `json:"maximized"`
Sizes map[string]Size `json:"sizes"` // outer sizes the person has left the window at
}
WindowPrefs is what is remembered about the window.
func LoadWindowPrefs ¶ added in v1.0.1
func LoadWindowPrefs(path string) WindowPrefs
LoadWindowPrefs reads the file; a missing or broken file gives the defaults.
func (*WindowPrefs) ForgetSize ¶ added in v1.0.1
func (p *WindowPrefs) ForgetSize(d string)
ForgetSize drops the remembered size of a density, so it goes back to the default.
func (WindowPrefs) Save ¶ added in v1.0.1
func (p WindowPrefs) Save(path string) error
Save writes the file (through a temporary one, so a crash cannot leave half of it).
func (WindowPrefs) Saved ¶ added in v1.0.1
func (p WindowPrefs) Saved(d string) (Size, bool)
Saved returns the remembered outer size for a density, if there is one.
func (*WindowPrefs) SetSize ¶ added in v1.0.1
func (p *WindowPrefs) SetSize(d string, s Size)
SetSize remembers the outer size for a density.