This commit is contained in:
2026-05-18 06:27:55 +01:00
parent 98cd855349
commit 5f95df147f
4 changed files with 70 additions and 20 deletions
+19 -3
View File
@@ -201,6 +201,13 @@ func switchToTab(jid string, w *gtk.Window) {
// medal.SetHExpand(true)
userbox.Prepend(status)
if u.Status != "" {
status_message := gtk.NewImageFromPaintable(clientAssets["comment"])
status_message.SetTooltipText(u.Status)
status_message.SetHAlign(gtk.AlignEnd)
userbox.Append(status_message)
}
medal := gtk.NewImageFromPaintable(clientAssets[mu.MucUserItem.Affiliation])
medal.SetTooltipText(mu.MucUserItem.Affiliation)
@@ -208,6 +215,7 @@ func switchToTab(jid string, w *gtk.Window) {
medal.SetHExpand(true)
userbox.Append(medal)
default_av := createIdenticon(u.From, false)
userbox.Prepend(default_av)
var vcu VCardUpdate
@@ -560,9 +568,17 @@ func switchToTab(jid string, w *gtk.Window) {
headerBox.Append(gtk.NewLabel(fmt.Sprintf("%d %s", i, loadedLocale["participants"])))
gen.Prepend(headerBox)
muci := getAvatar(jid, jid)
muci.SetPixelSize(80)
gen.Prepend(muci)
muc_presence := typed_tab.muc_presence
if muc_presence != nil {
vc := &VCardUpdate{}
ok = muc_presence.Get(vc)
if ok {
muci := getAvatar(jid, vc.Photo)
muci.SetPixelSize(80)
gen.Prepend(muci)
}
}
muc_name := gtk.NewLabel(typed_tab.name)
muc_name.AddCSSClass("author")
muc_name.SetWrap(true)
+38 -10
View File
@@ -105,11 +105,9 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
reactions := gtk.NewBox(gtk.OrientationHorizontal, 0)
reaction := []string{"👍", "👎", "♥️", "🤣", "💀"}
for _, v := range reaction {
like := gtk.NewButton()
like.SetLabel(v)
like := gtk.NewButtonWithLabel(v)
like.SetHExpand(true)
like.ConnectClicked(func() {
fmt.Println("licked") // TODO: Implement proper support for reactions via extension
client.SendRaw(fmt.Sprintf(`
<message from='%s' to='%s' id='%s' type='%s'>
<reactions id='%s' xmlns='urn:xmpp:reactions:0'>
@@ -122,6 +120,24 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
}
rc_box.Append(reactions)
custom := gtk.NewEntry()
custom.SetPlaceholderText("...")
enter_custom := gtk.NewButtonWithLabel("React")
enter_custom.SetLabel("React")
enter_custom.SetHExpand(true)
enter_custom.ConnectClicked(func() {
client.SendRaw(fmt.Sprintf(`
<message from='%s' to='%s' id='%s' type='%s'>
<reactions id='%s' xmlns='urn:xmpp:reactions:0'>
<reaction>%s</reaction>
</reactions>
</message>
`, m.To, jid.MustParse(m.From).Bare().String(), uuid.New().String(), m.Type, sid.ID, custom.Text()))
})
rc_box.Append(custom)
rc_box.Append(enter_custom)
quote := gtk.NewButtonWithLabel("Quote")
quote.ConnectClicked(func() {
@@ -149,13 +165,14 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
m.Get(&ocu)
id := JidMustParse(m.From).Resource
name := id
custom_nick, ok := loadedConfig.CustomNicks[ocu.ID]
if ok {
id = custom_nick
name = custom_nick
}
if id == "" {
id = JidMustParse(m.From).Bare()
if name == "" {
name = JidMustParse(m.From).Bare()
}
if loadedConfig.CompactMode {
@@ -183,16 +200,27 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
authorBox := gtk.NewBox(gtk.OrientationHorizontal, 10)
contentBox := gtk.NewBox(gtk.OrientationHorizontal, 0)
al := gtk.NewLabel(id)
al := gtk.NewLabel(name)
al.AddCSSClass("author")
al.SetSelectable(true)
if m.Type == stanza.MessageTypeGroupchat {
mo, _ := mucmembers.Load(JidMustParse(m.From).Bare())
mm := mo.(mucUnit)
can_generate := true
mo, ok := mucmembers.Load(JidMustParse(m.From).Bare())
if !ok {
can_generate = false
}
mm, ok := mo.(mucUnit)
if !ok {
can_generate = false
}
mmm := mm.Members
mmmm, ok := mmm.Load(id)
if ok {
if !ok {
can_generate = false
}
if can_generate {
pres := mmmm.(stanza.Presence)
var vu VCardUpdate
pres.Get(&vu)
+11 -7
View File
@@ -14,9 +14,9 @@ import (
"github.com/diamondburned/gotk4/pkg/gtk/v4"
"github.com/gen2brain/beeep"
"github.com/go-analyze/charts"
"github.com/google/uuid"
"golang.org/x/net/html/charset"
"path/filepath"
"github.com/google/uuid"
"github.com/BurntSushi/toml"
"gosrc.io/xmpp"
@@ -216,12 +216,6 @@ func main() {
fmt.Println(e)
}
/*
if m.Body == "" {
return
}
*/
originator := JidMustParse(m.From).Bare()
glib.IdleAdd(func() {
mStatus.SetText(originator)
@@ -411,6 +405,16 @@ func main() {
// The code is basically the exact same as above, we just don't check for mucuser
// TODO: Presence handling code goes here
j := presence.From
tab, ok := tabs.Load(j)
if ok {
typed_tab, ok := tab.(*chatTab)
if ok {
if typed_tab.isMuc {
typed_tab.muc_presence = &presence
}
}
}
}
})
+2
View File
@@ -4,6 +4,7 @@ import (
"github.com/diamondburned/gotk4/pkg/gtk/v4"
"mellium.im/xmpp/color"
"sync"
"gosrc.io/xmpp/stanza"
)
type chatTab struct {
@@ -11,6 +12,7 @@ type chatTab struct {
msgs *gtk.ListBox
name string
current_nick string
muc_presence *stanza.Presence
}
type lambdaConfig struct {