some qol stuff

This commit is contained in:
2026-05-10 14:46:19 +01:00
parent 1aa14f9fd5
commit 98cd855349
8 changed files with 66 additions and 6 deletions
+4
View File
@@ -143,6 +143,9 @@ var jabberBytes []byte
//go:embed assets/fail.png
var failBytes []byte
//go:embed assets/please_wait.gif
var pleaseWaitBytes []byte
func loadAsset(key string, data []byte) {
loader := gdkpixbuf.NewPixbufLoader()
loader.Write(data)
@@ -197,6 +200,7 @@ func init() {
"moderate": moderateBytes,
"jabber": jabberBytes,
"fail": failBytes,
"please_wait": pleaseWaitBytes,
} {
loadAsset(key, data)
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

+17
View File
@@ -136,9 +136,11 @@ func switchToTab(jid string, w *gtk.Window) {
u.Get(&ocu)
if mu.MucUserItem.Role == "moderator" {
gen.Prepend(gtk.NewSeparator(gtk.OrientationHorizontal))
gen.Prepend(userbox)
} else {
gen.Append(userbox)
gen.Append(gtk.NewSeparator(gtk.OrientationHorizontal))
}
//id := ocu.ID
@@ -147,6 +149,10 @@ func switchToTab(jid string, w *gtk.Window) {
//}
nick_label := gtk.NewLabel(JidMustParse(u.From).Resource)
custom_nick, ok := loadedConfig.CustomNicks[ocu.ID]
if ok {
nick_label.SetText(custom_nick)
}
nick_label.SetEllipsize(pango.EllipsizeEnd)
nick_label.AddCSSClass(mu.MucUserItem.Role)
if mu.MucUserItem.Role == "visitor" {
@@ -366,6 +372,10 @@ func switchToTab(jid string, w *gtk.Window) {
win.SetDefaultSize(400, 400)
profile_box := gtk.NewBox(gtk.OrientationVertical, 0)
nick := gtk.NewLabel(JidMustParse(u.From).Resource)
if custom_nick != "" {
nick.SetText(custom_nick)
}
ver_text := gtk.NewLabel(loadedLocale["gettingVersion"])
ver_text.AddCSSClass("visitor")
@@ -418,6 +428,13 @@ func switchToTab(jid string, w *gtk.Window) {
profile_box.Append(gtk.NewLabel(loadedLocale["affiliatedAs"] + mu.MucUserItem.Affiliation))
}
if ocu.ID != "" {
ocu_label := gtk.NewLabel(ocu.ID)
ocu_label.AddCSSClass("jid")
ocu_label.SetSelectable(true)
profile_box.Append(ocu_label)
}
go func() {
myIQ, err := stanza.NewIQ(stanza.Attrs{
+10 -5
View File
@@ -149,6 +149,14 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
m.Get(&ocu)
id := JidMustParse(m.From).Resource
custom_nick, ok := loadedConfig.CustomNicks[ocu.ID]
if ok {
id = custom_nick
}
if id == "" {
id = JidMustParse(m.From).Bare()
}
if loadedConfig.CompactMode {
al := gtk.NewLabel(id)
@@ -174,11 +182,8 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
} else {
authorBox := gtk.NewBox(gtk.OrientationHorizontal, 10)
contentBox := gtk.NewBox(gtk.OrientationHorizontal, 0)
n := JidMustParse(m.From).Resource
if n == "" {
n = JidMustParse(m.From).Resource
}
al := gtk.NewLabel(n)
al := gtk.NewLabel(id)
al.AddCSSClass("author")
al.SetSelectable(true)
+6 -1
View File
@@ -16,6 +16,7 @@ import (
"github.com/go-analyze/charts"
"golang.org/x/net/html/charset"
"path/filepath"
"github.com/google/uuid"
"github.com/BurntSushi/toml"
"gosrc.io/xmpp"
@@ -176,6 +177,8 @@ func main() {
{Var: "http://jabber.org/protocol/muc"},
{Var: "λ"},
{Var: "urn:xmpp:attention:0"},
{Var: "urn:xmpp:carbons:2"},
{Var: "urn:xmpp:ping"},
},
}
iqResp.Payload = &payload
@@ -433,9 +436,10 @@ func main() {
pingStatus.AddCSSClass("pending")
before := time.Now()
iq := new(stanza.IQ)
iq.Id = uuid.New().String()
iq.From = clientroot.Session.BindJid
iq.To = iq.From
iq.Type = "get"
iq.Payload = &Ping{}
ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
mychan, err := client.SendIQ(ctx, iq)
@@ -1161,6 +1165,7 @@ func activate(app *gtk.Application) {
i := (gtk.NewImageFromPaintable(clientAssets["chart_bar"]))
i.AddCSSClass("icon")
pBox.Append(i)
pingStatus = gtk.NewLabel("...")
pBox.Append(pingStatus)
+1
View File
@@ -26,6 +26,7 @@ type lambdaConfig struct {
Debug bool
ShowPresenceUpdates bool
CompactMode bool
CustomNicks map[string]string
}
type mucUnit struct {
+27
View File
@@ -0,0 +1,27 @@
package main
// Implementation of XEP-0199: XMPP Ping
// https://xmpp.org/extensions/xep-0199.html
import (
"encoding/xml"
"gosrc.io/xmpp/stanza"
)
type Ping struct {
stanza.IQ
XMLName xml.Name `xml:"urn:xmpp:ping ping"`
ResultSet *stanza.ResultSet `xml:"set,omitempty"`
}
func (v *Ping) Namespace() string {
return v.XMLName.Space
}
func (v *Ping) GetSet() *stanza.ResultSet {
return v.ResultSet
}
func init() {
stanza.TypeRegistry.MapExtension(stanza.PKTIQ, xml.Name{Space: "urn:xmpp:ping", Local: "ping"}, Ping{})
}
+1
View File
@@ -51,3 +51,4 @@ func init() {
stanza.TypeRegistry.MapExtension(stanza.PKTIQ, xml.Name{Space: "vcard-temp", Local: "vCard"}, VCard{})
stanza.TypeRegistry.MapExtension(stanza.PKTPresence, xml.Name{Space: "vcard-temp:x:update", Local: "x"}, VCardUpdate{})
}