Skip to content

Commit

Permalink
Merge pull request unoplatform#328 from unoplatform/windows_linux_lau…
Browse files Browse the repository at this point in the history
…ncherextension
  • Loading branch information
MartinZikmund authored Feb 22, 2024
2 parents 330c5ca + b713966 commit 52e12a2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/Uno.Foundation/Extensibility/ApiExtensibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ public static bool CreateInstance<T>(object owner, [NotNullWhen(true)] out T? in
{
if (_registrations.TryGetValue(typeof(T), out var builder))
{
instance = (T)builder(owner);
return true;
if (builder(owner) is { } o)
{
instance = (T)o;
return true;
}
}
}

Expand Down
18 changes: 16 additions & 2 deletions src/Uno.UI.Runtime.Skia.Gtk/Extensions/GtkExtensionsRegistrar.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Uno.ApplicationModel.DataTransfer;
using System.Runtime.InteropServices;
using Uno.ApplicationModel.DataTransfer;
using Uno.Extensions.ApplicationModel.Core;
using Uno.Extensions.Storage.Pickers;
using Uno.Extensions.System;
Expand Down Expand Up @@ -40,12 +41,25 @@ internal static void Register()
ApiExtensibility.Register(typeof(ISystemThemeHelperExtension), o => new GtkSystemThemeHelperExtension(o));
ApiExtensibility.Register(typeof(Windows.Graphics.Display.IDisplayInformationExtension), o => new GtkDisplayInformationExtension(o));
ApiExtensibility.Register<TextBoxView>(typeof(IOverlayTextBoxViewExtension), o => new TextBoxViewExtension(o));
ApiExtensibility.Register(typeof(ILauncherExtension), o => new LinuxLauncherExtension(o));
ApiExtensibility.Register<FileOpenPicker>(typeof(IFileOpenPickerExtension), o => new FileOpenPickerExtension(o));
ApiExtensibility.Register<FolderPicker>(typeof(IFolderPickerExtension), o => new FolderPickerExtension(o));
ApiExtensibility.Register(typeof(IClipboardExtension), o => new ClipboardExtensions(o));
ApiExtensibility.Register<FileSavePicker>(typeof(IFileSavePickerExtension), o => new FileSavePickerExtension(o));
ApiExtensibility.Register(typeof(IAnalyticsInfoExtension), o => new AnalyticsInfoExtension());
ApiExtensibility.Register(typeof(ISystemNavigationManagerPreviewExtension), o => new SystemNavigationManagerPreviewExtension());

ApiExtensibility.Register(typeof(ILauncherExtension), o =>
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return new WindowsLauncherExtension(o);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return new LinuxLauncherExtension(o);
}

return null;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Windows.Storage.Pickers;
using Windows.System.Profile.Internal;
using Microsoft.UI.Xaml.Controls;
using Uno.UI.Runtime.Skia.Extensions.System;
using Uno.UI.Runtime.Skia.Wpf.Input;

namespace Uno.UI.Runtime.Skia.Wpf.Extensions;
Expand Down Expand Up @@ -49,7 +50,7 @@ internal static void Register()
ApiExtensibility.Register(typeof(IFileSavePickerExtension), o => new FileSavePickerExtension(o));
ApiExtensibility.Register(typeof(IConnectionProfileExtension), o => new WindowsConnectionProfileExtension(o));
ApiExtensibility.Register<TextBoxView>(typeof(IOverlayTextBoxViewExtension), o => new TextBoxViewExtension(o));
ApiExtensibility.Register(typeof(ILauncherExtension), o => new LauncherExtension(o));
ApiExtensibility.Register(typeof(ILauncherExtension), o => new WindowsLauncherExtension(o));
ApiExtensibility.Register(typeof(IClipboardExtension), o => new ClipboardExtensions(o));
ApiExtensibility.Register(typeof(IAnalyticsInfoExtension), o => new AnalyticsInfoExtension());
ApiExtensibility.Register(typeof(ISystemNavigationManagerPreviewExtension), o => new SystemNavigationManagerPreviewExtension());
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UWP/System/LinuxLauncherExtension.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Task<LaunchQuerySupportStatus> QueryUriSupportAsync(Uri uri, LaunchQueryS
}
}

// Guaranteed to work on all Linux Gtk platforms.
// Should work with most Linux environments
canOpenUri ??= CheckMimeTypeAssociations(uri);

return canOpenUri.Value ?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#nullable enable
#nullable enable

using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.Win32;
using Windows.System;
using Uno.Extensions.System;

namespace Uno.Extensions.System
namespace Uno.UI.Runtime.Skia.Extensions.System
{
internal class LauncherExtension : ILauncherExtension
internal class WindowsLauncherExtension : ILauncherExtension
{
public LauncherExtension(object owner)
public WindowsLauncherExtension(object owner)
{
}

Expand Down

0 comments on commit 52e12a2

Please sign in to comment.