diff --git a/docs/src/content/docs/changelog.mdx b/docs/src/content/docs/changelog.mdx index 89af3efeb..8d985a0e4 100644 --- a/docs/src/content/docs/changelog.mdx +++ b/docs/src/content/docs/changelog.mdx @@ -76,6 +76,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add cancellation support for query methods on `sqlite` service by [@fbbdev](https://github.com/fbbdev) in [#4067](https://github.com/wailsapp/wails/pull/4067) - Add prepared statement support to `sqlite` service with JS bindings by [@fbbdev](https://github.com/fbbdev) in [#4067](https://github.com/wailsapp/wails/pull/4067) - Add `SetMenu()` on window to allow for setting a menu on a window by [@leaanthony](https://github.com/leaanthony) +-  Add File Association support for mac by [@wimaha](https://github.com/wimaha) in [#4177](https://github.com/wailsapp/wails/pull/4177) ### Fixed diff --git a/docs/src/content/docs/guides/file-associations.mdx b/docs/src/content/docs/guides/file-associations.mdx index 3394b576f..eebc29364 100644 --- a/docs/src/content/docs/guides/file-associations.mdx +++ b/docs/src/content/docs/guides/file-associations.mdx @@ -62,6 +62,7 @@ fileAssociations: | description | Description shown in file properties | Windows | | iconName | Name of the icon file (without extension) in the build folder | All | | role | Application's role for this file type (e.g., `Editor`, `Viewer`) | macOS | +| mimeType | MIME type for the file (e.g., `image/jpeg`) | macOS | ## Listening for File Open Events @@ -105,6 +106,8 @@ Let's walk through setting up file associations for a simple text editor: Run `wails3 generate icons --help` for more information. ::: + - For macOS add copy statement like `cp build/darwin/documenticon.icns {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources` in the `create:app:bundle:` task. + 2. ### Configure File Associations Edit the `build/config.yml` file to add your file associations: diff --git a/v3/internal/commands/build-assets.go b/v3/internal/commands/build-assets.go index 12b5694fd..1fa9138f5 100644 --- a/v3/internal/commands/build-assets.go +++ b/v3/internal/commands/build-assets.go @@ -4,14 +4,15 @@ import ( "embed" _ "embed" "fmt" - "github.com/leaanthony/gosod" - "gopkg.in/yaml.v3" "io/fs" "os" "path/filepath" "runtime" "strings" "time" + + "github.com/leaanthony/gosod" + "gopkg.in/yaml.v3" ) //go:embed build_assets @@ -121,6 +122,7 @@ type FileAssociation struct { Description string `yaml:"description"` IconName string `yaml:"iconName"` Role string `yaml:"role"` + MimeType string `yaml:"mimeType"` } type UpdateConfig struct { diff --git a/v3/internal/commands/build_assets/config.yml b/v3/internal/commands/build_assets/config.yml index bc09a6d28..8a5e2f4c8 100644 --- a/v3/internal/commands/build_assets/config.yml +++ b/v3/internal/commands/build_assets/config.yml @@ -56,6 +56,7 @@ fileAssociations: # description: Image File # iconName: jpegFileIcon # role: Editor +# mimeType: image/jpeg # (optional) # Other data other: diff --git a/v3/internal/commands/updatable_build_assets/darwin/Info.dev.plist.tmpl b/v3/internal/commands/updatable_build_assets/darwin/Info.dev.plist.tmpl index 47f39f537..e44a679d2 100644 --- a/v3/internal/commands/updatable_build_assets/darwin/Info.dev.plist.tmpl +++ b/v3/internal/commands/updatable_build_assets/darwin/Info.dev.plist.tmpl @@ -2,27 +2,50 @@ CFBundlePackageType - APPL + APPL CFBundleName - {{.ProductName}} + {{.ProductName}} CFBundleExecutable - {{.BinaryName}} + {{.BinaryName}} CFBundleIdentifier - {{.ProductIdentifier}} + {{.ProductIdentifier}} CFBundleVersion - {{.ProductVersion}} + {{.ProductVersion}} CFBundleGetInfoString - {{.ProductComments}} + {{.ProductComments}} CFBundleShortVersionString - {{.ProductVersion}} + {{.ProductVersion}} CFBundleIconFile - icons + icons LSMinimumSystemVersion - 10.15.0 + 10.15.0 NSHighResolutionCapable - true + true NSHumanReadableCopyright - {{.ProductCopyright}} + {{.ProductCopyright}} + {{- if .FileAssociations}} + CFBundleDocumentTypes + + {{- range .FileAssociations}} + + CFBundleTypeExtensions + + {{.Ext}} + + CFBundleTypeName + {{.Name}} + CFBundleTypeRole + {{.Role}} + CFBundleTypeIconFile + {{.IconName}} + {{- if .MimeType}} + CFBundleTypeMimeType + {{.MimeType}} + {{- end}} + + {{- end}} + + {{- end}} NSAppTransportSecurity NSAllowsLocalNetworking diff --git a/v3/internal/commands/updatable_build_assets/darwin/Info.plist.tmpl b/v3/internal/commands/updatable_build_assets/darwin/Info.plist.tmpl index 3dce3676c..c20032556 100644 --- a/v3/internal/commands/updatable_build_assets/darwin/Info.plist.tmpl +++ b/v3/internal/commands/updatable_build_assets/darwin/Info.plist.tmpl @@ -2,26 +2,49 @@ CFBundlePackageType - APPL + APPL CFBundleName - {{.ProductName}} + {{.ProductName}} CFBundleExecutable - {{.BinaryName}} + {{.BinaryName}} CFBundleIdentifier - {{.ProductIdentifier}} + {{.ProductIdentifier}} CFBundleVersion - {{.ProductVersion}} + {{.ProductVersion}} CFBundleGetInfoString - {{.ProductComments}} + {{.ProductComments}} CFBundleShortVersionString - {{.ProductVersion}} + {{.ProductVersion}} CFBundleIconFile - icons + icons LSMinimumSystemVersion - 10.15.0 + 10.15.0 NSHighResolutionCapable - true + true NSHumanReadableCopyright - {{.ProductCopyright}} + {{.ProductCopyright}} + {{- if .FileAssociations}} + CFBundleDocumentTypes + + {{- range .FileAssociations}} + + CFBundleTypeExtensions + + {{.Ext}} + + CFBundleTypeName + {{.Name}} + CFBundleTypeRole + {{.Role}} + CFBundleTypeIconFile + {{.IconName}} + {{- if .MimeType}} + CFBundleTypeMimeType + {{.MimeType}} + {{- end}} + + {{- end}} + + {{- end}} \ No newline at end of file diff --git a/v3/pkg/application/dialogs.go b/v3/pkg/application/dialogs.go index 1e52225ce..2c832d5f2 100644 --- a/v3/pkg/application/dialogs.go +++ b/v3/pkg/application/dialogs.go @@ -291,6 +291,9 @@ func (d *OpenFileDialogStruct) PromptForMultipleSelection() ([]string, error) { } selections, err := InvokeSyncWithResultAndError(d.impl.show) + if err != nil { + return nil, err + } var result []string for filename := range selections { diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index d1b405813..c5f51220e 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fixed locking issue on Windows when multiselect dialog returns an error. Fixed in [PR](https://github.com/wailsapp/wails/pull/4156) by @johannes-luebke + ## v2.9.1 - 2024-06-18 ### Fixed