ui changes
This commit is contained in:
@@ -16,6 +16,19 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func generatePresenceWidget(p stanza.Packet) gtk.Widgetter {
|
||||
presence, ok := p.(stanza.Presence)
|
||||
if !ok {
|
||||
return gtk.NewLabel("Unsupported message.")
|
||||
}
|
||||
|
||||
if presence.Type == stanza.PresenceTypeUnavailable {
|
||||
return gtk.NewLabel(jid.MustParse(presence.From).Resourcepart() + " left the room")
|
||||
} else {
|
||||
return gtk.NewLabel(jid.MustParse(presence.From).Resourcepart() + " joined the room")
|
||||
}
|
||||
}
|
||||
|
||||
func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
|
||||
m, ok := p.(stanza.Message)
|
||||
if !ok {
|
||||
|
||||
54
main.go
54
main.go
@@ -20,7 +20,6 @@ import (
|
||||
_ "embed"
|
||||
"encoding/xml"
|
||||
"runtime"
|
||||
|
||||
)
|
||||
|
||||
var loadedConfig lambdaConfig
|
||||
@@ -181,7 +180,6 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var mu MucUser
|
||||
var ocu OccupantID
|
||||
|
||||
@@ -206,6 +204,25 @@ 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)
|
||||
@@ -214,16 +231,17 @@ func main() {
|
||||
// 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)
|
||||
|
||||
Reference in New Issue
Block a user