ui changes
This commit is contained in:
62
main.go
62
main.go
@@ -20,7 +20,6 @@ import (
|
||||
_ "embed"
|
||||
"encoding/xml"
|
||||
"runtime"
|
||||
|
||||
)
|
||||
|
||||
var loadedConfig lambdaConfig
|
||||
@@ -48,7 +47,7 @@ var uiQueue = make(chan func(), 100)
|
||||
// stores members of mucs
|
||||
var mucmembers sync.Map
|
||||
|
||||
// stores devices of users
|
||||
// stores devices of users
|
||||
var userdevices sync.Map
|
||||
|
||||
func init() {
|
||||
@@ -181,7 +180,6 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var mu MucUser
|
||||
var ocu OccupantID
|
||||
|
||||
@@ -206,24 +204,44 @@ func main() {
|
||||
typed_unit.Members.Store(ocu.ID, presence)
|
||||
} else {
|
||||
typed_unit.Members.Delete(ocu.ID)
|
||||
glib.IdleAdd(func() {
|
||||
uiQueue <- func() {
|
||||
b := gtk.NewLabel("")
|
||||
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
||||
if ok {
|
||||
b = ba
|
||||
}
|
||||
|
||||
tab, ok := tabs.Load(muc)
|
||||
typed_tab := tab.(*chatTab)
|
||||
|
||||
if ok {
|
||||
typed_tab.msgs.Append(b)
|
||||
scrollToBottomAfterUpdate(scroller)
|
||||
} else {
|
||||
fmt.Println("Got message when the tab does not exist!")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
mucmembers.Store(muc, typed_unit)
|
||||
|
||||
} else { // This is a presence stanza from a regular user
|
||||
// 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
|
||||
user := jid.MustParse(presence.From).Bare().String()
|
||||
_, ok := userdevices.Load(user)
|
||||
if !ok {
|
||||
_, mok := mucmembers.Load(user)
|
||||
if !ok && !mok { // FIXME: The initial muc presence gets picked up from this check
|
||||
userdevices.Store(user, userUnit{})
|
||||
createTab(user, false)
|
||||
|
||||
b := gtk.NewButtonWithLabel(user)
|
||||
b.ConnectClicked(func() {
|
||||
b.AddCSSClass("accent")
|
||||
switchToTab(user)
|
||||
})
|
||||
menu.Append(b)
|
||||
b := gtk.NewButtonWithLabel(user)
|
||||
b.ConnectClicked(func() {
|
||||
b.AddCSSClass("accent")
|
||||
switchToTab(user)
|
||||
})
|
||||
menu.Append(b)
|
||||
}
|
||||
|
||||
unit, ok := userdevices.Load(user)
|
||||
@@ -291,7 +309,7 @@ func activate(app *gtk.Application) {
|
||||
|
||||
window.SetTitle("Lambda")
|
||||
window.Window.AddCSSClass("ssd")
|
||||
menu = gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
menu = gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
/*
|
||||
f_menu := gtk.NewMenuButton()
|
||||
f_menu.SetLabel("File")
|
||||
@@ -333,12 +351,22 @@ func activate(app *gtk.Application) {
|
||||
// scroller.SetChild(empty_dialog)
|
||||
scroller.SetChild(empty_dialog)
|
||||
menu_scroll := gtk.NewScrolledWindow()
|
||||
menu_scroll.SetHExpand(true)
|
||||
|
||||
menu_scroll.SetChild(menu)
|
||||
box.Append(menu_scroll)
|
||||
// box.Append(menu_scroll)
|
||||
|
||||
chatbox := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
chatbox.Append(scroller)
|
||||
chatbox.Append(memberList)
|
||||
// chatbox.Append(menu_scroll)
|
||||
chat_pane := gtk.NewPaned(gtk.OrientationHorizontal)
|
||||
chat_pane.SetStartChild(scroller)
|
||||
chat_pane.SetEndChild(memberList)
|
||||
|
||||
main_pane := gtk.NewPaned(gtk.OrientationHorizontal)
|
||||
main_pane.SetStartChild(menu_scroll)
|
||||
main_pane.SetEndChild(chat_pane)
|
||||
|
||||
chatbox.Append(main_pane)
|
||||
box.Append(chatbox)
|
||||
|
||||
entry_box := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
@@ -365,8 +393,8 @@ func activate(app *gtk.Application) {
|
||||
|
||||
typed_tab := tab.(*chatTab)
|
||||
if typed_tab.isMuc {
|
||||
message_type = stanza.MessageTypeGroupchat
|
||||
}
|
||||
message_type = stanza.MessageTypeGroupchat
|
||||
}
|
||||
|
||||
err := sendMessage(client, current, message_type, t, "", "")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user