Last active
January 7, 2020 16:58
-
-
Save asticode/26467f277049aa62ca5fcfe7cfa6ae4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"github.com/asticode/go-astilectron" | |
"github.com/asticode/go-astilectron-bootstrap" | |
"github.com/asticode/go-astilog" | |
"github.com/pkg/errors" | |
) | |
// Vars | |
var ( | |
AppName string | |
BuiltAt string | |
debug = flag.Bool("d", false, "enables the debug mode") | |
w *astilectron.Window | |
) | |
func main() { | |
// Init | |
flag.Parse() | |
astilog.FlagInit() | |
// Run bootstrap | |
astilog.Debugf("Running app built at %s", BuiltAt) | |
if err := bootstrap.Run(bootstrap.Options{ | |
AstilectronOptions: astilectron.Options{ | |
AppName: AppName, | |
AppIconDarwinPath: "resources/icon.icns", | |
AppIconDefaultPath: "resources/icon.png", | |
}, | |
Debug: *debug, | |
Homepage: "index.html", | |
Logger: astilog.GetLogger(), | |
MenuOptions: []*astilectron.MenuItemOptions{{ | |
Label: astilectron.PtrStr("File"), | |
SubMenu: []*astilectron.MenuItemOptions{ | |
{Label: astilectron.PtrStr("About")}, | |
{Role: astilectron.MenuItemRoleClose}, | |
}, | |
}}, | |
OnWait: func(_ *astilectron.Astilectron, iw *astilectron.Window, _ *astilectron.Menu, _ *astilectron.Tray, _ *astilectron.Menu) error { | |
w = iw | |
return nil | |
}, | |
WindowOptions: &astilectron.WindowOptions{ | |
BackgroundColor: astilectron.PtrStr("#333"), | |
Center: astilectron.PtrBool(true), | |
Height: astilectron.PtrInt(700), | |
Width: astilectron.PtrInt(700), | |
}, | |
}); err != nil { | |
astilog.Fatal(errors.Wrap(err, "running bootstrap failed")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment