From 48d1781fed3f9ea5cfd2b270bd92fd2826605636 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 17 Sep 2026 10:56:19 +0200 Subject: gui: conditions as a nested tree, and a way to add a directory --- gui/internal/ui/rules.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gui/internal/ui/rules.go') diff --git a/gui/internal/ui/rules.go b/gui/internal/ui/rules.go index 3bae8df..5cce276 100644 --- a/gui/internal/ui/rules.go +++ b/gui/internal/ui/rules.go @@ -77,6 +77,10 @@ func newRulesView(w *Window) *rulesView { bar.SetMarginBottom(6) bar.Append(gtk.NewLabel("Rules for")) bar.Append(r.dirs) + add := gtk.NewButtonWithLabel("Add directory...") + add.SetTooltipText("sort another directory: writes dirs/NAME.conf from the template and adds NAME to krino.conf's include, as krino new does") + add.ConnectClicked(func() { r.w.addDirectory() }) + bar.Append(add) r.check = gtk.NewLabel("") r.check.SetXAlign(0) r.check.SetHExpand(true) @@ -269,6 +273,22 @@ func (r *rulesView) textChangedByForm() { r.runCheck() } +// refreshDirs rebuilds the picker after the configuration changed. +func (r *rulesView) refreshDirs(keep string) { + r.names = model.RuleFiles(r.w.engine) + names := r.names + if len(names) == 0 { + names = []string{"none"} + } + r.dirs.SetModel(gtk.NewStringList(names)) + for i, n := range r.names { + if n == keep { + r.dirs.SetSelected(uint(i)) + } + } + r.open(r.selectedName()) +} + // selectedName is the directory the picker names, "" when none is offered. func (r *rulesView) selectedName() string { i := int(r.dirs.Selected()) -- cgit v1.3