forked from Nexus-Mods/NexusMods.App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use XDG Desktop Portal to open URIs and files
Resolves Nexus-Mods#1676 and related to Nexus-Mods#2436.
- Loading branch information
Showing
6 changed files
with
62 additions
and
2 deletions.
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
30 changes: 30 additions & 0 deletions
30
src/NexusMods.CrossPlatform/DesktopPortalConnectionManagerWrapper.cs
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,30 @@ | ||
using LinuxDesktopUtils.XDGDesktopPortal; | ||
|
||
namespace NexusMods.CrossPlatform; | ||
|
||
internal sealed class DesktopPortalConnectionManagerWrapper : IAsyncDisposable | ||
{ | ||
private readonly SemaphoreSlim _semaphoreSlim = new(initialCount: 1, maxCount: 1); | ||
private DesktopPortalConnectionManager? _instance; | ||
|
||
private async ValueTask<DesktopPortalConnectionManager> InitAsync() | ||
{ | ||
await _semaphoreSlim.WaitAsync(timeout: TimeSpan.FromSeconds(10)); | ||
|
||
var manager = await DesktopPortalConnectionManager.ConnectAsync(); | ||
_instance = manager; | ||
|
||
return manager; | ||
} | ||
|
||
public async ValueTask<DesktopPortalConnectionManager> GetInstance() | ||
{ | ||
if (_instance is not null) return _instance; | ||
return await InitAsync(); | ||
} | ||
|
||
public async ValueTask DisposeAsync() | ||
{ | ||
if (_instance is not null) await _instance.DisposeAsync(); | ||
} | ||
} |
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
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