aboutsummaryrefslogtreecommitdiff
path: root/gui/internal/ui/rules.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 10:56:19 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 10:56:19 +0200
commit48d1781fed3f9ea5cfd2b270bd92fd2826605636 (patch)
tree8abddf0ae7aaab97426cad1f65038560c8b85b9f /gui/internal/ui/rules.go
parenta2cb20851499e9c00bd3bf642680a9ce3148cae8 (diff)
downloadkrino-48d1781fed3f9ea5cfd2b270bd92fd2826605636.tar.gz
krino-48d1781fed3f9ea5cfd2b270bd92fd2826605636.zip
gui: conditions as a nested tree, and a way to add a directory
Diffstat (limited to 'gui/internal/ui/rules.go')
-rw-r--r--gui/internal/ui/rules.go20
1 files changed, 20 insertions, 0 deletions
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())