Skip to content

Added Essentials AppActions - #200

Draft
cedric56 wants to merge 13 commits into
AvaloniaUI:mainfrom
cedric56:essentials-appactions
Draft

Added Essentials AppActions#200
cedric56 wants to merge 13 commits into
AvaloniaUI:mainfrom
cedric56:essentials-appactions

Conversation

@cedric56

@cedric56 cedric56 commented May 7, 2026

Copy link
Copy Markdown

✨ Add AppActions support for Avalonia MAUI Essentials (Linux D-Bus integration)

This PR introduces a new AppActions implementation for Avalonia.Controls.Maui.Essentials, enabling Linux desktop integration through D-Bus activation and .desktop file actions.

🚀 Overview

This feature extends MAUI AppActions to support desktop Linux environments when using Avalonia, allowing applications to expose and handle native app shortcuts via:

D-Bus service registration
Dynamic .desktop file generation
Runtime action activation callbacks

✅ Linux Platform Support

Implements PlatformSetAsync for Linux only
Uses OperatingSystem.IsLinux() guard

🔌 D-Bus Integration

Registers a session bus service (com.essentials.AppActions)
Exposes actions via Tmds.DBus
Handles activation through OnAppActionAsync

🖥 Desktop Integration

Generates .desktop files dynamically per app instance
Adds custom Desktop Action entries for each AppAction
Uses gdbus calls to trigger actions externally

🪟 Window Integration

Sets X11 WM_CLASS to support desktop identity binding
Ensures initialization occurs after MainWindow is available

Comment on lines +26 to +29
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'browser'">
<PackageReference Include="Tmds.DBus" Version="0.92.0">
<Aliases>TmdsDBus</Aliases>
</PackageReference>

@jsuarezruiz jsuarezruiz May 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition excludes only the browser TFM, so the packed net11.0 dependency group now includes Tmds.DBus for every desktop consumer, including Windows and macOS, even though the implementation only supports Linux. This needs a packaging/design decision: avoid flowing the Linux-only dependency to non-Linux consumers, or explicitly accept and document that the shared desktop asset carries it.

Comment thread samples/ControlGallery/ControlGallery/Properties/launchSettings.json Outdated
Comment thread src/Avalonia.Controls.Maui.Essentials/AppActions/AvaloniaAppActions.cs Outdated

@jsuarezruiz jsuarezruiz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rebase and fix the conflict? Thanks in advance.

Comment thread src/Avalonia.Controls.Maui.Essentials/AppActions/AvaloniaAppActions.Default.cs Outdated
@jsuarezruiz

Copy link
Copy Markdown
Member

CI is currently failing in the ControlGallery NativeAOT publish because AppActionsPage.xaml uses string-path bindings inside the CollectionView item template.

The generated XAML code calls Microsoft.Maui.Controls.Binding.Binding(string, ...), which is marked RequiresUnreferencedCode, so NativeAOT/trimming fails with IL2026:

Using bindings with string paths is not trim safe. Use expression-based binding instead.

Can you review?

@cedric56

Copy link
Copy Markdown
Author

CI is currently failing in the ControlGallery NativeAOT publish because AppActionsPage.xaml uses string-path bindings inside the CollectionView item template.

The generated XAML code calls Microsoft.Maui.Controls.Binding.Binding(string, ...), which is marked RequiresUnreferencedCode, so NativeAOT/trimming fails with IL2026:

Using bindings with string paths is not trim safe. Use expression-based binding instead.

Can you review?

I added a x:DataType to CollectionView ItemTemplate.

@cedric56 cedric56 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added x:DataType="model:AppAction"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants