packages

package
v0.0.0-...-0caaa62 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2017 License: GPL-3.0-or-later Imports: 15 Imported by: 0

Documentation

Overview

Package packages lists and acts on cairo-dock packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatNewVersion

func FormatNewVersion(str string, delta int) (string, error)

FormatNewVersion formats an upgraded X.Y.Z version string.

Value for delta:

1: increase micro  X.Y.Z+1
2: increase minor  X.Y+1.0
3: increase major  X+1.0.0

func ListDownloadApplets

func ListDownloadApplets(log cdtype.Logger, externalUserDir string) (map[string]*AppletPackage, error)

ListDownloadApplets builds the full list of external applets packages.

func ListDownloadDockThemes

func ListDownloadDockThemes(log cdtype.Logger, themeDir string) (map[string]*AppletPackage, error)

ListDownloadDockThemes builds the full list of dock themes packages.

func ListDownloadIndex

func ListDownloadIndex(log cdtype.Logger, srvTag, externalUserDir string, source PackageSource) (map[string]*AppletPackage, error)

ListDownloadIndex builds a merged list of external packages in local and distant sources with downloadable state, indexed by applet name. In case of multiple errors, the last one is returned. (local access errors are more important than network errors)

Types

type AppInfoField

type AppInfoField int

AppInfoField defines edit applet info fields.

const (
	AppInfoUnknown       AppInfoField = iota // empty (or unused).
	AppInfoVersion                           // string
	AppInfoCategory                          // int
	AppInfoAuthor                            // string
	AppInfoDescription                       // string
	AppInfoActAsLauncher                     // bool
	AppInfoMultiInstance                     // bool
	AppInfoTitle                             // string
	AppInfoIcon                              // string
)

Applet info fields.

func (AppInfoField) Comment

func (field AppInfoField) Comment() string

Comment returns the config comment for the field.

func (AppInfoField) Key

func (field AppInfoField) Key() string

Key returns the config file key for the field.

func (AppInfoField) Translated

func (field AppInfoField) Translated() string

Translated returns the translated name for the field.

type AppletPackage

type AppletPackage struct {
	DisplayedName string             // name of the package
	Type          cdtype.PackageType // type of package : installed, user, distant...
	Path          string             // complete path of the package.
	LastModifDate string             `conf:"last modif"` // date of latest changes in the package.
	SrvTag        string             // webserver version tag to download.
	Source        PackageSource      // applet or theme.

	Author          string              `conf:"author"` // author(s)
	Description     string              `conf:"description"`
	Category        cdtype.CategoryType `conf:"category"`
	Title           string              `conf:"title"` // From file: alt applet name to use. From DBus: also translated.
	Icon            string              `conf:"icon"`  // From file: alt icon name to use.   From DBus: with full path?.
	Version         string              `conf:"version"`
	ActAsLauncher   bool                `conf:"act as launcher"`
	IsMultiInstance bool                `conf:"multi-instance"`

	// On server only.
	CreationDate int     `conf:"creation"` // date of creation of the package.
	Size         float64 `conf:"size"`     // size in Mo

	// From Dbus only
	Preview    string
	Instances  []string
	ModuleType int
	// contains filtered or unexported fields
}

AppletPackage defines a generic cairo-dock applet package.

func NewAppletPackage

func NewAppletPackage(log cdtype.Logger) *AppletPackage

NewAppletPackage creates an empty AppletPackage.

func NewAppletPackageUser

func NewAppletPackageUser(log cdtype.Logger, dir, name string, typ cdtype.PackageType, source PackageSource) (*AppletPackage, error)

NewAppletPackageUser try to read an external applet package info from dir.

func ReadPackageFile

func ReadPackageFile(log cdtype.Logger, dir, applet string, source PackageSource) (*AppletPackage, error)

ReadPackageFile loads a package from its config file on disk.

func (*AppletPackage) Dir

func (pack *AppletPackage) Dir() string

Dir gives the location of the package on disk. TODO: confirm same dir as the applet.

func (*AppletPackage) FormatName

func (pack *AppletPackage) FormatName() string

FormatName returns the best available package name to display. (translated if possible).

func (*AppletPackage) FormatSize

func (pack *AppletPackage) FormatSize() string

FormatSize returns the human readable size for the applet.

func (*AppletPackage) FormatState

func (pack *AppletPackage) FormatState() string

FormatState returns the human readable state for the applet.

func (*AppletPackage) GetAuthor

func (pack *AppletPackage) GetAuthor() string

GetAuthor returns the package author.

func (*AppletPackage) GetDescription

func (pack *AppletPackage) GetDescription() string

GetDescription returns the package description text. Can be slow if it needs to download the file (non installed package).

func (*AppletPackage) GetGettextDomain

func (pack *AppletPackage) GetGettextDomain() string

GetGettextDomain is a stub. TODO: expand and use.

func (*AppletPackage) GetModuleVersion

func (pack *AppletPackage) GetModuleVersion() string

GetModuleVersion returns the version of the package.

func (*AppletPackage) GetName

func (pack *AppletPackage) GetName() string

GetName returns the package name to use as config key.

func (*AppletPackage) GetPreview

func (pack *AppletPackage) GetPreview(tmp string) (string, bool)

