diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-17 00:23:51 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-17 00:23:51 +0200 |
| commit | 04b4243ad31d144c4caf9be4c5096a0f27a2648e (patch) | |
| tree | 056515d145ba8e4fba29a2150b2c58199133b0c1 /gui/internal/ui/window.go | |
| parent | 9db67b201b80e9b7f824989df8517cefc587036d (diff) | |
| download | krino-04b4243ad31d144c4caf9be4c5096a0f27a2648e.tar.gz krino-04b4243ad31d144c4caf9be4c5096a0f27a2648e.zip | |
gui: syntax colours, a file preview, and a settings window
Diffstat (limited to 'gui/internal/ui/window.go')
| -rw-r--r-- | gui/internal/ui/window.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/gui/internal/ui/window.go b/gui/internal/ui/window.go index 27e1730..9727846 100644 --- a/gui/internal/ui/window.go +++ b/gui/internal/ui/window.go @@ -29,13 +29,14 @@ type Window struct { history *historyView rules *rulesView status *gtk.Label + prefs model.Prefs } // 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 := &Window{app: app, engine: e, prefs: model.LoadPrefs()} w.win = gtk.NewApplicationWindow(app) w.win.SetTitle("krino") w.win.SetDefaultSize(1200, 720) @@ -64,19 +65,29 @@ func NewWindow(app *gtk.Application, e *engine.Engine) *Window { w.status.SetMarginTop(4) w.status.SetMarginBottom(4) + settings := gtk.NewButtonWithLabel("Settings") + settings.SetHasFrame(false) + settings.ConnectClicked(func() { w.showSettings() }) + statusRow := gtk.NewBox(gtk.OrientationHorizontal, 6) + w.status.SetHExpand(true) + statusRow.Append(w.status) + statusRow.Append(settings) + box := gtk.NewBox(gtk.OrientationVertical, 0) notebook.SetVExpand(true) box.Append(notebook) box.Append(gtk.NewSeparator(gtk.OrientationHorizontal)) - box.Append(w.status) + box.Append(statusRow) w.win.SetChild(box) // Closing the window releases whatever directory lock the open plan // holds, rather than leaving a lock file for the next run to find. w.win.ConnectCloseRequest(func() bool { w.plan.closeTab() + w.plan.closePreview() w.history.closeTab() return false }) + w.applyPrefs(w.prefs) return w } @@ -98,6 +109,15 @@ func (w *Window) reloadEngine() error { return nil } +// applyPrefs takes a change from the settings window: the font of the +// editor, whether the configuration is coloured, and whether the file +// behind a row is shown. What is already on screen changes at once. +func (w *Window) applyPrefs(p model.Prefs) { + w.prefs = p + w.rules.applyPrefs(p) + w.plan.applyPrefs(p) +} + // 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. |
