Backend registering is platform-dependent

This commit is contained in:
Sasha Koshka 2024-05-03 12:46:09 -04:00
parent 2eb82d9035
commit 7c7d93d6d1
3 changed files with 15 additions and 5 deletions

View File

@ -1,7 +1,9 @@
package nasin package nasin
import "log"
import "image" import "image"
import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/nasin/internal/registry"
// Application represents an application object. // Application represents an application object.
type Application interface { type Application interface {
@ -74,9 +76,13 @@ type ApplicationRole string; const (
RoleChecklist ApplicationRole = "Checklist" RoleChecklist ApplicationRole = "Checklist"
) )
// RunApplication is like Run, but runs an application. // RunApplication is like tomo.Run, but runs an application. If something fails
func RunApplication (application Application) error { // to initialize, an error is written to the standard logger.
return tomo.Run(application.Init) func RunApplication (application Application) {
err := registry.Init()
if err != nil { log.Fatal("nasin: could not init registry:", err) }
err := tomo.Run(application.Init)
if err != nil { log.Fatal("nasin: could not run application:", err) }
} }
// NewApplicationWindow creates a window for an application. It will // NewApplicationWindow creates a window for an application. It will

2
internal/registry/doc.go Normal file
View File

@ -0,0 +1,2 @@
// Package registry provides platform-dependent components at compile time.
package registry

View File

@ -1,8 +1,10 @@
package nasin //go:build unix && (!darwin)
package registry
import "git.tebibyte.media/tomo/x" import "git.tebibyte.media/tomo/x"
import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo"
func init () { func Init () error {
tomo.Register(1, x.NewBackend) tomo.Register(1, x.NewBackend)
return nil
} }