1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-gtk.git synced 2024-11-16 11:12:44 +00:00
cchat-gtk/internal/ui/service/children.go

31 lines
583 B
Go
Raw Normal View History

2020-06-07 04:27:28 +00:00
package service
import (
"github.com/diamondburned/cchat-gtk/internal/ui/service/session"
"github.com/gotk3/gotk3/gtk"
)
type children struct {
*gtk.Box
Sessions map[string]*session.Row
}
func newChildren() *children {
box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
box.Show()
return &children{box, map[string]*session.Row{}}
}
func (c *children) addSessionRow(id string, row *session.Row) {
c.Sessions[id] = row
c.Box.Add(row)
}
func (c *children) removeSessionRow(id string) {
if row, ok := c.Sessions[id]; ok {
delete(c.Sessions, id)
c.Box.Remove(row)
}
}