Add experimental hats support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/diamondburned/gotk4/pkg/glib/v2"
|
||||
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||
@@ -60,6 +61,94 @@ func switchToTab(jid string) {
|
||||
|
||||
userbox.Append(nick_label)
|
||||
|
||||
gesture := gtk.NewGestureClick()
|
||||
gesture.SetButton(3) // Right click
|
||||
|
||||
gesture.Connect("pressed", func(n_press, x, y int) {
|
||||
win := gtk.NewWindow()
|
||||
win.SetDefaultSize(400, 400)
|
||||
profile_box := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
nick := gtk.NewLabel(Jid.MustParse(u.From).Resourcepart())
|
||||
nick.AddCSSClass("author")
|
||||
profile_box.Append(nick)
|
||||
profile_box.Append(gtk.NewLabel(u.From))
|
||||
|
||||
iqResp, err := stanza.NewIQ(stanza.Attrs{
|
||||
Type: "get",
|
||||
From: clientroot.Session.BindJid,
|
||||
To: u.From,
|
||||
Id: "vc2",
|
||||
Lang: "en",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
iqResp.Payload = &stanza.Version{}
|
||||
loading_version_text := gtk.NewLabel("...")
|
||||
|
||||
var hats Hats
|
||||
ok := u.Get(&hats)
|
||||
if ok {
|
||||
for _, hat := range hats.Hats {
|
||||
profile_box.Append(gtk.NewLabel(hat.Title))
|
||||
}
|
||||
}
|
||||
|
||||
go func() {
|
||||
ctx := context.TODO()
|
||||
mychan, err := client.SendIQ(ctx, iqResp)
|
||||
if err == nil {
|
||||
result := <-mychan
|
||||
ver, ok := result.Payload.(*stanza.Version)
|
||||
if ok {
|
||||
loading_version_text.SetVisible(false)
|
||||
name := ver.Name
|
||||
version := ver.Version
|
||||
os := ver.OS
|
||||
|
||||
profile_box.Append(gtk.NewLabel(name))
|
||||
profile_box.Append(gtk.NewLabel(version))
|
||||
profile_box.Append(gtk.NewLabel(os))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
mo, _ := mucmembers.Load(Jid.MustParse(u.From).Bare().String())
|
||||
mm := mo.(mucUnit)
|
||||
mmm := mm.Members
|
||||
mmmm, ok := mmm.Load(ocu.ID)
|
||||
if ok {
|
||||
pres := mmmm.(stanza.Presence)
|
||||
|
||||
var vu VCardUpdate
|
||||
pres.Get(&vu)
|
||||
if vu.Photo != "" {
|
||||
im := getAvatar(u.From, vu.Photo)
|
||||
im.SetPixelSize(80)
|
||||
im.AddCSSClass("author_img")
|
||||
profile_box.Append(im)
|
||||
} else {
|
||||
im := newImageFromPath("debug.png")
|
||||
im.SetPixelSize(80)
|
||||
im.AddCSSClass("author_img")
|
||||
profile_box.Append(im)
|
||||
}
|
||||
} else {
|
||||
im := newImageFromPath("debug.png")
|
||||
im.SetPixelSize(80)
|
||||
im.AddCSSClass("author_img")
|
||||
profile_box.Append(im)
|
||||
}
|
||||
}()
|
||||
|
||||
win.SetChild(profile_box)
|
||||
win.Present()
|
||||
})
|
||||
userbox.AddController(gesture)
|
||||
|
||||
gen.Append(userbox)
|
||||
return true
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user