IApplicationPlatformServices interface

Namespace Runic.Platform in Runic.Platform 0.23.0

public interface IApplicationPlatformServices : IPlatformCapabilities

Inherits or implements IPlatformCapabilities.

Native services of the application that need no window: opening URIs and files, revealing files, and message boxes.

Remarks

A host registers one instance for the application, so a service without a window of its own, such as a link handler, a menu command shared by several windows or a background download, takes this interface in its constructor. It works before the first window opens, while every window is closed, for an application behind a status icon and for Windows served to a browser.

Prefer a window's IWindowPlatformServices.FileLauncher while that window is shown: the desktop can then place an application chooser over it. The application's launcher reports PlatformUnavailableReason.OwnerUnavailable only where a platform needs a parent window, which none of Runic's providers does.

Properties

FileLauncher

IDesktopFileLauncher FileLauncher { get; }

Hands local files and web, mail or Windows Settings URIs to native applications, without a window.

Remarks

The rules and results of IDesktopFileLauncher: the same URI policy, the same refusal to open programs, and DesktopFileOperation.Reveal and DesktopFileOperation.ChooseApplication, which shows its chooser without a parent. Its capabilities are PlatformCapabilityIds.FilesLaunch and PlatformCapabilityIds.UrisLaunch.

MessageBoxes

IDesktopMessageBoxes MessageBoxes { get; }

Message boxes without a window, such as for an error before the first window opens.

Remarks

A box asks for it with OwnerPolicy.PreferOwner; with OwnerPolicy.RequireOwner, the default, it reports PlatformUnavailableReason.OwnerUnavailable, as the application has no window to own it. The box is modal for the application rather than for a window, and otherwise follows IDesktopMessageBoxes.ShowAsync. Its capability is PlatformCapabilityIds.MessageBoxes, which describes a OwnerPolicy.PreferOwner box.

Runic Desktop shows a task dialog on Windows, an application-modal alert on macOS, which needs the main thread (the Desktop event loop, or a call on the main thread), and on Linux a dialog of the GTK toolkit the process runs, once its loop runs: from the start of a GTK 4 event loop, and with GTK 3 once a window opened. Without a running toolkit Linux reports PlatformUnavailableReason.BackendUnavailable.

Example

await platform.MessageBoxes.ShowAsync(new DesktopMessageBox("The settings cannot be read.")
{
    Kind = DesktopMessageBoxKind.Error, OwnerPolicy = OwnerPolicy.PreferOwner,
});