database

package
v0.0.0-...-3f99431 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package database provides launchpad database functions

Index

Constants

View Source
const (
	RootType
	FolderRootType
	PageType
	ApplicationType
	DownloadingAppType
	WidgetType
)

Types

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID         int    `gorm:"column:item_id;primary_key"`
	Title      string `gorm:"column:title"`
	BundleID   string `gorm:"column:bundleid"`
	StoreID    string `gorm:"column:storeid;default:null"`
	CategoryID int    `gorm:"column:category_id;default:null"`
	Category   Category
	Moddate    float64 `gorm:"column:moddate"`
	Bookmark   []byte  `gorm:"column:bookmark"`
}

App CREATE TABLE apps (item_id INTEGER PRIMARY KEY, title VARCHAR, bundleid VARCHAR, storeid VARCHAR,category_id INTEGER, moddate REAL, bookmark BLOB)

type AppFolder

type AppFolder struct {
	Name  string       `yaml:"folder" json:"folder,omitempty" mapstructure:"folder"`
	Pages []FolderPage `yaml:"pages,omitempty" json:"pages,omitempty"`
}

AppFolder is a launchpad folder object

type Apps

type Apps struct {
	Pages []Page `yaml:"pages" json:"pages,omitempty"`
}

Apps is the launchpad apps config object

type Category

type Category struct {
	ID  uint   `gorm:"column:rowid;primary_key"`
	UTI string `gorm:"column:uti"`
}

Category CREATE TABLE categories (rowid INTEGER PRIMARY KEY ASC, uti VARCHAR)

type Config

type Config struct {
	Apps    Apps    `yaml:"apps" json:"apps,omitempty"`
	Widgets Apps    `yaml:"widgets" json:"widgets,omitempty"`
	Dock    Dock    `yaml:"dock_items" json:"dock_items,omitempty"  mapstructure:"dock_items"`
	Desktop Desktop `yaml:"desktop" json:"desktop,omitempty"  mapstructure:"desktop"`
}

Config is the Launchpad config

func LoadConfig

func LoadConfig(filename string) (Config, error)

LoadConfig loads the Launchpad config from the config file

func (Config) GetFolderContainingApp

func (c Config) GetFolderContainingApp(app string) (string, error)

GetFolderContainingApp returns the folder name that contains the app

func (Config) Verify

func (c Config) Verify() error

Verify that the config is valid

type DBInfo

type DBInfo struct {
	Key   string
	Value string
}

DBInfo - CREATE TABLE dbinfo (key VARCHAR, value VARCHAR)

func (DBInfo) TableName

func (DBInfo) TableName() string

TableName set DBInfo's table name to be `dbinfo`

type Desktop

type Desktop struct {
	Image string `yaml:"image,omitempty" json:"image,omitempty"`
}

Desktop is the desktop object

type Dock

type Dock struct {
	Apps     []string      `yaml:"apps,omitempty" json:"apps,omitempty"`
	Others   []Folder      `yaml:"others,omitempty" json:"others,omitempty"`
	Settings *DockSettings `yaml:"settings,omitempty" json:"settings,omitempty"`
}

Dock is the launchpad dock config object

type DockSettings

type DockSettings struct {
	AutoHide              bool `yaml:"autohide" json:"autohide,omitempty"`
	LargeSize             any  `yaml:"largesize" json:"largesize,omitempty"`
	Magnification         bool `yaml:"magnification" json:"magnification,omitempty"`
	MinimizeToApplication bool `yaml:"minimize-to-application" json:"minimize-to-application,omitempty"`
	MruSpaces             bool `yaml:"mru-spaces" json:"mru-spaces,omitempty"`
	ShowRecents           bool `yaml:"show-recents" json:"show-recents,omitempty"`
	TileSize              any  `yaml:"tilesize" json:"tilesize,omitempty"`
}

DockSettings is the launchpad dock settings object

type Folder

type Folder struct {
	Path    string        `yaml:"path,omitempty" json:"path,omitempty"`
	Display FolderDisplay `yaml:"display,omitempty" json:"display,omitempty"`
	View    FolderView    `yaml:"view,omitempty" json:"view,omitempty"`
	Sort    FolderSort    `yaml:"sort,omitempty" json:"sort,omitempty"`
}

Folder is a launchpad folder object

