Skip to content

Commit

Permalink
Upgrade Eto.Forms to 2.8.3
Browse files Browse the repository at this point in the history
This allows removing several workarounds due to upstream fixes.
  • Loading branch information
cyanfish committed Mar 16, 2024
1 parent c8a41e3 commit 0a7349c
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 75 deletions.
2 changes: 1 addition & 1 deletion NAPS2.App.Gtk/NAPS2.App.Gtk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<ProjectReference Include="..\NAPS2.Lib.Gtk\NAPS2.Lib.Gtk.csproj" />

<PackageReference Include="Eto.Platform.Gtk" Version="2.8.2" />
<PackageReference Include="Eto.Platform.Gtk" Version="2.8.3" />
<!-- This shouldn't need a reference normally, but otherwise "dotnet restore" doesn't pick
it up, which breaks the flatpak build. -->
<PackageReference Include="Microsoft.NETCore.App" Version="2.1.*" />
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.App.Mac/NAPS2.App.Mac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<ProjectReference Include="..\NAPS2.Lib.Mac\NAPS2.Lib.Mac.csproj" />

<PackageReference Include="Eto.Platform.macOS" Version="2.8.2" />
<PackageReference Include="Eto.Platform.macOS" Version="2.8.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Images.Gtk/NAPS2.Images.Gtk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<ItemGroup>
<ProjectReference Include="..\NAPS2.Images\NAPS2.Images.csproj" />
<PackageReference Include="GtkSharp" Version="3.24.24.38" />
<PackageReference Include="GtkSharp" Version="3.24.24.95" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Images.Mac/NAPS2.Images.Mac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<ProjectReference Include="..\NAPS2.Images\NAPS2.Images.csproj" />
<PackageReference Include="Eto.Platform.Mac64" Version="2.8.2" Condition="'$(TargetFramework)' == 'net6'" />
<PackageReference Include="Eto.Platform.Mac64" Version="2.8.3" Condition="'$(TargetFramework)' == 'net6'" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net6'">
Expand Down
4 changes: 2 additions & 2 deletions NAPS2.Lib.Gtk/NAPS2.Lib.Gtk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<ItemGroup>
<ProjectReference Include="..\NAPS2.Images.Gtk\NAPS2.Images.Gtk.csproj" />
<ProjectReference Include="..\NAPS2.Lib\NAPS2.Lib.csproj" />
<PackageReference Include="Eto.Forms" Version="2.8.2" />
<PackageReference Include="Eto.Platform.Gtk" Version="2.8.2" />
<PackageReference Include="Eto.Forms" Version="2.8.3" />
<PackageReference Include="Eto.Platform.Gtk" Version="2.8.3" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 0 additions & 14 deletions NAPS2.Lib.Mac/EtoForms/Mac/MacEtoPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@ public override Application CreateApplication()
return new Application(Platforms.macOS);
}

public override void Invoke(Application application, Action action)
{
// TODO: Eto PR to use this instead of DispatchQueue.MainQueue
// Invoking directly on DispatchQueue ignores the run loop mode, which can mean something like spawning a modal
// form doesn't behave normally.
// https://stackoverflow.com/questions/9335434/whats-the-difference-between-performselectoronmainthread-and-dispatch-async
NSApplication.SharedApplication.InvokeOnMainThread(action);
}

public override void AsyncInvoke(Application application, Action action)
{
NSApplication.SharedApplication.BeginInvokeOnMainThread(action);
}

public override IListView<T> CreateListView<T>(ListViewBehavior<T> behavior) =>
new MacListView<T>(behavior);

Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Lib.Mac/NAPS2.Lib.Mac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\NAPS2.Images.Mac\NAPS2.Images.Mac.csproj" />
<ProjectReference Include="..\NAPS2.Lib\NAPS2.Lib.csproj" />
<PackageReference Include="Eto.Platform.macOS" Version="2.8.2" />
<PackageReference Include="Eto.Platform.macOS" Version="2.8.3" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 0 additions & 14 deletions NAPS2.Lib.WinForms/EtoForms/WinForms/WinFormsEtoPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ public override Application CreateApplication()
return new Application(Eto.Platforms.WinForms);
}

