diff options
author | Rodrigo Moya <rodrigo.moya@xamarin.com> | 2019-07-18 14:41:28 +0300 |
---|---|---|
committer | Rodrigo Moya <rodrigo.moya@xamarin.com> | 2019-07-25 12:31:12 +0300 |
commit | 4740ce100bad0328d90bdbae638a61d34816e292 (patch) | |
tree | 4ed6c7e201d167ceda0cd92e3c050c1bebf83efc /main/src/addins/MacPlatform/MacPlatform.cs | |
parent | c6af3e627a728356c3ae44d2c35806862feaf583 (diff) |
[MacPlatform] Fix retrieval of installed applications
Also, remove some old CoreFoundation bindings which are not needed
anymore, as same code is available in Xamarin.Mac already.
Diffstat (limited to 'main/src/addins/MacPlatform/MacPlatform.cs')
-rw-r--r-- | main/src/addins/MacPlatform/MacPlatform.cs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs index 49cadaa103..aa7eea5109 100644 --- a/main/src/addins/MacPlatform/MacPlatform.cs +++ b/main/src/addins/MacPlatform/MacPlatform.cs @@ -980,18 +980,19 @@ namespace MonoDevelop.MacIntegration checkUniqueName.Add ("MonoDevelop"); checkUniqueName.Add (BrandingService.ApplicationName); - string def = MonoDevelop.MacInterop.CoreFoundation.GetApplicationUrl (filename, - MonoDevelop.MacInterop.CoreFoundation.LSRolesMask.All); + var def = global::CoreServices.LaunchServices.GetDefaultApplicationUrlForUrl (NSUrl.FromString (filename)); var apps = new List<DesktopApplication> (); - foreach (var app in MonoDevelop.MacInterop.CoreFoundation.GetApplicationUrls (filename, - MonoDevelop.MacInterop.CoreFoundation.LSRolesMask.All)) { - if (string.IsNullOrEmpty (app) || !checkUniquePath.Add (app)) - continue; - var name = NSFileManager.DefaultManager.DisplayName (app); - if (checkUniqueName.Add (name)) - apps.Add (new MacDesktopApplication (app, name, def != null && def == app)); + var retrievedApps = global::CoreServices.LaunchServices.GetApplicationUrlsForUrl (NSUrl.FromString (filename), global::CoreServices.LSRoles.All); + if (retrievedApps != null) { + foreach (var app in retrievedApps) { + if (string.IsNullOrEmpty (app.Path) || !checkUniquePath.Add (app.Path)) + continue; + if (checkUniqueName.Add (app.LastPathComponent)) { + apps.Add (new MacDesktopApplication (app.Path, app.LastPathComponent, def != null && def == app)); + } + } } apps.Sort ((DesktopApplication a, DesktopApplication b) => { @@ -1012,8 +1013,11 @@ namespace MonoDevelop.MacIntegration public override void Launch (params string[] files) { - foreach (var file in files) - NSWorkspace.SharedWorkspace.OpenFile (file, Id); + NSWorkspace.SharedWorkspace.OpenUrls ( + files.Select (NSUrl.FromString).ToArray (), + NSBundle.FromPath (Id).BundleIdentifier, + NSWorkspaceLaunchOptions.Default, + NSAppleEventDescriptor.DescriptorWithBoolean (true)); } } |