microsoft-webui-desktop 3.0.2

Configurable native desktop SDK for WebUI applications
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use std::path::Path;

use gtk4::gio::{self, prelude::*};

use super::NativeServiceError;

pub(super) fn open_url(url: &str) -> Result<(), NativeServiceError> {
    gio::AppInfo::launch_default_for_uri(url, None::<&gio::AppLaunchContext>)
        .map_err(|error| NativeServiceError::Os(error.to_string()))
}

pub(super) fn open_document(path: &Path) -> Result<(), NativeServiceError> {
    let file = gio::File::for_path(path);
    open_url(file.uri().as_str())
}