-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6365 from cdwcgt/PresentFileExternally-macos
Implement native method for `PresentFileExternally` in MacOS
- Loading branch information
Showing
4 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Threading.Tasks; | ||
|
||
namespace osu.Framework.Platform.MacOS.Native | ||
{ | ||
internal static class Finder | ||
{ | ||
private static readonly NSWorkspace shared_workspace = NSWorkspace.SharedWorkspace(); | ||
|
||
internal static void OpenFolderAndSelectItem(string filename) | ||
{ | ||
Task.Run(() => | ||
{ | ||
shared_workspace.SelectFile(filename); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
|
||
namespace osu.Framework.Platform.MacOS.Native | ||
{ | ||
internal readonly struct NSWorkspace | ||
{ | ||
internal IntPtr Handle { get; } | ||
|
||
private static readonly IntPtr class_pointer = Class.Get("NSWorkspace"); | ||
private static readonly IntPtr sel_shared_workspace = Selector.Get("sharedWorkspace"); | ||
private static readonly IntPtr sel_select_file = Selector.Get("selectFile:inFileViewerRootedAtPath:"); | ||
|
||
internal NSWorkspace(IntPtr handle) | ||
{ | ||
Handle = handle; | ||
} | ||
|
||
internal static NSWorkspace SharedWorkspace() => new NSWorkspace(Cocoa.SendIntPtr(class_pointer, sel_shared_workspace)); | ||
|
||
internal bool SelectFile(string file) => Cocoa.SendBool(Handle, sel_select_file, Cocoa.ToNSString(file)); | ||
} | ||
} |