type FolderDisplay

type FolderDisplay int

type FolderPage

type FolderPage struct {
	Number int      `yaml:"number,omitempty" json:"number"`
	Items  []string `yaml:"items,omitempty" json:"items,omitempty"`
}

FolderPage is a launchpad folder page object

type FolderSort

type FolderSort int

type FolderView

type FolderView int

type Group

type Group struct {
	ID         int    `gorm:"column:item_id;primary_key"`
	CategoryID int    `gorm:"column:category_id;default:null"`
	Title      string `gorm:"column:title;default:null"`
}

Group CREATE TABLE groups (item_id INTEGER PRIMARY KEY, category_id INTEGER, title VARCHAR)

type Item

type Item struct {
	ID       int    `gorm:"column:rowid;primary_key"`
	App      App    `gorm:"ForeignKey:ID"`
	Widget   Widget `gorm:"ForeignKey:ID"`
	UUID     string `gorm:"column:uuid"`
	Flags    int    `gorm:"column:flags;default:null"`
	Type     int    `gorm:"column:type"`
	Group    Group  `gorm:"ForeignKey:ID"`
	ParentID int    `gorm:"not null;column:parent_id"`
	Ordering int    `gorm:"column:ordering"`
}

Item - CREATE TABLE items (rowid INTEGER PRIMARY KEY ASC, uuid VARCHAR, flags INTEGER, type INTEGER, parent_id INTEGER NOT NULL, ordering INTEGER)

type LaunchPad

type LaunchPad struct {
	DB     *gorm.DB
	File   string
	Folder string

	Config Config
	// contains filtered or unexported fields
}

LaunchPad is a LaunchPad struct

func (*LaunchPad) AddRootsAndHoldingPages

func (lp *LaunchPad) AddRootsAndHoldingPages() error

AddRootsAndHoldingPages adds back in the RootPage and HoldingPage defaults

func (*LaunchPad) ApplyConfig

func (lp *LaunchPad) ApplyConfig(config Apps, groupID, rootParentID int) error

func (*LaunchPad) ClearGroups

func (lp *LaunchPad) ClearGroups() error

ClearGroups clears out items related to groups

func (*LaunchPad) DisableTriggers

func (lp *LaunchPad) DisableTriggers() error

DisableTriggers disables item update triggers

func (*LaunchPad) EnableTriggers

func (lp *LaunchPad) EnableTriggers() error

EnableTriggers enables item update triggers

func (*LaunchPad) FixOther

func (lp *LaunchPad) FixOther() error

FixOther moves all apps in the 'Other' group to the root page

func (*LaunchPad) FlattenApps

func (lp *LaunchPad) FlattenApps() error

FlattenApps sets all the apps to the root page

func (*LaunchPad) GetMaxAppID

func (lp *LaunchPad) GetMaxAppID() int

GetMaxAppID returns the maximum App ItemID

func (*LaunchPad) GetMaxWidgetID

func (lp *LaunchPad) GetMaxWidgetID() int

GetMaxWidgetID returns the maximum Widget ItemID deprecated

func (*LaunchPad) GetMissing

func (lp *LaunchPad) GetMissing(apps *Apps, appType int) error

GetMissing returns a list of the rest of the apps not in the config

func (*LaunchPad) TriggersDisabled

func (lp *LaunchPad) TriggersDisabled() bool

TriggersDisabled returns true if triggers are disabled

type Page

type Page struct {
	Number int   `yaml:"number" json:"number"`
	Items  []any `yaml:"items,omitempty" json:"items,omitempty"`
}

Page is a launchpad page object

type Widget

type Widget struct {
	ID         int    `gorm:"column:item_id;primary_key"`
	Title      string `gorm:"column:title"`
	BundleID   string `gorm:"column:bundleid"`
	StoreID    string `gorm:"column:storeid;default:null"`
	CategoryID int    `gorm:"column:category_id;default:null"`
	Category   Category
	Moddate    float64 `gorm:"column:moddate"`
	Bookmark   []byte  `gorm:"column:bookmark"`
}

Widget - CREATE TABLE widgets (item_id INTEGER PRIMARY KEY, title VARCHAR, bundleid VARCHAR, storeid VARCHAR,category_id INTEGER, moddate REAL, bookmark BLOB)

Jump to

Keyboard shortcuts

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