config

package
v0.0.0-...-6513b37 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config provides the repository for configuration and preferences.

Index

Constants

View Source
const ConfigFile = "config.json"

Variables

This section is empty.

Functions

func AppearanceAdd

func AppearanceAdd(name string, value EntryValue)

func DirPath

func DirPath() string

DirPath returns the config directory.

func MarshalToFile

func MarshalToFile(file string, from interface{}) error

MarshalToFile marshals the given interface into the given filename. The filename will be prepended with the config directory.

func PrettyMarshal

func PrettyMarshal(dst io.Writer, v interface{}) error

PrettyMarshal pretty marshals v into dst as formatted JSON.

func RegisterConfig

func RegisterConfig(filename string, jsonValue interface{})

RegisterConfig adds the config filename into the registry of value pointers to unmarshal configs to.

func Restore

func Restore()

Restore the global config. IsNotExist is not an error and will not be logged.

func Save

func Save() error

Save the global config.

func SaveToFile

func SaveToFile(file string, v []byte) error

SaveToFile saves the given bytes into the given filename. The filename will be prepended with the config directory.

func Sections

func Sections() (sects [sectionLen][]Entry)

func UnmarshalFromFile

func UnmarshalFromFile(file string, to interface{}) error

UnmarshalFromFile unmarshals the given filename to the given interface. The filename will be prepended with the config directory. IsNotExist errors are ignored.

Types

type Entry

type Entry struct {
	Name  string
	Value EntryValue
}

type EntryValue

type EntryValue interface {
	json.Marshaler
	json.Unmarshaler
	Construct() gtk.IWidget
}

EntryValue with JSON serde capabilities.

func Combo

func Combo(selected *int, options []string, change func(int)) EntryValue

func InputEntry

func InputEntry(value *string, change func(string) error) EntryValue

func Switch

func Switch(value *bool, change func(bool)) EntryValue

type Section

type Section uint8

List of config sections.

const (
	Appearance Section = iota
)

func (Section) String

func (s Section) String() string

type SectionEntries

type SectionEntries map[string]EntryValue

func (SectionEntries) UnmarshalJSON

func (s SectionEntries) UnmarshalJSON(b []byte) error

UnmarshalJSON ignores all JSON entries with unknown keys.

type Updaters

type Updaters []func()

Updaters contains a list of callbacks to be called when something is updated.

func (*Updaters) Add

func (us *Updaters) Add(f func())

func (*Updaters) Updated

func (us *Updaters) Updated()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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