forked from sunglocto/lambda
Sensible room joining flow
This commit is contained in:
186
main.go
186
main.go
@@ -96,9 +96,9 @@ func main() {
|
||||
TransportConfiguration: xmpp.TransportConfiguration{
|
||||
Address: loadedConfig.Server,
|
||||
},
|
||||
Jid: loadedConfig.Username + "/lambda." + str,
|
||||
Credential: xmpp.Password(loadedConfig.Password),
|
||||
Insecure: loadedConfig.Insecure,
|
||||
Jid: loadedConfig.Username + "/lambda." + str,
|
||||
Credential: xmpp.Password(loadedConfig.Password),
|
||||
Insecure: loadedConfig.Insecure,
|
||||
StreamLogger: os.Stdout,
|
||||
}
|
||||
router := xmpp.NewRouter()
|
||||
@@ -164,7 +164,6 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if m.Body == "" {
|
||||
return
|
||||
@@ -175,21 +174,21 @@ func main() {
|
||||
|
||||
glib.IdleAdd(func() {
|
||||
//uiQueue <- func() {
|
||||
b := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
ba, ok := generateMessageWidget(p).(*gtk.Box)
|
||||
if ok {
|
||||
b = ba
|
||||
}
|
||||
b := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
ba, ok := generateMessageWidget(p).(*gtk.Box)
|
||||
if ok {
|
||||
b = ba
|
||||
}
|
||||
|
||||
tab, ok := tabs.Load(originator)
|
||||
typed_tab := tab.(*chatTab)
|
||||
tab, ok := tabs.Load(originator)
|
||||
typed_tab := tab.(*chatTab)
|
||||
|
||||
if ok {
|
||||
typed_tab.msgs.Append(b)
|
||||
scrollToBottomAfterUpdate(scroller)
|
||||
} else {
|
||||
fmt.Println("Got message when the tab does not exist!")
|
||||
}
|
||||
if ok {
|
||||
typed_tab.msgs.Append(b)
|
||||
scrollToBottomAfterUpdate(scroller)
|
||||
} else {
|
||||
fmt.Println("Got message when the tab does not exist!")
|
||||
}
|
||||
//}
|
||||
})
|
||||
})
|
||||
@@ -231,21 +230,21 @@ func main() {
|
||||
typed_unit.Members.Delete(ocu.ID)
|
||||
glib.IdleAdd(func() {
|
||||
//uiQueue <- func() {
|
||||
b := gtk.NewLabel("")
|
||||
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
||||
if ok {
|
||||
b = ba
|
||||
}
|
||||
b := gtk.NewLabel("")
|
||||
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
||||
if ok {
|
||||
b = ba
|
||||
}
|
||||
|
||||
tab, ok := tabs.Load(muc)
|
||||
typed_tab := tab.(*chatTab)
|
||||
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!")
|
||||
}
|
||||
if ok {
|
||||
typed_tab.msgs.Append(b)
|
||||
scrollToBottomAfterUpdate(scroller)
|
||||
} else {
|
||||
fmt.Println("Got message when the tab does not exist!")
|
||||
}
|
||||
//}
|
||||
})
|
||||
}
|
||||
@@ -332,39 +331,82 @@ func activate(app *gtk.Application) {
|
||||
)
|
||||
|
||||
window = gtk.NewApplicationWindow(app)
|
||||
the_menu := gio.NewMenu()
|
||||
|
||||
fileMenu := gio.NewMenu()
|
||||
fileMenu.Append("Join room", "app.join")
|
||||
fileMenu.Append("Start DM", "app.dm")
|
||||
|
||||
joinAction := gio.NewSimpleAction("join", nil)
|
||||
joinAction.ConnectActivate(func(p *glib.Variant) {
|
||||
box := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
jid_box := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
nick_box := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
|
||||
jid_entry := gtk.NewEntry()
|
||||
nick_entry := gtk.NewEntry()
|
||||
|
||||
jid_entry.SetHAlign(gtk.AlignEnd)
|
||||
jid_entry.SetHExpand(true)
|
||||
|
||||
nick_entry.SetHAlign(gtk.AlignEnd)
|
||||
nick_entry.SetHExpand(true)
|
||||
|
||||
nick_entry.SetText(loadedConfig.Nick)
|
||||
|
||||
jid_box.Append(gtk.NewLabel("MUC JID:"))
|
||||
jid_box.Append(jid_entry)
|
||||
|
||||
nick_box.Append(gtk.NewLabel("Nick:"))
|
||||
nick_box.Append(nick_entry)
|
||||
|
||||
box.Append(jid_box)
|
||||
box.Append(nick_box)
|
||||
|
||||
btn := gtk.NewButtonWithLabel("Submit")
|
||||
btn.SetVAlign(gtk.AlignBaseline)
|
||||
|
||||
box.Append(btn)
|
||||
|
||||
win := gtk.NewWindow()
|
||||
win.SetDefaultSize(200, 200)
|
||||
win.SetChild(box)
|
||||
|
||||
btn.ConnectClicked(func() {
|
||||
t := jid_entry.Text()
|
||||
_, ok := tabs.Load(t)
|
||||
if !ok {
|
||||
err := joinMuc(client, clientroot.Session.BindJid, t, nick_entry.Text())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
createTab(t, true)
|
||||
b := gtk.NewButtonWithLabel(t)
|
||||
b.ConnectClicked(func() {
|
||||
b.AddCSSClass("accent")
|
||||
switchToTab(t, &window.Window)
|
||||
})
|
||||
menu.Append(b)
|
||||
}
|
||||
win.SetVisible(false)
|
||||
})
|
||||
|
||||
win.SetTransientFor(win)
|
||||
win.Present()
|
||||
})
|
||||
|
||||
app.AddAction(joinAction)
|
||||
|
||||
the_menu.AppendSubmenu("File", fileMenu)
|
||||
|
||||
the_menuBar := gtk.NewPopoverMenuBarFromModel(the_menu)
|
||||
app.SetMenubar(gio.NewMenu())
|
||||
|
||||
window.SetTitle("Lambda")
|
||||
window.Window.AddCSSClass("ssd")
|
||||
window.Window.SetDefaultSize(500, 500)
|
||||
menu = gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
/*
|
||||
f_menu := gtk.NewMenuButton()
|
||||
f_menu.SetLabel("File")
|
||||
f_menu.SetAlwaysShowArrow(false)
|
||||
|
||||
e_menu := gtk.NewMenuButton()
|
||||
e_menu.SetLabel("Edit")
|
||||
e_menu.SetAlwaysShowArrow(false)
|
||||
|
||||
v_menu := gtk.NewMenuButton()
|
||||
v_menu.SetLabel("View")
|
||||
v_menu.SetAlwaysShowArrow(false)
|
||||
|
||||
b_menu := gtk.NewMenuButton()
|
||||
b_menu.SetLabel("Bookmarks")
|
||||
b_menu.SetAlwaysShowArrow(false)
|
||||
|
||||
h_menu := gtk.NewMenuButton()
|
||||
h_menu.SetLabel("Help")
|
||||
h_menu.SetAlwaysShowArrow(false)
|
||||
|
||||
menu.Append(f_menu)
|
||||
menu.Append(e_menu)
|
||||
menu.Append(v_menu)
|
||||
menu.Append(b_menu)
|
||||
menu.Append(h_menu)
|
||||
*/
|
||||
|
||||
empty_dialog = gtk.NewLabel("You are not focused on any chats.")
|
||||
empty_dialog.SetVExpand(true)
|
||||
@@ -376,6 +418,8 @@ func activate(app *gtk.Application) {
|
||||
memberList.SetHExpand(true)
|
||||
|
||||
box := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
box.Append(the_menuBar)
|
||||
|
||||
// scroller.SetChild(empty_dialog)
|
||||
scroller.SetChild(empty_dialog)
|
||||
menu_scroll := gtk.NewScrolledWindow()
|
||||
@@ -440,37 +484,9 @@ func activate(app *gtk.Application) {
|
||||
|
||||
en.SetHExpand(true)
|
||||
|
||||
m_entry := gtk.NewEntry()
|
||||
|
||||
entry_box.Append(en)
|
||||
entry_box.Append(b)
|
||||
|
||||
entry_box.Append(m_entry)
|
||||
|
||||
debug_btn := gtk.NewButtonWithLabel("Join muc")
|
||||
|
||||
debug_btn.ConnectClicked(func() {
|
||||
t := en.Text()
|
||||
_, ok := tabs.Load(t)
|
||||
if !ok {
|
||||
err := joinMuc(client, clientroot.Session.BindJid, t, m_entry.Text())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
createTab(t, true)
|
||||
b := gtk.NewButtonWithLabel(t)
|
||||
b.ConnectClicked(func() {
|
||||
b.AddCSSClass("accent")
|
||||
switchToTab(t, &window.Window)
|
||||
})
|
||||
menu.Append(b)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
entry_box.Append(debug_btn)
|
||||
|
||||
box.Append(entry_box)
|
||||
|
||||
window.SetChild(box)
|
||||
|
||||
Reference in New Issue
Block a user