From 1e3dd67868e1b6d3c12f0bca201d5e60a12c3723 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 17 Sep 2026 08:39:48 +0200 Subject: gui: aligned columns, theme colours, a second layout, and a scan-selection setting --- gui/internal/ui/window.go | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'gui/internal/ui/window.go') 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{ -- cgit v1.3