diff options
Diffstat (limited to 'gui/internal/ui/rules.go')
| -rw-r--r-- | gui/internal/ui/rules.go | 20 |
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()) |
