*BREAKING CHANGE* move Path and Paths methods into application package.

This commit is contained in:
Lea Anthony 2025-01-24 08:09:13 +11:00
commit 46bb4e8414
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
3 changed files with 17 additions and 16 deletions

View file

@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Breaking Changes
- Renamed Service methods: `Name` -> `ServiceName`, `OnStartup` -> `ServiceStartup`, `OnShutdown` -> `ServiceShutdown` by [@leaanthony](https://github.com/leaanthony)
- Moved `Path` and `Paths` methods to `application` package by [@leaanthony](https://github.com/leaanthony)
### Added

View file

@ -1077,16 +1077,6 @@ func (a *App) shouldQuit() bool {
return true
}
// Path returns the path for the given selector
func (a *App) Path(selector Path) string {
return paths[selector]
}
// Paths returns the paths for the given selector
func (a *App) Paths(selector Paths) []string {
return pathdirs[selector]
}
// OpenFileManager opens the file manager at the specified path, optionally selecting the file.
func (a *App) OpenFileManager(path string, selectFile bool) error {
return InvokeSyncWithError(func() error {

View file

@ -2,11 +2,11 @@ package application
import "github.com/adrg/xdg"
type Path int
type PathType int
const (
// PathHome is the user's home directory.
PathHome Path = iota
PathHome PathType = iota
// PathDataHome defines the base directory relative to which user-specific
// data files should be stored. This directory is defined by the
@ -68,7 +68,7 @@ const (
PathPublicShare
)
var paths = map[Path]string{
var paths = map[PathType]string{
PathHome: xdg.Home,
PathDataHome: xdg.DataHome,
PathConfigHome: xdg.ConfigHome,
@ -85,7 +85,7 @@ var paths = map[Path]string{
PathPublicShare: xdg.UserDirs.PublicShare,
}
type Paths int
type PathTypes int
const (
// PathsDataDirs defines the preference-ordered set of base directories to
@ -96,7 +96,7 @@ const (
// DataHome directory is considered more important than any of the
// directories defined by DataDirs. Therefore, user data files should be
// written relative to the DataHome directory, if possible.
PathsDataDirs = iota
PathsDataDirs PathTypes = iota
// PathsConfigDirs defines the preference-ordered set of base directories
// search for configuration files in addition to the ConfigHome base
@ -115,9 +115,19 @@ const (
PathsApplicationDirs
)
var pathdirs = map[Paths][]string{
var pathdirs = map[PathTypes][]string{
PathsDataDirs: xdg.DataDirs,
PathsConfigDirs: xdg.ConfigDirs,
PathsFontDirs: xdg.FontDirs,
PathsApplicationDirs: xdg.ApplicationDirs,
}
// Path returns the path for the given selector
func Path(selector PathType) string {
return paths[selector]
}
// Paths returns the paths for the given selector
func Paths(selector PathTypes) []string {
return pathdirs[selector]
}