aboutsummaryrefslogtreecommitdiff
path: root/gui/internal/ui/history.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-16 22:57:12 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-16 22:57:12 +0200
commit22c324d8e887a2c38d9ef01574e4c3f87f6b1706 (patch)
tree0f0d12efc65999e93968efe70c2687b42e71959e /gui/internal/ui/history.go
parent9300992c8a0043900a6cd76626310189d2537634 (diff)
downloadkrino-22c324d8e887a2c38d9ef01574e4c3f87f6b1706.tar.gz
krino-22c324d8e887a2c38d9ef01574e4c3f87f6b1706.zip
gui: size the plan and undo columns to what they hold, so the rule is never cut
Diffstat (limited to 'gui/internal/ui/history.go')
-rw-r--r--gui/internal/ui/history.go26
1 files changed, 21 insertions, 5 deletions
diff --git a/gui/internal/ui/history.go b/gui/internal/ui/history.go
index 7d4ee7b..bbdb27d 100644
--- a/gui/internal/ui/history.go
+++ b/gui/internal/ui/history.go
@@ -244,8 +244,9 @@ func (h *historyView) fillPlan() {
h.header.SetText(fmt.Sprintf("%d files · %d to reverse · %d refused",
c.Files, c.ToReverse, c.Refused))
}
+ w := h.widths()
for i, r := range h.tab.Rows {
- h.list.Append(h.undoRowWidget(i, r))
+ h.list.Append(h.undoRowWidget(i, r, w))
}
h.updateUndoButton()
}
@@ -258,8 +259,23 @@ func (h *historyView) clearPlan() {
h.undo.SetSensitive(false)
}
+// widths sizes the undo columns to what this plan holds, as the plan tab's
+// do, so a file or a reversal is not cut short for want of a few characters.
+func (h *historyView) widths() [3]int {
+ w := [3]int{16, 16, 6}
+ for _, r := range h.tab.Rows {
+ w[0] = max(w[0], len([]rune(r.Dir+"/"+r.File)))
+ w[1] = max(w[1], len([]rune(undoWhat(r, h.w.dirRoot(r.Dir)))))
+ w[2] = max(w[2], len([]rune(r.Outcome)))
+ }
+ for i, cap := range [3]int{40, 52, 24} {
+ w[i] = min(w[i], cap)
+ }
+ return w
+}
+
// undoRowWidget is one file of the reversal.
-func (h *historyView) undoRowWidget(i int, r model.UndoRow) *gtk.ListBoxRow {
+func (h *historyView) undoRowWidget(i int, r model.UndoRow, w [3]int) *gtk.ListBoxRow {
box := gtk.NewBox(gtk.OrientationHorizontal, 8)
box.SetMarginStart(6)
box.SetMarginEnd(6)
@@ -277,13 +293,13 @@ func (h *historyView) undoRowWidget(i int, r model.UndoRow) *gtk.ListBoxRow {
})
box.Append(check)
- box.Append(column(escape(r.Dir+"/"+r.File), 24, true))
+ box.Append(column(escape(r.Dir+"/"+r.File), w[0], true))
// The outcome comes before the reversal: after an undo it is what the
// user is looking for, and the reversal is the column that ellipsizes.
if r.Outcome != "" {
- box.Append(column(escape(r.Outcome), 12, false))
+ box.Append(column(escape(r.Outcome), w[2], false))
}
- what := column(escape(undoWhat(r, h.w.dirRoot(r.Dir))), 30, false)
+ what := columnMin(escape(undoWhat(r, h.w.dirRoot(r.Dir))), w[1], 18, true)
if r.Refused != "" {
what.AddCSSClass("error")
}