From f74a02254ac15a84d38c9a254ead293ebaad2377 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 17 Sep 2026 14:16:19 +0200 Subject: Settings changes take effect, and keep this copy respects the plan Five of the Settings window's controls - the sort order, the three column toggles and the preview height - were read when it built its new preferences but never connected to anything, so changing them did nothing until some other control happened to fire, and then they all landed at once out of nowhere. Every control is connected now. The same closure composed a whole Prefs from its own widgets, which wrote the remembered divider positions back as zeros: dragging the panes to taste and then ticking any checkbox threw them away. A settings change is now applied over the preferences as they are, by model.Prefs.WithDisplay - which is where it can be tested, and is. "Keep this copy, replace the other" wrote a Displaces straight into the chain. internal/plan refuses to build two steps that displace one path, because the second destroys what the first put there; the window went round that code, so choosing it for two duplicates of one file left both rows saying "done" with the first file in the Trash. It now refuses the second, naming the file that has the place. --- gui/internal/ui/settings.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'gui/internal/ui') diff --git a/gui/internal/ui/settings.go b/gui/internal/ui/settings.go index 32a6066..361f415 100644 --- a/gui/internal/ui/settings.go +++ b/gui/internal/ui/settings.go @@ -137,6 +137,9 @@ func (w *Window) showSettings() { box.Append(l) } + // Everything this window can change, applied over the preferences as + // they are: the divider positions belong to the panes, not here, and + // composing a whole Prefs from these controls wrote them back as zeros. apply := func() { which := model.LayoutSide if layout.Selected() == 1 { @@ -146,8 +149,9 @@ func (w *Window) showSettings() { if i := int(sortOrder.Selected()); i >= 0 && i < len(model.SortOrders) { order = model.SortOrders[i] } - p := model.Prefs{ + p := w.prefs.WithDisplay(model.Display{ Sort: order, + Layout: which, ShowSize: showSize.Active(), ShowAge: showAge.Active(), ShowRule: showRule.Active(), @@ -155,17 +159,24 @@ func (w *Window) showSettings() { Preview: preview.Active(), SelectAll: selectAll.Selected() == 0, PreviewHeight: int(previewHeight.Value()), - Layout: which, - } + }) w.applyPrefs(p) if err := p.Save(); err != nil { w.setStatus("settings: %v", err) } } + // Every control, not four of them: sort, the three column toggles and + // the preview height were read by apply but never connected to it, so + // changing them did nothing until some other control happened to fire. colours.ConnectToggled(apply) preview.ConnectToggled(apply) + showSize.ConnectToggled(apply) + showAge.ConnectToggled(apply) + showRule.ConnectToggled(apply) selectAll.Connect("notify::selected", func() { apply() }) layout.Connect("notify::selected", func() { apply() }) + sortOrder.Connect("notify::selected", func() { apply() }) + previewHeight.ConnectValueChanged(apply) s.save = gtk.NewButtonWithLabel("Save krino.conf") s.save.AddCSSClass("suggested-action") -- cgit v1.3