aboutsummaryrefslogtreecommitdiff
path: root/gui/internal/ui/window.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 08:39:48 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 08:39:48 +0200
commit1e3dd67868e1b6d3c12f0bca201d5e60a12c3723 (patch)
tree3cea9254020a25bf69e1bb75096503db778bcff3 /gui/internal/ui/window.go
parent5418ba6bc5c653b6a99572c6ece6abbf57836c43 (diff)
downloadkrino-1e3dd67868e1b6d3c12f0bca201d5e60a12c3723.tar.gz
krino-1e3dd67868e1b6d3c12f0bca201d5e60a12c3723.zip
gui: aligned columns, theme colours, a second layout, and a scan-selection setting
Diffstat (limited to 'gui/internal/ui/window.go')
-rw-r--r--gui/internal/ui/window.go33
1 files changed, 32 insertions, 1 deletions
diff --git a/gui/internal/ui/window.go b/gui/internal/ui/window.go
index 784fc64..61fe157 100644
--- a/gui/internal/ui/window.go
+++ b/gui/internal/ui/window.go
@@ -104,6 +104,7 @@ func NewWindow(app *gtk.Application, e *engine.Engine) *Window {
w.history.closeTab()
return false
})
+ themeColours(w.win)
w.applyPrefs(w.prefs)
return w
}
@@ -225,7 +226,9 @@ func runInBackground(work func(context.Context) error, done func(error)) context
// actionColours are what each action is painted in, so the eye finds the
// deletions without reading: they are the ones that cannot be undone from
-// the window (his request, 2026-09-17).
+// the window. They are the fallbacks; themeColours replaces them with the
+// running theme's own, so the window looks like the rest of the desktop
+// rather than like GNOME's palette (his request, 2026-09-17).
var actionColours = map[plan.Kind]string{
plan.Copy: "#2a9d8f",
plan.Move: "#3584e4",
@@ -234,6 +237,34 @@ 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.
+func themeColours(w gtk.Widgetter) {
+ ctx := gtk.BaseWidget(w).StyleContext()
+ pick := func(names ...string) string {
+ for _, name := range names {
+ if rgba, ok := ctx.LookupColor(name); ok {
+ return fmt.Sprintf("#%02x%02x%02x",
+ int(rgba.Red()*255), int(rgba.Green()*255), int(rgba.Blue()*255))
+ }
+ }
+ return ""
+ }
+ set := func(kind plan.Kind, colour string) {
+ if colour != "" {
+ actionColours[kind] = colour
+ }
+ }
+ accent := pick("accent_color", "theme_selected_bg_color", "accent_bg_color")
+ set(plan.Move, accent)
+ set(plan.Copy, pick("success_color", "success_bg_color"))
+ set(plan.Rename, accent)
+ set(plan.Trash, pick("warning_color", "warning_bg_color"))
+ set(plan.DeletePermanent, pick("error_color", "destructive_color", "error_bg_color"))
+}
+
// actionRank decides which action gives a row its colour when a file gets
// several: the one that matters most to the reader.
var actionRank = map[plan.Kind]int{