public override void RunApplication(Application application, Form mainForm)
{
// We manually run an application rather than using eto as that lets us change the main form
// TODO: PR for eto to handle mainform changes correctly
application.MainForm = mainForm;
mainForm.Show();
var appContext = new WF.ApplicationContext(mainForm.ToNative());
WinFormsDesktopForm.ApplicationContext = appContext;
var setOptionsMethod =
typeof(ApplicationHandler).GetMethod("SetOptions", BindingFlags.Instance | BindingFlags.NonPublic);
setOptionsMethod!.Invoke(application.Handler, Array.Empty<object>());
WF.Application.Run(appContext);
}

public override IListView<T> CreateListView<T>(ListViewBehavior<T> behavior) =>
new WinFormsListView<T>(behavior);

Expand Down
4 changes: 2 additions & 2 deletions NAPS2.Lib.WinForms/NAPS2.Lib.WinForms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<ItemGroup>
<ProjectReference Include="..\NAPS2.Lib\NAPS2.Lib.csproj" />
<ProjectReference Include="..\NAPS2.Images.Gdi\NAPS2.Images.Gdi.csproj" />
<PackageReference Include="Eto.Forms" Version="2.8.2" />
<PackageReference Include="Eto.Platform.Windows" Version="2.8.2" />
<PackageReference Include="Eto.Forms" Version="2.8.3" />
<PackageReference Include="Eto.Platform.Windows" Version="2.8.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Lib/EntryPoints/ConsoleEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static int Run(string[] args, Module imageModule)
application.UnhandledException += UnhandledException;
application.Initialized += (_, _) => scanning.Execute().ContinueWith(_ => application.Quit());
Invoker.Current = new EtoInvoker(application);
EtoPlatform.Current.RunApplication(application);
application.Run();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Lib/EntryPoints/GuiEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static int Run(string[] args, Module imageModule, Module guiModule)
var formFactory = container.Resolve<IFormFactory>();
var desktop = formFactory.Create<DesktopForm>();

EtoPlatform.Current.RunApplication(application, desktop);
application.Run(desktop);
return 0;
}

Expand Down
12 changes: 0 additions & 12 deletions NAPS2.Lib/EtoForms/EtoDialogBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Eto.Drawing;
using Eto.Forms;
using NAPS2.EtoForms.Layout;

Expand Down Expand Up @@ -27,17 +26,6 @@ protected override void OnPreLoad(EventArgs e)
base.OnPreLoad(e);
}

// TODO: PR for Eto to integrate this
public new Icon Icon
{
get => base.Icon;
set
{
base.Icon = value;
EtoPlatform.Current.ShowIcon(this);
}
}

public FormStateController FormStateController { get; }

public LayoutController LayoutController { get; } = new();
Expand Down
6 changes: 3 additions & 3 deletions NAPS2.Lib/EtoForms/EtoInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ public EtoInvoker(Application application)

public void Invoke(Action action)
{
EtoPlatform.Current.Invoke(_application, action);
_application.Invoke(action);
}

public void InvokeDispatch(Action action)
{
EtoPlatform.Current.AsyncInvoke(_application, action);
_application.AsyncInvoke(action);
}

public T InvokeGet<T>(Func<T> func)
{
T value = default!;
EtoPlatform.Current.Invoke(_application, () => value = func());
_application.Invoke(() => value = func());
return value;
}
}
20 changes: 0 additions & 20 deletions NAPS2.Lib/EtoForms/EtoPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,6 @@ public virtual void InitializePlatform()
{
}

public virtual void RunApplication(Application application, Form mainForm)
{
application.Run(mainForm);
}

public virtual void RunApplication(Application application)
{
application.Run();
}

public virtual void Invoke(Application application, Action action)
{
application.Invoke(action);
}

public virtual void AsyncInvoke(Application application, Action action)
{
application.AsyncInvoke(action);
}

public virtual void SetContainerSize(Window window, Control container, Size size, int padding)
{
}
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Lib/NAPS2.Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="MimeKit" Version="1.22.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.6" />
<PackageReference Include="Eto.Forms" Version="2.8.2" />
<PackageReference Include="Eto.Forms" Version="2.8.3" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="8.0.0" />
</ItemGroup>
Expand Down

0 comments on commit 0a7349c

Please sign in to comment.