From 813c5b09fe57021809a4f550d766e43b809e433e Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sun, 10 Nov 2024 17:38:39 +0100 Subject: WIP: xA: highlighted icon --- xA/Makefile | 2 +- xA/xA.go | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/xA/Makefile b/xA/Makefile index cd33028..b597652 100644 --- a/xA/Makefile +++ b/xA/Makefile @@ -21,7 +21,7 @@ FyneApp.toml: ../xK-version Categories = ['Network', 'Chat', 'IRCClient']\n" > $@ .svg.png: rsvg-convert --output=$@ -- $< -xA: xA.go proto.go ../xK-version +xA: xA.go proto.go ../xK-version xA.png xA-highlighted.png go build -ldflags "-X 'main.projectVersion=$$(cat ../xK-version)'" -o $@ \ -gcflags=all="-N -l" proto.go: $(tools)/lxdrgen.awk $(tools)/lxdrgen-go.awk ../xC.lxdr diff --git a/xA/xA.go b/xA/xA.go index 8150026..c1038e5 100644 --- a/xA/xA.go +++ b/xA/xA.go @@ -6,6 +6,7 @@ package main import ( "bufio" "context" + _ "embed" "encoding/binary" "flag" "fmt" @@ -31,6 +32,16 @@ var ( debug = flag.Bool("debug", false, "enable debug output") projectName = "xA" projectVersion = "?" + + //go:embed xA.png + iconNormal []byte + //go:embed xA-highlighted.png + iconHighlighted []byte + + resourceIconNormal = fyne.NewStaticResource( + "xA.png", iconNormal) + resourceIconHighlighted = fyne.NewStaticResource( + "xA-highlighted.png", iconHighlighted) ) // --- Theme ------------------------------------------------------------------- @@ -326,7 +337,19 @@ func bufferScrollToBottom() { // --- UI state refresh -------------------------------------------------------- func refreshIcon() { - // TODO(p): We can have an icon. + highlighted := false + for _, b := range buffers { + if b.highlighted { + highlighted = true + break + } + } + + if highlighted { + wWindow.SetIcon(resourceIconHighlighted) + } else { + wWindow.SetIcon(resourceIconNormal) + } } func refreshTopic(topic []bufferLineItem) { @@ -577,9 +600,8 @@ func bufferPrintLine(lines []bufferLine, index int) { } func bufferPrintSeparator() { - // TODO(p): Formatting. + // TODO(p): Implement our own, so that it can use the primary colour. wRichText.Segments = append(wRichText.Segments, - &widget.TextSegment{Style: widget.RichTextStyleParagraph}, &widget.SeparatorSegment{}) } @@ -656,6 +678,7 @@ func relayProcessBufferLine(b *buffer, m *RelayEventDataBufferLine) { bufferScrollToBottom() } + // TODO(p): On mobile, we should probably send notifications. if line.isHighlight || (!visible && !line.isUnimportant && b.kind == RelayBufferKindPrivateMessage) { beep() -- cgit v1.2.3-70-g09d2