1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-gtk.git synced 2024-11-01 03:54:16 +00:00
cchat-gtk/internal/ui/messages/container/compact/message.go

45 lines
1 KiB
Go

package compact
import (
"github.com/diamondburned/cchat"
"github.com/diamondburned/cchat-gtk/internal/ui/messages/container"
"github.com/diamondburned/cchat-gtk/internal/ui/messages/input"
"github.com/diamondburned/cchat-gtk/internal/ui/messages/message"
"github.com/gotk3/gotk3/gtk"
)
type PresendMessage struct {
message.PresendContainer
Message
}
func NewPresendMessage(msg input.PresendMessage) PresendMessage {
var msgc = message.NewPresendContainer(msg)
return PresendMessage{
PresendContainer: msgc,
Message: Message{msgc.GenericContainer},
}
}
type Message struct {
*message.GenericContainer
}
var _ container.GridMessage = (*Message)(nil)
func NewMessage(msg cchat.MessageCreate) Message {
msgc := message.NewContainer(msg)
message.FillContainer(msgc, msg)
return Message{msgc}
}
func NewEmptyMessage() Message {
return Message{message.NewEmptyContainer()}
}
func (m Message) Attach(grid *gtk.Grid, row int) {
container.AttachRow(grid, row, m.Timestamp, m.Username, m.Content)
}