diff options
Diffstat (limited to 'gui/internal/ui/window.go')
| -rw-r--r-- | gui/internal/ui/window.go | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/gui/internal/ui/window.go b/gui/internal/ui/window.go index e35a363..c42a7e8 100644 --- a/gui/internal/ui/window.go +++ b/gui/internal/ui/window.go @@ -24,16 +24,17 @@ type Window struct { win *gtk.ApplicationWindow engine *engine.Engine - sess *engine.Session - plan *planView - status *gtk.Label + plan *planView + history *historyView + status *gtk.Label } -// NewWindow builds the window for e; the session is the run everything in -// it goes through. -func NewWindow(app *gtk.Application, e *engine.Engine, sess *engine.Session) *Window { - w := &Window{app: app, engine: e, sess: sess} +// NewWindow builds the window for e. Each plan and each undo is its own +// run of krino, with its own run id in the log, so the window itself holds +// no session. +func NewWindow(app *gtk.Application, e *engine.Engine) *Window { + w := &Window{app: app, engine: e} w.win = gtk.NewApplicationWindow(app) w.win.SetTitle("krino") w.win.SetDefaultSize(1000, 640) @@ -41,8 +42,18 @@ func NewWindow(app *gtk.Application, e *engine.Engine, sess *engine.Session) *Wi notebook := gtk.NewNotebook() w.plan = newPlanView(w) notebook.AppendPage(w.plan.root, gtk.NewLabel("Plan")) - notebook.AppendPage(placeholder("History and undo arrives with the next milestone."), gtk.NewLabel("History & undo")) + w.history = newHistoryView(w) + notebook.AppendPage(w.history.root, gtk.NewLabel("History & undo")) notebook.AppendPage(placeholder("The rules editor arrives with a later milestone."), gtk.NewLabel("Rules")) + // The log is read when the tab is first opened, not at start-up: a + // window that only sorts never reads it. + loaded := false + notebook.ConnectSwitchPage(func(_ gtk.Widgetter, page uint) { + if page == 1 && !loaded { + loaded = true + w.history.loadRuns() + } + }) w.status = gtk.NewLabel("") w.status.SetXAlign(0) @@ -61,6 +72,7 @@ func NewWindow(app *gtk.Application, e *engine.Engine, sess *engine.Session) *Wi // holds, rather than leaving a lock file for the next run to find. w.win.ConnectCloseRequest(func() bool { w.plan.closeTab() + w.history.closeTab() return false }) return w @@ -69,6 +81,18 @@ func NewWindow(app *gtk.Application, e *engine.Engine, sess *engine.Session) *Wi // Show puts the window on screen. func (w *Window) Show() { w.win.Show() } +// dirRoot is the path of the configured directory called name, or "" if +// the configuration no longer has one - a log entry can outlive its +// directory. +func (w *Window) dirRoot(name string) string { + for _, d := range w.engine.Dirs { + if d.Name == name { + return d.Root + } + } + return "" +} + // setStatus writes the line at the bottom of the window. func (w *Window) setStatus(format string, args ...any) { w.status.SetText(fmt.Sprintf(format, args...)) |
