2019-09-06 11:43:14 -04:00
|
|
|
//+build darwin
|
2019-09-06 10:45:18 -04:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/user"
|
|
|
|
"path"
|
|
|
|
|
2019-11-20 14:30:43 -05:00
|
|
|
"gioui.org/app"
|
2019-12-18 13:30:56 -05:00
|
|
|
"gioui.org/font"
|
|
|
|
"gioui.org/font/gofont"
|
|
|
|
"gioui.org/font/opentype"
|
|
|
|
"gioui.org/text"
|
2019-09-06 10:45:18 -04:00
|
|
|
)
|
|
|
|
|
2019-11-20 15:48:56 -05:00
|
|
|
var (
|
|
|
|
noidLabelText = "No GPG ids available. Please create a private key or enter a key ID above"
|
|
|
|
)
|
|
|
|
|
2019-12-18 13:30:56 -05:00
|
|
|
func setFont() error {
|
2019-09-06 10:45:18 -04:00
|
|
|
f, err := os.Open("/System/Library/Fonts/AppleSDGothicNeo.ttc")
|
|
|
|
if err != nil {
|
2019-12-18 13:30:56 -05:00
|
|
|
log(Info, "Cannot open system font collection")
|
2019-09-06 10:45:18 -04:00
|
|
|
return err
|
2019-09-06 10:46:23 -04:00
|
|
|
|
2019-09-06 10:45:18 -04:00
|
|
|
}
|
2019-12-18 13:30:56 -05:00
|
|
|
fnts, err := opentype.ParseCollectionReaderAt(f)
|
2019-09-06 10:45:18 -04:00
|
|
|
if err != nil {
|
2019-12-18 13:30:56 -05:00
|
|
|
log(Info, "Cannot parse font collection")
|
2019-09-06 10:45:18 -04:00
|
|
|
return err
|
|
|
|
}
|
2019-12-18 13:30:56 -05:00
|
|
|
face, err := fnts.Font(0)
|
2019-09-06 10:45:18 -04:00
|
|
|
if err != nil {
|
2019-12-18 13:30:56 -05:00
|
|
|
log(Info, "Cannot access font from font collection")
|
2019-09-06 10:45:18 -04:00
|
|
|
return err
|
|
|
|
}
|
2019-12-18 13:30:56 -05:00
|
|
|
font.Register(text.Font{}, face)
|
2019-09-06 10:45:18 -04:00
|
|
|
return nil
|
2019-12-18 13:30:56 -05:00
|
|
|
}
|
2019-09-06 10:45:18 -04:00
|
|
|
|
|
|
|
func init() {
|
2019-11-20 14:30:43 -05:00
|
|
|
fontSize = 16
|
2019-12-18 13:30:56 -05:00
|
|
|
err := setFont()
|
|
|
|
if err != nil {
|
|
|
|
gofont.Register()
|
|
|
|
}
|
2019-11-20 14:30:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func initPgp(w *app.Window) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func getConfDir() (string, error) {
|
2019-09-06 10:45:18 -04:00
|
|
|
usr, err := user.Current()
|
|
|
|
if err != nil {
|
2019-11-20 14:30:43 -05:00
|
|
|
log(Error, "Cannot get current user: ", err)
|
|
|
|
return "", err
|
2019-09-06 10:45:18 -04:00
|
|
|
}
|
2019-11-20 14:30:43 -05:00
|
|
|
ret := path.Join(usr.HomeDir, ".config/passgo")
|
|
|
|
if _, err := os.Stat(ret); os.IsNotExist(err) {
|
|
|
|
err = os.MkdirAll(ret, 0700)
|
2019-09-06 10:45:18 -04:00
|
|
|
if err != nil {
|
2019-09-06 10:46:23 -04:00
|
|
|
log(Info, "Cannot create configuration directory ", confDir)
|
2019-11-20 14:30:43 -05:00
|
|
|
return "", err
|
2019-09-06 10:45:18 -04:00
|
|
|
} else {
|
|
|
|
log(Info, "Configuration directory created")
|
2019-11-20 14:30:43 -05:00
|
|
|
return ret, nil
|
2019-09-06 10:45:18 -04:00
|
|
|
}
|
|
|
|
}
|
2019-11-20 14:30:43 -05:00
|
|
|
return ret, nil
|
2019-09-06 10:45:18 -04:00
|
|
|
}
|