GetPreview returns the location of the applet preview on disk. The preview will be downloaded from the server for non installed applets. If a temp file location is provided, it will be used, otherwise, the Returned values are the file location and the boolean indicates if a temp file was used and need to be removed when no more useful.

func (*AppletPackage) GetPreviewFilePath

func (pack *AppletPackage) GetPreviewFilePath() string

GetPreviewFilePath returns the location of the preview file. Can be slow if it needs to download the file (non installed package).

func (*AppletPackage) GetTitle

func (pack *AppletPackage) GetTitle() string

GetTitle returns the package readable name.

func (*AppletPackage) IconState

func (pack *AppletPackage) IconState() string

IconState returns the icon location for the state for the applet.

func (*AppletPackage) Install

func (pack *AppletPackage) Install(externalUserDir string) error

Install downloads and extract an external archive to package dir. Optional tar settings can be passed.

func (*AppletPackage) IsInstalled

func (pack *AppletPackage) IsInstalled() bool

IsInstalled return true if the package is installed on disk.

func (*AppletPackage) SaveUpdated

func (pack *AppletPackage) SaveUpdated(edits map[AppInfoField]interface{}) (*AppletPackage, error)

SaveUpdated updates the package, then saves and returns a reloaded package.

func (*AppletPackage) SetInstalled

func (pack *AppletPackage) SetInstalled(externalUserDir string) error

SetInstalled updates package data with info from disk after download.

func (*AppletPackage) Uninstall

func (pack *AppletPackage) Uninstall(externalUserDir string) error

Uninstall removes an external applet from disk.

type AppletPackages

type AppletPackages []*AppletPackage

AppletPackages defines a list of AppletPackage.

func ListDistant

func ListDistant(log cdtype.Logger, version string) (AppletPackages, error)

ListDistant lists packages available on the server applets market for given version.

func ListDownloadSort

func ListDownloadSort(list map[string]*AppletPackage) (sorted AppletPackages)

ListDownloadSort sorts a list of applet packages.

func ListFromDir

func ListFromDir(log cdtype.Logger, dir string, typ cdtype.PackageType, source PackageSource) (AppletPackages, error)

ListFromDir lists packages in external applets dir.

func (AppletPackages) Exist

func (list AppletPackages) Exist(applet string) bool

Exist returns true if the package was found in the list.

func (AppletPackages) Get

func (list AppletPackages) Get(applet string) *AppletPackage

Get returns the package matching the name provided if found.

func (AppletPackages) Len

func (list AppletPackages) Len() int

Len returns the number of packages in the list.

func (AppletPackages) Swap

func (list AppletPackages) Swap(i, j int)

Swap exchanges the position of two packages.

type ByName

type ByName struct{ AppletPackages }

ByName sorts the list of packages by name.

func (ByName) Less

func (list ByName) Less(i, j int) bool

Less compares packages names for the sort.

type Gauge

type Gauge struct {
	XMLName xml.Name `xml:"gauge"`
	Theme
}

Gauge is an icon theme.

type PackageSource

type PackageSource int

PackageSource defines whether the loaded package is an applet or a theme.

const (
	SourceApplet PackageSource = iota
	SourceTheme
	SourceDockTheme
)

Source of package to load (applet or theme).

func (PackageSource) File

func (ps PackageSource) File() string

File returns the file name for the package source.

func (PackageSource) Group

func (ps PackageSource) Group() string

Group returns the group name to parse for the package source.

type Theme

type Theme struct {
	// Name    string      `xml:"name"`   // name of the package
	DirName string             // really = directory name (used as key).
	Title   string             `xml:"name"`
	Author  string             `xml:"author"` // author(s)
	Version string             `xml:"version"`
	Type    cdtype.PackageType // type of package : installed, user, distant...
	// contains filtered or unexported fields
}

Theme represents an icon theme (gauge, clock...).

func ListThemesDir

func ListThemesDir(log cdtype.Logger, dir string, typ cdtype.PackageType) ([]Theme, error)

ListThemesDir lists themes in a given directory.

func (Theme) GetAuthor

func (t Theme) GetAuthor() string

GetAuthor returns the package author.

func (Theme) GetDescription

func (t Theme) GetDescription() string

GetDescription returns the package description text. Can be slow if it needs to download the file (non installed package).

func (Theme) GetGettextDomain

func (t Theme) GetGettextDomain() string

GetGettextDomain is a stub. TODO: expand and use.

func (Theme) GetModuleVersion

func (t Theme) GetModuleVersion() string

GetModuleVersion returns the version of the package.

func (Theme) GetName

func (t Theme) GetName() string

GetName returns the package name to use as config key.

func (Theme) GetPreviewFilePath

func (t Theme) GetPreviewFilePath() string

GetPreviewFilePath returns the location of the preview file. Can be slow if it needs to download the file (non installed package).

func (Theme) GetTitle

func (t Theme) GetTitle() string

GetTitle returns the package readable name.

Directories

Path Synopsis
Package build builds cairo-dock or applets from sources.
Package build builds cairo-dock or applets from sources.
Package editpack builds a console interface to edit applets definition info.
Package editpack builds a console interface to edit applets definition info.
Package versions checks and updates vcs packages.
Package versions checks and updates vcs packages.

Jump to

Keyboard shortcuts

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