aboutsummaryrefslogtreecommitdiff
path: root/gui/internal/ui/window.go
diff options
context:
space:
mode:
Diffstat (limited to 'gui/internal/ui/window.go')
-rw-r--r--gui/internal/ui/window.go55
1 files changed, 43 insertions, 12 deletions
diff --git a/gui/internal/ui/window.go b/gui/internal/ui/window.go
index 06bce05..12e94a3 100644
--- a/gui/internal/ui/window.go
+++ b/gui/internal/ui/window.go
@@ -254,12 +254,26 @@ var actionColours = map[plan.Kind]string{
plan.DeletePermanent: "#c01c28",
}
-// themeColours takes what it can from the GTK theme: the accent for the
-// actions that file a document, the theme's own warning and error colours
-// for the two that take it away. A theme that names none of them leaves the
-// fallbacks above.
+// actionClasses name the CSS class each action's cell carries. The colour
+// is applied by a style sheet rather than by painting the text, so that a
+// selected row - which draws its own background - can take the colour back
+// and stay readable: his green accent on his green selection was not (his
+// report, 2026-09-17).
+var actionClasses = map[plan.Kind]string{
+ plan.Copy: "krino-copy",
+ plan.Move: "krino-move",
+ plan.Rename: "krino-rename",
+ plan.Trash: "krino-trash",
+ plan.DeletePermanent: "krino-delete",
+}
+
+// themeColours takes what it can from the GTK theme - the accent for a
+// move, the selection blue for a rename, the theme's own success, warning
+// and error for the rest - and installs the style sheet that paints the
+// action cells. A theme that names none of them leaves the fallbacks above.
func themeColours(w gtk.Widgetter) {
- ctx := gtk.BaseWidget(w).StyleContext()
+ widget := gtk.BaseWidget(w)
+ ctx := widget.StyleContext()
pick := func(names ...string) string {
for _, name := range names {
if rgba, ok := ctx.LookupColor(name); ok {
@@ -274,12 +288,28 @@ func themeColours(w gtk.Widgetter) {
actionColours[kind] = colour
}
}
- accent := pick("accent_color", "theme_selected_bg_color", "accent_bg_color")
- set(plan.Move, accent)
+ set(plan.Move, pick("accent_color", "theme_selected_bg_color", "accent_bg_color"))
set(plan.Copy, pick("success_color", "success_bg_color"))
- set(plan.Rename, accent)
+ set(plan.Rename, pick("theme_selected_bg_color", "accent_bg_color"))
set(plan.Trash, pick("warning_color", "warning_bg_color"))
set(plan.DeletePermanent, pick("error_color", "destructive_color", "error_bg_color"))
+
+ var css strings.Builder
+ css.WriteString(".krino-action { font-weight: bold; }\n")
+ for kind, class := range actionClasses {
+ fmt.Fprintf(&css, ".%s { color: %s; }\n", class, actionColours[kind])
+ }
+ // A selected row paints its own background; the action takes that row's
+ // foreground so it never sits on a colour of its own.
+ fmt.Fprintf(&css, ".krino-warn { color: %s; }\n", actionColours[plan.Trash])
+ css.WriteString(".krino-title { font-weight: bold; font-size: 115%; }\n")
+ css.WriteString("row:selected .krino-action { color: @theme_selected_fg_color; }\n")
+ css.WriteString("row:selected .krino-action { color: @accent_fg_color; }\n")
+ provider := gtk.NewCSSProvider()
+ provider.LoadFromData(css.String())
+ if display := widget.Display(); display != nil {
+ gtk.StyleContextAddProviderForDisplay(display, provider, 700)
+ }
}
// actionRank decides which action gives a row its colour when a file gets
@@ -289,8 +319,9 @@ var actionRank = map[plan.Kind]int{
}
// rowAction is a row's actions in capitals - "MOVE", "RENAME+MOVE" - and
-// the colour they are shown in. A row that would do nothing has neither.
-func rowAction(r model.Row) (text, colour string) {
+// the CSS class they are painted with. A row that would do nothing has
+// neither.
+func rowAction(r model.Row) (text, class string) {
if len(r.Steps) == 0 {
return "", ""
}
@@ -309,9 +340,9 @@ func rowAction(r model.Row) (text, colour string) {
}
}
if len(parts) == 0 {
- return "SKIPPED", dimColour
+ return "SKIPPED", ""
}
- return strings.Join(parts, "+"), actionColours[worst]
+ return strings.Join(parts, "+"), actionClasses[worst]
}
// rowWhere is where a row's file would end up - the last place its steps