godock: github.com/sqp/godock/libs/packages Index | Files | Directories

package packages

import "github.com/sqp/godock/libs/packages"

Package packages lists and acts on cairo-dock packages.

Index

Package Files

packages.go

func FormatNewVersion Uses

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 Uses

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

ListDownloadApplets builds the full list of external applets packages.

func ListDownloadDockThemes Uses

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

ListDownloadDockThemes builds the full list of dock themes packages.

func ListDownloadIndex Uses

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)

func ListThemesDir Uses

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

ListThemesDir lists themes in a given directory.

type AppInfoField Uses

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 Uses

func (field AppInfoField) Comment() string

Comment returns the config comment for the field.

func (AppInfoField) Key Uses

func (field AppInfoField) Key() string

Key returns the config file key for the field.

func (AppInfoField) Translated Uses

func (field AppInfoField) Translated() string

Translated returns the translated name for the field.

type AppletPackage Uses

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 Uses

func NewAppletPackage(log cdtype.Logger) *AppletPackage

NewAppletPackage creates an empty AppletPackage.

func NewAppletPackageUser Uses

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 Uses

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 Uses

func (pack *AppletPackage) Dir() string

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

func (*AppletPackage) FormatName Uses

func (pack *AppletPackage) FormatName() string

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

func (*AppletPackage) FormatSize Uses

func (pack *AppletPackage) FormatSize() string

FormatSize returns the human readable size for the applet.

func (*AppletPackage) FormatState Uses

func (pack *AppletPackage) FormatState() string

FormatState returns the human readable state for the applet.

func (*AppletPackage) GetAuthor Uses

func (pack *AppletPackage) GetAuthor() string

GetAuthor returns the package author.

func (*AppletPackage) GetDescription Uses

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 Uses

func (pack *AppletPackage) GetGettextDomain() string

GetGettextDomain is a stub. TODO: expand and use.

func (*AppletPackage) GetModuleVersion Uses

func (pack *AppletPackage) GetModuleVersion() string

GetModuleVersion returns the version of the package.

func (*AppletPackage) GetName Uses

func (pack *AppletPackage) GetName() string

GetName returns the package name to use as config key.

func (*AppletPackage) GetPreview Uses

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 Uses

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 Uses

func (pack *AppletPackage) GetTitle() string

GetTitle returns the package readable name.

func (*AppletPackage) IconState Uses

func (pack *AppletPackage) IconState() string

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

func (*AppletPackage) Install Uses

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 Uses

func (pack *AppletPackage) IsInstalled() bool

IsInstalled return true if the package is installed on disk.

func (*AppletPackage) SaveUpdated Uses

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

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

func (*AppletPackage) SetInstalled Uses

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

SetInstalled updates package data with info from disk after download.

func (*AppletPackage) Uninstall Uses

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

Uninstall removes an external applet from disk.

type AppletPackages Uses

type AppletPackages []*AppletPackage

AppletPackages defines a list of AppletPackage.

func ListDistant Uses

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

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

func ListDownloadSort Uses

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

ListDownloadSort sorts a list of applet packages.

func ListFromDir Uses

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

ListFromDir lists packages in external applets dir.

func (AppletPackages) Exist Uses

func (list AppletPackages) Exist(applet string) bool

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

func (AppletPackages) Get Uses

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

Get returns the package matching the name provided if found.

func (AppletPackages) Len Uses

func (list AppletPackages) Len() int

Len returns the number of packages in the list.

func (AppletPackages) Swap Uses

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

Swap exchanges the position of two packages.

type ByName Uses

type ByName struct{ AppletPackages }

ByName sorts the list of packages by name.

func (ByName) Less Uses

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

Less compares packages names for the sort.

type Gauge Uses

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

Gauge is an icon theme.

type PackageSource Uses

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 Uses

func (ps PackageSource) File() string

File returns the file name for the package source.

func (PackageSource) Group Uses

func (ps PackageSource) Group() string

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

type Theme Uses

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 (Theme) GetAuthor Uses

func (t Theme) GetAuthor() string

GetAuthor returns the package author.

func (Theme) GetDescription Uses

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 Uses

func (t Theme) GetGettextDomain() string

GetGettextDomain is a stub. TODO: expand and use.

func (Theme) GetModuleVersion Uses

func (t Theme) GetModuleVersion() string

GetModuleVersion returns the version of the package.

func (Theme) GetName Uses

func (t Theme) GetName() string

GetName returns the package name to use as config key.

func (Theme) GetPreviewFilePath Uses

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 Uses

func (t Theme) GetTitle() string

GetTitle returns the package readable name.

Directories

PathSynopsis
buildPackage build builds cairo-dock or applets from sources.
editpackPackage editpack builds a console interface to edit applets definition info.
versionsPackage versions checks and updates vcs packages.

Package packages imports 15 packages (graph) and is imported by 9 packages. Updated 2017-09-10. Refresh now. Tools for package owners.