42 lines
1 KiB
Go
42 lines
1 KiB
Go
package gui
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/diamondburned/gotk4-adwaita/pkg/adw"
|
|
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
|
"suruatoel.xyz/mcg/data"
|
|
"suruatoel.xyz/mcg/internal/common"
|
|
)
|
|
|
|
type albumHeaderbar struct {
|
|
*adw.Bin
|
|
titleLabel *gtk.Label
|
|
artistLabel *gtk.Label
|
|
closeButton *gtk.Button
|
|
}
|
|
|
|
func newAlbumHeaderbar() *albumHeaderbar {
|
|
bar := albumHeaderbar{}
|
|
bar.loadWidgets()
|
|
|
|
return &bar
|
|
}
|
|
|
|
func (b *albumHeaderbar) loadWidgets() {
|
|
builder := gtk.NewBuilderFromString(data.AlbumHeaderbarXML)
|
|
|
|
b.Bin = builder.GetObject("McgAlbumHeaderbar").Cast().(*adw.Bin)
|
|
b.titleLabel = builder.GetObject("standalone_title").Cast().(*gtk.Label)
|
|
b.artistLabel = builder.GetObject("standalone_artist").Cast().(*gtk.Label)
|
|
b.closeButton = builder.GetObject("close_button").Cast().(*gtk.Button)
|
|
}
|
|
|
|
func (b *albumHeaderbar) SetAlbum(album *common.Album) {
|
|
b.titleLabel.SetText(album.Title())
|
|
b.artistLabel.SetText(strings.Join(album.Artists(), ", "))
|
|
}
|
|
|
|
func (b *albumHeaderbar) ConnectClose(callback func()) {
|
|
b.closeButton.ConnectClicked(callback)
|
|
}
|