https://github.com/inochi2d/dportals
D implementation of xdg-desktop-portals
https://github.com/inochi2d/dportals
Last synced: 8 months ago
JSON representation
D implementation of xdg-desktop-portals
- Host: GitHub
- URL: https://github.com/inochi2d/dportals
- Owner: Inochi2D
- Created: 2022-09-30T04:17:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-01T13:40:41.000Z (over 3 years ago)
- Last Synced: 2025-01-08T14:12:14.081Z (over 1 year ago)
- Language: D
- Size: 9.77 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# xdg-desktop-portal for D
This D library allows you to interface with XDG Desktop Portals when
you aren't using GTK or Qt.
## Example
```d
module app;
import dportals;
import std.stdio;
void main() {
// Initialize Desktop Portals support
// This will live for the *entire* application lifetime.
dpInit();
// Open a File Open Dialog with some options set.
// A Promise type is returned which you can await.
// If you want your application to be non-blocking
// you will have to continually call dpUpdate
// then check the success value of the response
// before getting the value.
auto promise = dpFileChooserOpenFile(
"",
"Open File",
// See FileOpenOptions for API
FileOpenOptions(
"",
"UwU",
false,
true,
false,
[FileFilter("PNG", [FileFilterItem(0, "*.png")])],
new FileFilter("PNG", [FileFilterItem(0, "*.png")]),
[FileChoice("mangle", "Mangle File", [], "")]
)
);
// Await the response.
// This will continually in a loop call dpUpdate
// until the dialog closes for some reason.
promise.await();
// Print useful info about selected file
write(promise.success(), " ");
if (promise.success) write(promise.value());
else write("null");
write("\n");
}
```