remove some occurences of mellium jid lib and try to add experimental affiliation displays
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/diamondburned/gotk4/pkg/glib/v2"
|
||||
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||
"gosrc.io/xmpp/stanza"
|
||||
Jid "mellium.im/xmpp/jid"
|
||||
)
|
||||
|
||||
func scrollToBottomAfterUpdate(scrolledWindow *gtk.ScrolledWindow) {
|
||||
@@ -17,7 +16,7 @@ func scrollToBottomAfterUpdate(scrolledWindow *gtk.ScrolledWindow) {
|
||||
})
|
||||
}
|
||||
|
||||
func createTab(jid string, isMuc bool) {
|
||||
func createTab(jid string, isMuc bool) bool {
|
||||
fmt.Println("Creating tab", jid, "isMuc:", isMuc)
|
||||
_, ok := tabs.Load(jid)
|
||||
if !ok {
|
||||
@@ -29,7 +28,10 @@ func createTab(jid string, isMuc bool) {
|
||||
|
||||
newTab.msgs.Append(gtk.NewButtonWithLabel("Get past messages..."))
|
||||
tabs.Store(jid, newTab)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func switchToTab(jid string, w *gtk.Window) {
|
||||
@@ -57,10 +59,27 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
u.Get(&mu)
|
||||
u.Get(&ocu)
|
||||
|
||||
nick_label := gtk.NewLabel(Jid.MustParse(u.From).Resourcepart())
|
||||
nick_label := gtk.NewLabel(JidMustParse(u.From).Resource)
|
||||
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.SetHAlign(gtk.AlignEnd)
|
||||
affil_label.SetHExpand(true)
|
||||
|
||||
|
||||
affil_label.AddCSSClass(mu.MucUserItem.Affiliation)
|
||||
|
||||
userbox.Append(nick_label)
|
||||
|
||||
userbox.Append(affil_label)
|
||||
|
||||
gesture := gtk.NewGestureClick()
|
||||
gesture.SetButton(3) // Right click
|
||||
|
||||
@@ -68,7 +87,7 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
win := gtk.NewWindow()
|
||||
win.SetDefaultSize(400, 400)
|
||||
profile_box := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
nick := gtk.NewLabel(Jid.MustParse(u.From).Resourcepart())
|
||||
nick := gtk.NewLabel(JidMustParse(u.From).Resource)
|
||||
nick.AddCSSClass("author")
|
||||
profile_box.Append(nick)
|
||||
profile_box.Append(gtk.NewLabel(u.From))
|
||||
@@ -96,6 +115,14 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
}
|
||||
}
|
||||
|
||||
var mu MucUser
|
||||
ok = u.Get(&mu)
|
||||
if ok {
|
||||
if mu.MucUserItem.JID != "" {
|
||||
profile_box.Append(gtk.NewLabel(mu.MucUserItem.JID))
|
||||
}
|
||||
}
|
||||
|
||||
go func() {
|
||||
ctx := context.TODO()
|
||||
mychan, err := client.SendIQ(ctx, iqResp)
|
||||
@@ -116,7 +143,7 @@ func switchToTab(jid string, w *gtk.Window) {
|
||||
}()
|
||||
|
||||
go func() {
|
||||
mo, _ := mucmembers.Load(Jid.MustParse(u.From).Bare().String())
|
||||
mo, _ := mucmembers.Load(JidMustParse(u.From).Bare())
|
||||
mm := mo.(mucUnit)
|
||||
mmm := mm.Members
|
||||
mmmm, ok := mmm.Load(ocu.ID)
|
||||
|
||||
Reference in New Issue
Block a user