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) // medal.SetHExpand(true)
userbox.Prepend(status) 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 := gtk.NewImageFromPaintable(clientAssets[mu.MucUserItem.Affiliation])
medal.SetTooltipText(mu.MucUserItem.Affiliation) medal.SetTooltipText(mu.MucUserItem.Affiliation)
@@ -208,6 +215,7 @@ func switchToTab(jid string, w *gtk.Window) {
medal.SetHExpand(true) medal.SetHExpand(true)
userbox.Append(medal) userbox.Append(medal)
default_av := createIdenticon(u.From, false) default_av := createIdenticon(u.From, false)
userbox.Prepend(default_av) userbox.Prepend(default_av)
var vcu VCardUpdate 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"]))) headerBox.Append(gtk.NewLabel(fmt.Sprintf("%d %s", i, loadedLocale["participants"])))
gen.Prepend(headerBox) gen.Prepend(headerBox)
muci := getAvatar(jid, jid) muc_presence := typed_tab.muc_presence
muci.SetPixelSize(80) if muc_presence != nil {
gen.Prepend(muci) 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 := gtk.NewLabel(typed_tab.name)
muc_name.AddCSSClass("author") muc_name.AddCSSClass("author")
muc_name.SetWrap(true) 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) reactions := gtk.NewBox(gtk.OrientationHorizontal, 0)
reaction := []string{"👍", "👎", "♥️", "🤣", "💀"} reaction := []string{"👍", "👎", "♥️", "🤣", "💀"}
for _, v := range reaction { for _, v := range reaction {
like := gtk.NewButton() like := gtk.NewButtonWithLabel(v)
like.SetLabel(v)
like.SetHExpand(true) like.SetHExpand(true)
like.ConnectClicked(func() { like.ConnectClicked(func() {
fmt.Println("licked") // TODO: Implement proper support for reactions via extension
client.SendRaw(fmt.Sprintf(` client.SendRaw(fmt.Sprintf(`
<message from='%s' to='%s' id='%s' type='%s'> <message from='%s' to='%s' id='%s' type='%s'>
<reactions id='%s' xmlns='urn:xmpp:reactions:0'> <reactions id='%s' xmlns='urn:xmpp:reactions:0'>
@@ -122,6 +120,24 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
} }
rc_box.Append(reactions) 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 := gtk.NewButtonWithLabel("Quote")
quote.ConnectClicked(func() { quote.ConnectClicked(func() {
@@ -149,13 +165,14 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
m.Get(&ocu) m.Get(&ocu)
id := JidMustParse(m.From).Resource id := JidMustParse(m.From).Resource
name := id
custom_nick, ok := loadedConfig.CustomNicks[ocu.ID] custom_nick, ok := loadedConfig.CustomNicks[ocu.ID]
if ok { if ok {
id = custom_nick name = custom_nick
} }
if id == "" { if name == "" {
id = JidMustParse(m.From).Bare() name = JidMustParse(m.From).Bare()
} }
if loadedConfig.CompactMode { if loadedConfig.CompactMode {
@@ -183,16 +200,27 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
authorBox := gtk.NewBox(gtk.OrientationHorizontal, 10) authorBox := gtk.NewBox(gtk.OrientationHorizontal, 10)
contentBox := gtk.NewBox(gtk.OrientationHorizontal, 0) contentBox := gtk.NewBox(gtk.OrientationHorizontal, 0)
al := gtk.NewLabel(id) al := gtk.NewLabel(name)
al.AddCSSClass("author") al.AddCSSClass("author")
al.SetSelectable(true) al.SetSelectable(true)
if m.Type == stanza.MessageTypeGroupchat { if m.Type == stanza.MessageTypeGroupchat {
mo, _ := mucmembers.Load(JidMustParse(m.From).Bare()) can_generate := true
mm := mo.(mucUnit) 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 mmm := mm.Members
mmmm, ok := mmm.Load(id) mmmm, ok := mmm.Load(id)
if ok { if !ok {
can_generate = false
}
if can_generate {
pres := mmmm.(stanza.Presence) pres := mmmm.(stanza.Presence)
var vu VCardUpdate var vu VCardUpdate
pres.Get(&vu) pres.Get(&vu)
+11 -7
View File
@@ -14,9 +14,9 @@ import (
"github.com/diamondburned/gotk4/pkg/gtk/v4" "github.com/diamondburned/gotk4/pkg/gtk/v4"
"github.com/gen2brain/beeep" "github.com/gen2brain/beeep"
"github.com/go-analyze/charts" "github.com/go-analyze/charts"
"github.com/google/uuid"
"golang.org/x/net/html/charset" "golang.org/x/net/html/charset"
"path/filepath" "path/filepath"
"github.com/google/uuid"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
"gosrc.io/xmpp" "gosrc.io/xmpp"
@@ -216,12 +216,6 @@ func main() {
fmt.Println(e) fmt.Println(e)
} }
/*
if m.Body == "" {
return
}
*/
originator := JidMustParse(m.From).Bare() originator := JidMustParse(m.From).Bare()
glib.IdleAdd(func() { glib.IdleAdd(func() {
mStatus.SetText(originator) 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 // The code is basically the exact same as above, we just don't check for mucuser
// TODO: Presence handling code goes here // 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" "github.com/diamondburned/gotk4/pkg/gtk/v4"
"mellium.im/xmpp/color" "mellium.im/xmpp/color"
"sync" "sync"
"gosrc.io/xmpp/stanza"
) )
type chatTab struct { type chatTab struct {
@@ -11,6 +12,7 @@ type chatTab struct {
msgs *gtk.ListBox msgs *gtk.ListBox
name string name string
current_nick string current_nick string
muc_presence *stanza.Presence
} }
type lambdaConfig struct { type lambdaConfig struct {