aboutsummaryrefslogtreecommitdiff
path: root/gui/internal/ui/window.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 09:12:32 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 09:12:32 +0200
commit4d6386960c981678a8e8123a4db5463df7ee60bb (patch)
tree403877da13c244b68ef335f25ba1337cd72a6527 /gui/internal/ui/window.go
parent80dde7b2cae7b9844c244e03395145370a819412 (diff)
downloadkrino-4d6386960c981678a8e8123a4db5463df7ee60bb.tar.gz
krino-4d6386960c981678a8e8123a4db5463df7ee60bb.zip
gui: keep every divider where it is put, and let the columns shrink
Diffstat (limited to 'gui/internal/ui/window.go')
-rw-r--r--gui/internal/ui/window.go29
1 files changed, 23 insertions, 6 deletions
diff --git a/gui/internal/ui/window.go b/gui/internal/ui/window.go
index 61fe157..06bce05 100644
--- a/gui/internal/ui/window.go
+++ b/gui/internal/ui/window.go
@@ -11,6 +11,7 @@ import (
"os"
"strings"
+ "github.com/diamondburned/gotk4/pkg/glib/v2"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
"krino/gui/internal/model"
@@ -26,12 +27,13 @@ type Window struct {
engine *engine.Engine
- plan *planView
- history *historyView
- rules *rulesView
- status *gtk.Label
- prefs model.Prefs
- leaving bool
+ plan *planView
+ history *historyView
+ rules *rulesView
+ status *gtk.Label
+ prefs model.Prefs
+ leaving bool
+ saveTimer glib.SourceHandle
}
// NewWindow builds the window for e. Each plan and each undo is its own
@@ -147,6 +149,21 @@ func (w *Window) confirmLeaving() {
d.Show()
}
+// savePrefsSoon writes the preferences a moment after the last change, so
+// dragging a divider does not write the file on every pixel.
+func (w *Window) savePrefsSoon() {
+ if w.saveTimer != 0 {
+ glib.SourceRemove(w.saveTimer)
+ }
+ w.saveTimer = glib.TimeoutAdd(500, func() bool {
+ w.saveTimer = 0
+ if err := w.prefs.Save(); err != nil {
+ w.setStatus("settings: %v", err)
+ }
+ return false
+ })
+}
+
// 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.