27 lines
638 B
Go
27 lines
638 B
Go
package x
|
|
|
|
import "io"
|
|
import "strings"
|
|
import "git.tebibyte.media/tomo/xgbsel/v2"
|
|
import "git.tebibyte.media/tomo/tomo/data"
|
|
|
|
type selectionData struct {
|
|
data data.Data
|
|
}
|
|
|
|
func (this selectionData) Convert (target xgbsel.Target) (io.ReadSeekCloser, bool) {
|
|
mimeStr, _ := target.ToMime()
|
|
ty, subty, _ := strings.Cut(string(mimeStr), "/")
|
|
mime := data.M(ty, subty)
|
|
stream, ok := this.data[mime]
|
|
stream.Seek(0, io.SeekStart)
|
|
return stream, ok
|
|
}
|
|
|
|
func (this selectionData) Supported () (targets []xgbsel.Target) {
|
|
for mime := range this.data {
|
|
targets = append(targets, xgbsel.MimeToTargets(mime.String())...)
|
|
}
|
|
return targets
|
|
}
|