package filetypes import ( "fmt" tk "modernc.org/tk9.0" ) type FileDescription struct { TkTypeName string MacExtensions []string IconFile string MIMETypes []string TypeName string OSTypes []string ItemContentTypes string } var Valid = []FileDescription{ { TkTypeName: "BMP", MacExtensions: []string{"bmp", "BMP"}, IconFile: "bmp.icns", MIMETypes: []string{"image/bmp"}, TypeName: "Windows Bitmap Image", OSTypes: []string{"BMP ", "BMPf"}, ItemContentTypes: "com.microsoft.bmp", }, { TkTypeName: "JPEG", MacExtensions: []string{"jpg", "JPG", "jpeg", "JPEG"}, IconFile: "jpeg.icns", MIMETypes: []string{"image/jpeg"}, TypeName: "JPEG Image", OSTypes: []string{"JPEG"}, ItemContentTypes: "public.jpeg", }, { TkTypeName: "GIF", MacExtensions: []string{"gif", "GIF"}, IconFile: "gif.icns", MIMETypes: []string{"image/gif"}, TypeName: "Graphics Interchange Format Image", OSTypes: []string{"GIFf"}, ItemContentTypes: "com.compuserve.gif", }, { TkTypeName: "PNG", MacExtensions: []string{"PNG", "png"}, IconFile: "png.icns", MIMETypes: []string{"image/png"}, TypeName: "Portable Network Graphics Image", OSTypes: []string{"PNGf"}, ItemContentTypes: "public.png", }, { TkTypeName: "TGA", MacExtensions: []string{"tga", "TGA"}, IconFile: "tga.icns", MIMETypes: []string{"image/targa", "image/tga", "application/tga"}, TypeName: "Targa Image", OSTypes: []string{"TPIC"}, ItemContentTypes: "com.truevision.tga-image", }, { TkTypeName: "TIFF", MacExtensions: []string{"tiff", "TIFF", "tif", "TIF"}, IconFile: "tiff.icns", MIMETypes: []string{"image/tiff"}, TypeName: "TIFF Image", OSTypes: []string{"TIFF"}, ItemContentTypes: "public.tiff", }, { TkTypeName: "WEBP", MacExtensions: []string{"webp", "WEBP"}, IconFile: "webp.icns", MIMETypes: []string{"image/webp"}, TypeName: "WebP Image", OSTypes: []string{"WEBP"}, ItemContentTypes: "org.webmproject.webp", }, } func GetTkTypes(fds []FileDescription) []tk.FileType { fts := make([]tk.FileType, len(fds)) for i, fd := range fds { fts[i] = tk.FileType{ TypeName: fd.TkTypeName, Extensions: make([]string, len(fd.MacExtensions)), } for j, ex := range fd.MacExtensions { fts[i].Extensions[j] = fmt.Sprintf(".%s", ex) } } return fts }