Add hat icon, change some CSS and remove all reply support

This commit is contained in:
2026-02-08 09:44:45 +00:00
parent 589101c292
commit 713cb24508
7 changed files with 118 additions and 74 deletions

View File

@@ -2,6 +2,8 @@ package main
import (
"context"
"crypto/sha1"
"encoding/hex"
"fmt"
"github.com/diamondburned/gotk4/pkg/glib/v2"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
@@ -75,17 +77,17 @@ func switchToTab(jid string, w *gtk.Window) {
nick_label := gtk.NewLabel(JidMustParse(u.From).Resource)
nick_label.SetEllipsize(pango.EllipsizeEnd)
/*
affil_label := gtk.NewLabel("")
switch mu.MucUserItem.Affiliation {
case "owner":
affil_label.SetText("O")
case "admin":
affil_label.SetText("A")
case "member":
affil_label.SetText("M")
case "none":
affil_label.SetText("-")
}
affil_label := gtk.NewLabel("")
switch mu.MucUserItem.Affiliation {
case "owner":
affil_label.SetText("O")
case "admin":
affil_label.SetText("A")
case "member":
affil_label.SetText("M")
case "none":
affil_label.SetText("-")
}
*/
nick_label.AddCSSClass(mu.MucUserItem.Role)
@@ -94,22 +96,39 @@ func switchToTab(jid string, w *gtk.Window) {
}
/*
affil_label.SetHAlign(gtk.AlignEnd)
affil_label.SetHExpand(true)
affil_label.SetHAlign(gtk.AlignEnd)
affil_label.SetHExpand(true)
affil_label.AddCSSClass(mu.MucUserItem.Affiliation)
affil_label.AddCSSClass(mu.MucUserItem.Affiliation)
*/
userbox.SetTooltipText(fmt.Sprintf("%s\n%s\n%s\nRight-click for more information", u.From, mu.MucUserItem.Role, mu.MucUserItem.Affiliation))
userbox.Append(nick_label)
// userbox.Append(affil_label)
var hats Hats
ok := u.Get(&hats)
if ok {
for _, hat := range hats.Hats {
tag := gtk.NewImageFromPaintable(clientAssets["tag"])
tag.SetTooltipText(hat.Title)
// tag.SetHAlign(gtk.AlignEnd)
// tag.SetHExpand(true)
userbox.Prepend(tag)
}
}
medal := gtk.NewImageFromPaintable(clientAssets[mu.MucUserItem.Affiliation])
medal.SetTooltipText(mu.MucUserItem.Affiliation)
medal.SetHAlign(gtk.AlignEnd)
medal.SetHExpand(true)
userbox.Append(medal)
gesture := gtk.NewGestureClick()
gesture.SetButton(3) // Right click
@@ -143,7 +162,9 @@ func switchToTab(jid string, w *gtk.Window) {
ok := u.Get(&hats)
if ok {
for _, hat := range hats.Hats {
profile_box.Append(gtk.NewLabel(hat.Title))
l := gtk.NewLabel(hat.Title)
l.AddCSSClass("hat")
profile_box.Append(l)
}
}
@@ -157,6 +178,43 @@ func switchToTab(jid string, w *gtk.Window) {
profile_box.Append(gtk.NewLabel("Affiliated as " + mu.MucUserItem.Affiliation))
}
go func() {
fmt.Println("Attempting to get Disco info")
myIQ, err := stanza.NewIQ(stanza.Attrs{
Type: "get",
From: clientroot.Session.BindJid,
To: u.From,
Id: "dicks",
Lang: "en",
})
if err != nil {
panic(err)
}
myIQ.Payload = &stanza.DiscoInfo{}
ctx := context.TODO()
mychan, err := client.SendIQ(ctx, myIQ)
if err == nil {
result := <-mychan
res, ok := result.Payload.(*stanza.DiscoInfo)
if ok {
idents := res.Identity
for i, ident := range idents {
profile_box.Append(gtk.NewLabel(fmt.Sprintf("Identity %d: Name: %s, Category: %s, Type: %s", i+1, ident.Name, ident.Category, ident.Type)))
}
s := fmt.Sprintf("%v", res.Features)
h := sha1.New()
h.Write([]byte(s))
sha1_hash := hex.EncodeToString(h.Sum(nil))
profile_box.Append(gtk.NewLabel(fmt.Sprintf("The hash of this user's Disco features is:\n%s\nUse the disco feature to view them", sha1_hash)))
}
}
}()
go func() {
ctx := context.TODO()
mychan, err := client.SendIQ(ctx, iqResp)
@@ -169,9 +227,7 @@ func switchToTab(jid string, w *gtk.Window) {
version := ver.Version
os := ver.OS
profile_box.Append(gtk.NewLabel(name))
profile_box.Append(gtk.NewLabel(version))
profile_box.Append(gtk.NewLabel(os))
profile_box.Append(gtk.NewLabel(fmt.Sprintf("%s %s %s", name, version, os)))
}
}
}()