From 4d6386960c981678a8e8123a4db5463df7ee60bb Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 17 Sep 2026 09:12:32 +0200 Subject: gui: keep every divider where it is put, and let the columns shrink --- gui/internal/ui/window.go | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'gui/internal/ui/window.go') 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. -- cgit v1.3