Fix uncolored names for light theme
This commit is contained in:
parent
d8f68cb852
commit
52655c2859
|
@ -48,6 +48,10 @@ type Message struct {
|
||||||
|
|
||||||
var _ container.MessageRow = (*Message)(nil)
|
var _ container.MessageRow = (*Message)(nil)
|
||||||
|
|
||||||
|
var renderCfg = markup.RenderConfig{
|
||||||
|
NoReferencing: true,
|
||||||
|
}
|
||||||
|
|
||||||
func WrapMessage(ct *message.State) Message {
|
func WrapMessage(ct *message.State) Message {
|
||||||
ts := message.NewTimestamp()
|
ts := message.NewTimestamp()
|
||||||
ts.SetVAlign(gtk.ALIGN_START)
|
ts.SetVAlign(gtk.ALIGN_START)
|
||||||
|
@ -74,12 +78,8 @@ func WrapMessage(ct *message.State) Message {
|
||||||
ct.PackStart(ct.Content, true, true, 0)
|
ct.PackStart(ct.Content, true, true, 0)
|
||||||
ct.SetClass("compact")
|
ct.SetClass("compact")
|
||||||
|
|
||||||
rcfg := markup.RenderConfig{}
|
|
||||||
rcfg.NoReferencing = true
|
|
||||||
rcfg.SetForegroundAnchor(ct.ContentBodyStyle)
|
|
||||||
|
|
||||||
user.SetRenderer(func(rich text.Rich) markup.RenderOutput {
|
user.SetRenderer(func(rich text.Rich) markup.RenderOutput {
|
||||||
return markup.RenderCmplxWithConfig(rich, rcfg)
|
return markup.RenderCmplxWithConfig(rich, renderCfg)
|
||||||
})
|
})
|
||||||
|
|
||||||
return Message{
|
return Message{
|
||||||
|
|
|
@ -54,6 +54,10 @@ func NewFullMessage(msg cchat.MessageCreate) *FullMessage {
|
||||||
return WrapFullMessage(message.NewState(msg))
|
return WrapFullMessage(message.NewState(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var renderCfg = markup.RenderConfig{
|
||||||
|
NoReferencing: true,
|
||||||
|
}
|
||||||
|
|
||||||
func WrapFullMessage(gc *message.State) *FullMessage {
|
func WrapFullMessage(gc *message.State) *FullMessage {
|
||||||
header := labeluri.NewLabel(text.Rich{})
|
header := labeluri.NewLabel(text.Rich{})
|
||||||
header.SetHAlign(gtk.ALIGN_START) // left-align
|
header.SetHAlign(gtk.ALIGN_START) // left-align
|
||||||
|
@ -103,12 +107,8 @@ func WrapFullMessage(gc *message.State) *FullMessage {
|
||||||
unwrap: func() { removeUpdate() },
|
unwrap: func() { removeUpdate() },
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := markup.RenderConfig{}
|
|
||||||
cfg.NoReferencing = true
|
|
||||||
cfg.SetForegroundAnchor(gc.ContentBodyStyle)
|
|
||||||
|
|
||||||
header.SetRenderer(func(rich text.Rich) markup.RenderOutput {
|
header.SetRenderer(func(rich text.Rich) markup.RenderOutput {
|
||||||
output := markup.RenderCmplxWithConfig(rich, cfg)
|
output := markup.RenderCmplxWithConfig(rich, renderCfg)
|
||||||
output.Markup = `<span font_weight="600">` + output.Markup + "</span>"
|
output.Markup = `<span font_weight="600">` + output.Markup + "</span>"
|
||||||
output.Markup += msg.timestamp
|
output.Markup += msg.timestamp
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (m *MenuButton) Bind(menu *Menu) {
|
||||||
// menu items.
|
// menu items.
|
||||||
m.SetSensitive(model.GetNItems() > 0)
|
m.SetSensitive(model.GetNItems() > 0)
|
||||||
// Subscribe the button to menu update events.
|
// Subscribe the button to menu update events.
|
||||||
m.lastsig = model.Connect("items-changed", func(model *glib.MenuModel) {
|
m.lastsig = model.Connect("items-changed", func() {
|
||||||
m.SetSensitive(model.GetNItems() > 0)
|
m.SetSensitive(model.GetNItems() > 0)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,11 +4,13 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/diamondburned/cchat-gtk/internal/gts"
|
||||||
"github.com/diamondburned/cchat-gtk/internal/ui/rich/parser/attrmap"
|
"github.com/diamondburned/cchat-gtk/internal/ui/rich/parser/attrmap"
|
||||||
"github.com/diamondburned/cchat-gtk/internal/ui/rich/parser/hl"
|
"github.com/diamondburned/cchat-gtk/internal/ui/rich/parser/hl"
|
||||||
"github.com/diamondburned/cchat/text"
|
"github.com/diamondburned/cchat/text"
|
||||||
|
@ -136,13 +138,10 @@ type RenderConfig struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetForegroundAnchor sets the AnchorColor of the render config to be that of
|
// setForegroundAnchor sets the AnchorColor of the render config to be that of
|
||||||
// the regular text foreground color.
|
// the regular text foreground color.
|
||||||
func (c *RenderConfig) SetForegroundAnchor(ctx *gtk.StyleContext) {
|
func (c *RenderConfig) setForegroundAnchor(ctx *gtk.StyleContext) {
|
||||||
rgba := ctx.GetColor(gtk.STATE_FLAG_NORMAL)
|
rgba := ctx.GetColor(gtk.STATE_FLAG_ACTIVE)
|
||||||
if rgba == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var color uint32
|
var color uint32
|
||||||
for _, v := range rgba.Floats() { // [0.0, 1.0]
|
for _, v := range rgba.Floats() { // [0.0, 1.0]
|
||||||
|
@ -153,6 +152,21 @@ func (c *RenderConfig) SetForegroundAnchor(ctx *gtk.StyleContext) {
|
||||||
c.AnchorColor.uint32 = text.SolidColor(color) // force alpha 100%
|
c.AnchorColor.uint32 = text.SolidColor(color) // force alpha 100%
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensureAnchorColor ensures the RenderConfig has an AnchorColor.
|
||||||
|
func (c *RenderConfig) ensureAnchorColor() {
|
||||||
|
if c.AnchorColor.bool {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
styleCtx, _ := gts.App.Window.GetStyleContext()
|
||||||
|
if styleCtx == nil {
|
||||||
|
log.Println("Window's StyleCtx is nil.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.setForegroundAnchor(styleCtx)
|
||||||
|
}
|
||||||
|
|
||||||
func RenderCmplxWithConfig(content text.Rich, cfg RenderConfig) RenderOutput {
|
func RenderCmplxWithConfig(content text.Rich, cfg RenderConfig) RenderOutput {
|
||||||
// Fast path.
|
// Fast path.
|
||||||
if len(content.Segments) == 0 {
|
if len(content.Segments) == 0 {
|
||||||
|
@ -232,7 +246,8 @@ func RenderCmplxWithConfig(content text.Rich, cfg RenderConfig) RenderOutput {
|
||||||
|
|
||||||
if colorer := segment.AsColorer(); colorer != nil {
|
if colorer := segment.AsColorer(); colorer != nil {
|
||||||
appended.Span(start, end, colorAttrs(colorer.Color(), false)...)
|
appended.Span(start, end, colorAttrs(colorer.Color(), false)...)
|
||||||
} else if hasAnchor && cfg.AnchorColor.bool {
|
} else if hasAnchor {
|
||||||
|
cfg.ensureAnchorColor()
|
||||||
appended.Span(start, end, colorAttrs(cfg.AnchorColor.uint32, false)...)
|
appended.Span(start, end, colorAttrs(cfg.AnchorColor.uint32, false)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,16 +135,17 @@ func (s *Servers) SetList(slist cchat.Lister) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Servers) load() {
|
func (s *Servers) load() {
|
||||||
// Return if we're loading.
|
if s.Lister == nil || s.IsLoading() {
|
||||||
if s.IsLoading() {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark the servers list as loading.
|
// Mark the servers list as loading.
|
||||||
s.setLoading()
|
s.setLoading()
|
||||||
|
|
||||||
|
lister := s.Lister
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
stop, err := s.Lister.Servers(s)
|
stop, err := lister.Servers(s)
|
||||||
gts.ExecAsync(func() {
|
gts.ExecAsync(func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.setFailed(err)
|
s.setFailed(err)
|
||||||
|
|
Loading…
Reference in New Issue