Sensible room joining flow

This commit is contained in:
2026-02-01 19:22:43 +00:00
parent ac013e7969
commit 6cb8771994

128
main.go
View File

@@ -164,7 +164,6 @@ func main() {
return
}
/*
if m.Body == "" {
return
@@ -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)