mirror of
https://github.com/diamondburned/cchat-gtk.git
synced 2025-03-21 17:39:23 +00:00
Bumped to cchat v0.0.37
This commit is contained in:
parent
0d2c1d5e8f
commit
0a353ff128
6
go.mod
6
go.mod
|
@ -7,9 +7,9 @@ replace github.com/gotk3/gotk3 => github.com/diamondburned/gotk3 v0.0.0-20200619
|
|||
require (
|
||||
github.com/Xuanwo/go-locale v0.2.0
|
||||
github.com/alecthomas/chroma v0.7.3
|
||||
github.com/diamondburned/cchat v0.0.35
|
||||
github.com/diamondburned/cchat-discord v0.0.0-20200629023132-0a66a65fcf27
|
||||
github.com/diamondburned/cchat-mock v0.0.0-20200628063912-3155c1b6d6a9
|
||||
github.com/diamondburned/cchat v0.0.37
|
||||
github.com/diamondburned/cchat-discord v0.0.0-20200630031444-53111f3186b3
|
||||
github.com/diamondburned/cchat-mock v0.0.0-20200630025821-605d61d89288
|
||||
github.com/diamondburned/imgutil v0.0.0-20200611215339-650ac7cfaf64
|
||||
github.com/goodsign/monday v1.0.0
|
||||
github.com/google/btree v1.0.0 // indirect
|
||||
|
|
6
go.sum
6
go.sum
|
@ -51,16 +51,22 @@ github.com/diamondburned/cchat v0.0.34 h1:BGiVxMRA9dmW3rLilIldBvjVan7eTTpaWCCfX9
|
|||
github.com/diamondburned/cchat v0.0.34/go.mod h1:+zXktogE45A0om4fT6B/z6Ii7FXNafjxsNspI0rlhbU=
|
||||
github.com/diamondburned/cchat v0.0.35 h1:WiMGl8BQJgbP9E4xRxgLGlqUsHpTcJgDKDt8/6a7lBk=
|
||||
github.com/diamondburned/cchat v0.0.35/go.mod h1:+zXktogE45A0om4fT6B/z6Ii7FXNafjxsNspI0rlhbU=
|
||||
github.com/diamondburned/cchat v0.0.37 h1:yGz9yls5Lb/vLkU/DU53GjC80WOqoRe229DXsu5mtaY=
|
||||
github.com/diamondburned/cchat v0.0.37/go.mod h1:+zXktogE45A0om4fT6B/z6Ii7FXNafjxsNspI0rlhbU=
|
||||
github.com/diamondburned/cchat-discord v0.0.0-20200619222738-e5babcbb42e3 h1:8RCcaY3gtA+8NG2mwkcC/PIFK+eS8XnGyeVaUbCXbF0=
|
||||
github.com/diamondburned/cchat-discord v0.0.0-20200619222738-e5babcbb42e3/go.mod h1:4q0jHEl1gJEzkS92oacwcSf9+3fFcNPukOpURDJpV/A=
|
||||
github.com/diamondburned/cchat-discord v0.0.0-20200629023132-0a66a65fcf27 h1:MAWs83jAZKxkU04RAoaewc1xUrLKlB6F5X1ViFRkWdw=
|
||||
github.com/diamondburned/cchat-discord v0.0.0-20200629023132-0a66a65fcf27/go.mod h1:af673uNyL2NSjYqJ54DotPV/iNY+OvBcQfDqHefbap4=
|
||||
github.com/diamondburned/cchat-discord v0.0.0-20200630031444-53111f3186b3 h1:NDh2osOfPBtiNzz8ro8P7vN4f91uuVMMBJ8+Q2s/EQo=
|
||||
github.com/diamondburned/cchat-discord v0.0.0-20200630031444-53111f3186b3/go.mod h1:hj6qS/5TOiIxwWyFMts51ILzY9M3GKbXT31hjVbr9gM=
|
||||
github.com/diamondburned/cchat-mock v0.0.0-20200615015702-8cac8b16378d h1:LkzARyvdGRvAsaKEPTV3XcqMHENH6J+KRAI+3sq41Qs=
|
||||
github.com/diamondburned/cchat-mock v0.0.0-20200615015702-8cac8b16378d/go.mod h1:SVTt5je4G+re8aSVJAFk/x8vvbRzXdpKgSKmVGoM1tg=
|
||||
github.com/diamondburned/cchat-mock v0.0.0-20200620231423-b286a0301190 h1:mHbA/xhL584IToD38m3QkeU1cRWIPzBZCDFi1Wv0Bz4=
|
||||
github.com/diamondburned/cchat-mock v0.0.0-20200620231423-b286a0301190/go.mod h1:u4aWUu4be+JkuMtTIGJNS79T1b+8ruijVn9qL/LM4Rk=
|
||||
github.com/diamondburned/cchat-mock v0.0.0-20200628063912-3155c1b6d6a9 h1:PnVUCrLTsQlafutS13ST7292WkBpiMJzA7125q02LkA=
|
||||
github.com/diamondburned/cchat-mock v0.0.0-20200628063912-3155c1b6d6a9/go.mod h1:kKtLZzvkJdeLpiNVmwe15Bl202gfbIHC/LwWUbsSnls=
|
||||
github.com/diamondburned/cchat-mock v0.0.0-20200630025821-605d61d89288 h1:ApNV7DUyj+LG5lUxtTv4yvQZcprsDgZji0iiD+LYJmM=
|
||||
github.com/diamondburned/cchat-mock v0.0.0-20200630025821-605d61d89288/go.mod h1:Tu+8b1iz9NGeQb2jmndXn+dQ9zBUa8a8ktK9hL5aaxw=
|
||||
github.com/diamondburned/gotk3 v0.0.0-20200619213419-0533bcce0dd6 h1:ZzLrfQqszhzWI7zqwltzQIWtppfcL7m2aIEpB4kuqx0=
|
||||
github.com/diamondburned/gotk3 v0.0.0-20200619213419-0533bcce0dd6/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
|
||||
github.com/diamondburned/imgutil v0.0.0-20200611215339-650ac7cfaf64 h1:/ykUYHuYyj+NN/aaqe6lfaCZQc3EMZs93wAGVJTh5j0=
|
||||
|
|
|
@ -171,10 +171,12 @@ type Reuser interface {
|
|||
Validate(int64) bool
|
||||
}
|
||||
|
||||
type AsyncUser = func(context.Context) (interface{}, error)
|
||||
|
||||
// AsyncUse is a handler for structs that implement the Reuser primitive. The
|
||||
// passed in function will be called asynchronously, but swap will be called in
|
||||
// the Gtk main thread.
|
||||
func AsyncUse(r Reuser, swap func(interface{}), fn func(context.Context) (interface{}, error)) {
|
||||
func AsyncUse(r Reuser, swap func(interface{}), fn AsyncUser) {
|
||||
// Acquire an ID.
|
||||
id := r.Acquire()
|
||||
ctx := r.Context()
|
||||
|
|
|
@ -103,7 +103,7 @@ func (u *usernameContainer) Update(session cchat.Session, sender cchat.ServerMes
|
|||
|
||||
// Does session implement an icon? Update if yes.
|
||||
if iconer, ok := session.(cchat.Icon); ok {
|
||||
u.avatar.AsyncSetIcon(iconer.Icon, "Error fetching session icon URL")
|
||||
u.avatar.AsyncSetIconer(iconer, "Error fetching session icon URL")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import (
|
|||
"github.com/gotk3/gotk3/gtk"
|
||||
)
|
||||
|
||||
type IconerFn = func(context.Context, cchat.IconContainer) (func(), error)
|
||||
|
||||
type Icon struct {
|
||||
*gtk.Revealer
|
||||
Image *gtk.Image
|
||||
|
@ -114,17 +116,12 @@ func (i *Icon) swapResource(v interface{}) {
|
|||
i.SetIconUnsafe(v.(*nullIcon).url)
|
||||
}
|
||||
|
||||
func (i *Icon) AsyncSetIcon(fn func(context.Context, cchat.IconContainer) error, wrap string) {
|
||||
gts.AsyncUse(&i.r, i.swapResource, func(ctx context.Context) (interface{}, error) {
|
||||
var ni = &nullIcon{}
|
||||
return ni, fn(ctx, ni)
|
||||
})
|
||||
}
|
||||
|
||||
func (i *Icon) AsyncSetIconer(iconer cchat.Icon, wrap string) {
|
||||
gts.AsyncUse(&i.r, i.swapResource, func(ctx context.Context) (interface{}, error) {
|
||||
var ni = &nullIcon{}
|
||||
return ni, iconer.Icon(ctx, ni)
|
||||
ni := &nullIcon{}
|
||||
f, err := iconer.Icon(ctx, ni)
|
||||
ni.cancel = f
|
||||
return ni, err
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ type Labeler interface {
|
|||
Reset()
|
||||
}
|
||||
|
||||
type LabelerFn = func(context.Context, cchat.LabelContainer) (func(), error)
|
||||
|
||||
type Label struct {
|
||||
gtk.Label
|
||||
current text.Rich
|
||||
|
@ -62,10 +64,12 @@ func (l *Label) swapResource(v interface{}) {
|
|||
l.SetLabelUnsafe(v.(*nullLabel).Rich)
|
||||
}
|
||||
|
||||
func (l *Label) AsyncSetLabel(fn func(context.Context, cchat.LabelContainer) error, info string) {
|
||||
func (l *Label) AsyncSetLabel(fn LabelerFn, info string) {
|
||||
gts.AsyncUse(&l.r, l.swapResource, func(ctx context.Context) (interface{}, error) {
|
||||
var nl = &nullLabel{}
|
||||
return nl, fn(ctx, nl)
|
||||
nl := &nullLabel{}
|
||||
f, err := fn(ctx, nl)
|
||||
nl.cancel = f
|
||||
return nl, err
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,17 @@ func MakeRed(content text.Rich) string {
|
|||
}
|
||||
|
||||
// used for grabbing text without changing state
|
||||
type nullLabel struct{ text.Rich }
|
||||
type nullLabel struct {
|
||||
text.Rich
|
||||
cancel func()
|
||||
}
|
||||
|
||||
func (n *nullLabel) SetLabel(t text.Rich) { n.Rich = t }
|
||||
|
||||
// used for grabbing url without changing state
|
||||
type nullIcon struct{ url string }
|
||||
type nullIcon struct {
|
||||
url string
|
||||
cancel func()
|
||||
}
|
||||
|
||||
func (i *nullIcon) SetIcon(url string) { i.url = url }
|
||||
|
|
Loading…
Reference in a new issue