2024-04-28 22:47:50 -06:00
|
|
|
package nasin
|
|
|
|
|
|
|
|
import "image"
|
|
|
|
import "git.tebibyte.media/tomo/tomo"
|
|
|
|
|
|
|
|
// Application represents an application object.
|
|
|
|
type Application interface {
|
|
|
|
// Describe returns a description of the application.
|
|
|
|
Describe () ApplicationDescription
|
|
|
|
|
|
|
|
// Init performs the initial setup of the application.
|
|
|
|
Init ()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ApplicationDescription describes the name and type of an application.
|
|
|
|
type ApplicationDescription struct {
|
|
|
|
// The name of the application.
|
|
|
|
Name string
|
|
|
|
|
|
|
|
// The ID of the application. This should be a well-known name, that is,
|
|
|
|
// a reversed domain name owned by the author with the application name
|
|
|
|
// as the subdomain.
|
|
|
|
//
|
|
|
|
// For example:
|
|
|
|
// com.example.Application
|
|
|
|
ID string
|
|
|
|
|
|
|
|
// Role describes what the application does.
|
|
|
|
Role ApplicationRole
|
|
|
|
}
|
|
|
|
|
|
|
|
// String satisfies the fmt.Stringer interface.
|
|
|
|
func (application ApplicationDescription) String () string {
|
|
|
|
if application.Name == "" {
|
2024-04-29 14:21:35 -06:00
|
|
|
return string(application.Role)
|
2024-04-28 22:47:50 -06:00
|
|
|
} else {
|
|
|
|
return application.Name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ApplicationRole describes what an application does.
|
2024-04-29 14:21:35 -06:00
|
|
|
type ApplicationRole string; const (
|
|
|
|
RoleUnknown ApplicationRole = ""
|
|
|
|
|
|
|
|
RoleWebBrowser ApplicationRole = "Web Browser"
|
|
|
|
RoleMesssanger ApplicationRole = "Messsanger"
|
|
|
|
RolePhone ApplicationRole = "Phone"
|
|
|
|
RoleMail ApplicationRole = "Mail"
|
|
|
|
|
|
|
|
RoleTerminalEmulator ApplicationRole = "Terminal Emulator"
|
|
|
|
RoleFileBrowser ApplicationRole = "File Browser"
|
|
|
|
RoleTextEditor ApplicationRole = "Text Editor"
|
|
|
|
|
|
|
|
RoleDocumentViewer ApplicationRole = "Document Viewer"
|
|
|
|
RoleWordProcessor ApplicationRole = "Word Processor"
|
|
|
|
RoleSpreadsheet ApplicationRole = "Spreadsheet"
|
|
|
|
RoleSlideshow ApplicationRole = "Slideshow"
|
|
|
|
RoleCalculator ApplicationRole = "Calculator"
|
|
|
|
|
|
|
|
RolePreferences ApplicationRole = "Preferences"
|
|
|
|
RoleProcessManager ApplicationRole = "Process Manager"
|
|
|
|
RoleSystemInformation ApplicationRole = "System Information"
|
|
|
|
RoleManual ApplicationRole = "Manual"
|
|
|
|
|
|
|
|
RoleCamera ApplicationRole = "Camera"
|
|
|
|
RoleImageViewer ApplicationRole = "Image Viewer"
|
|
|
|
RoleMediaPlayer ApplicationRole = "Media Player"
|
|
|
|
RoleImageEditor ApplicationRole = "Image Editor"
|
|
|
|
RoleAudioEditor ApplicationRole = "Audio Editor"
|
|
|
|
RoleVideoEditor ApplicationRole = "Video Editor"
|
|
|
|
|
|
|
|
RoleClock ApplicationRole = "Clock"
|
|
|
|
RoleCalendar ApplicationRole = "Calendar"
|
|
|
|
RoleChecklist ApplicationRole = "Checklist"
|
2024-04-28 22:47:50 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// RunApplication is like Run, but runs an application.
|
|
|
|
func RunApplication (application Application) error {
|
|
|
|
return tomo.Run(application.Init)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewApplicationWindow creates a window for an application. It will
|
|
|
|
// automatically set window information to signal to the OS that the window is
|
|
|
|
// owned by the application.
|
|
|
|
func NewApplicationWindow (application Application, bounds image.Rectangle) (tomo.MainWindow, error) {
|
|
|
|
window, err := tomo.NewWindow(bounds)
|
|
|
|
if err != nil { return nil, err }
|
|
|
|
window.SetTitle(application.Describe().String())
|
|
|
|
return window, nil
|
|
|
|
}
|