initial commit
This commit is contained in:
38
gtk-helpers.go
Normal file
38
gtk-helpers.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/diamondburned/gotk4/pkg/glib/v2"
|
||||
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||
"github.com/sqweek/dialog"
|
||||
)
|
||||
|
||||
func scrollToBottomAfterUpdate(scrolledWindow *gtk.ScrolledWindow) {
|
||||
glib.IdleAdd(func() bool {
|
||||
vAdj := scrolledWindow.VAdjustment()
|
||||
vAdj.SetValue(vAdj.Upper() - vAdj.PageSize())
|
||||
return false // Return false to run only once
|
||||
})
|
||||
}
|
||||
|
||||
func createTab(jid string, isMuc bool) {
|
||||
_, ok := tabs[jid]
|
||||
if !ok {
|
||||
newTab := new(chatTab)
|
||||
newTab.isMuc = isMuc
|
||||
newTab.msgs = gtk.NewListBox()
|
||||
newTab.msgs.SetVExpand(true)
|
||||
newTab.msgs.SetShowSeparators(true)
|
||||
|
||||
newTab.msgs.Append(gtk.NewButtonWithLabel("Get past messages..."))
|
||||
tabs[jid] = newTab
|
||||
}
|
||||
}
|
||||
|
||||
func switchToTab(jid string) {
|
||||
current = jid
|
||||
scroller.SetChild(tabs[current].msgs)
|
||||
}
|
||||
|
||||
func showErrorDialog(err error) {
|
||||
dialog.Message("%s", err.Error()).Title("Error").Error()
|
||||
}
|
||||
Reference in New Issue
Block a user