this commit was sponsored by mizkif

This commit is contained in:
2026-07-14 16:25:18 +01:00
parent 7c19abb6ae
commit ede81d551c
6 changed files with 84 additions and 11 deletions
+4
View File
@@ -150,6 +150,9 @@ var pleaseWaitBytes []byte
//go:embed assets/update.png
var updateBytes []byte
//go:embed assets/solar.png
var solarBytes []byte
// var clientAssets map[string]gdk.Paintabler = make(map[string]gdk.Paintabler)
var clientAssets sync.Map
@@ -223,6 +226,7 @@ func init() {
"fail": failBytes,
"please_wait": pleaseWaitBytes,
"update": updateBytes,
"solar": solarBytes,
} {
loadAsset(key, data)
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

+4 -1
View File
@@ -573,7 +573,10 @@ func switchToTab(jid string, w *gtk.Window) {
}))
headerBox := gtk.NewBox(gtk.OrientationHorizontal, 0)
if i >= 500 {
if i >= 1000 {
headerBox.Append(gtk.NewImageFromPaintable(clientAssetsLoad("solar")))
} else if i >= 500 {
headerBox.Append(gtk.NewImageFromPaintable(clientAssetsLoad("world")))
} else if i >= 50 {
headerBox.Append(gtk.NewImageFromPaintable(clientAssetsLoad("large_group")))
+50 -9
View File
@@ -362,9 +362,9 @@ func main() {
}
tab, ok := tabs.Load(muc)
typed_tab := tab.(*chatTab)
typed_tab, ok2 := tab.(*chatTab)
if ok {
if ok && ok2 {
typed_tab.msgs.Append(b)
if current == muc {
scrollToBottomAfterUpdate(scroller)
@@ -1171,6 +1171,7 @@ func activate(app *gtk.Application) {
i := gtk.NewPictureForPaintable(gdk.NewTextureForPixbuf(loader.Pixbuf()))
win := gtk.NewWindow()
win.SetDefaultSize(600, 400)
win.SetResizable(false)
win.SetTitle(loadedLocale["pingGraphTitle"])
box := gtk.NewBox(gtk.OrientationVertical, 0)
box.Append(i)
@@ -1236,13 +1237,6 @@ func activate(app *gtk.Application) {
sendtxt := func() {
t := message_en.Text()
if t == "" {
dialog := &gtk.AlertDialog{}
dialog.SetDetail("detail")
dialog.SetMessage("message")
dialog.SetButtons([]string{"yes, no"})
dialog.Choose(context.TODO(), &window.Window, nil)
}
message_type := stanza.MessageTypeChat
tab, ok := tabs.Load(current)
@@ -1253,6 +1247,51 @@ func activate(app *gtk.Application) {
typed_tab := tab.(*chatTab)
if typed_tab.isMuc {
message_type = stanza.MessageTypeGroupchat
// First check if the user is a visitor
mu, ok := mucmembers.Load(current)
if ok {
typed_mu := mu.(mucUnit)
typed_mu.Members.Range(func(k, v any) bool {
user, ok := v.(stanza.Presence)
if ok {
var mui MucUser
ok = user.Get(&mui)
if ok && mui.MucUserItem.JID != "" {
if JidMustParse(mui.MucUserItem.JID).Bare() == JidMustParse(clientroot.Session.BindJid).Bare() {
if mui.MucUserItem.Role == "visitor" {
win := gtk.NewWindow()
win.SetDefaultSize(1,1)
box := gtk.NewBox(gtk.OrientationVertical, 5)
txt := gtk.NewLabel("You are a visitor and do not have voice.\nWould you like to request voice from the moderators of this MUC?")
btn := gtk.NewButtonWithLabel("Request voice")
btn.ConnectClicked(func (){
sendVoiceRequest(client, current)
win.SetVisible(false)
})
dismiss := gtk.NewButtonWithLabel("Dismiss")
dismiss.ConnectClicked(func() {
win.SetVisible(false)
})
box.Append(txt)
box.Append(btn)
box.Append(dismiss)
win.SetChild(box)
win.SetResizable(false)
win.SetVisible(true)
}
return false
}
}
}
return true
})
}
}
exts := []stanza.MsgExtension{}
@@ -1278,6 +1317,8 @@ func activate(app *gtk.Application) {
exts = append(exts, new_attention)
}
err := sendMessage(client, current, message_type, t, "", "", exts)
if err != nil {
showErrorDialog(err, &window.Window)
+1 -1
View File
@@ -1,3 +1,3 @@
package main
var lambda_version string = "1"
var lambda_version string = "2"
+25
View File
@@ -3,6 +3,7 @@ package main
import (
"gosrc.io/xmpp"
"gosrc.io/xmpp/stanza"
"fmt"
)
// This file has small functions that can be used to do XMPP stuff without writing tons of boilerplate
@@ -116,3 +117,27 @@ func JidMustParse(s string) *stanza.Jid {
}
return j
}
func sendVoiceRequest(c xmpp.Sender, sendTo string) error {
err := c.SendRaw(fmt.Sprintf(`
<message from='%s'
id='yd53c486'
to='%s'>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE'>
<value>http://jabber.org/protocol/muc#request</value>
</field>
<field var='muc#role'
type='list-single'
label='Requested role'>
<value>participant</value>
</field>
</x>
</message>
`, clientroot.Session.BindJid, sendTo))
if err != nil {
return err
}
return nil
}