From 6bff15ec96f63589551e4772c6499cd0ca8369a5 Mon Sep 17 00:00:00 2001 From: Lehonti Ramos <17771375+Lehonti@users.noreply.github.com> Date: Thu, 3 Oct 2024 12:30:57 +0200 Subject: [PATCH] Changed return type of `LaunchConfiguration` from `Task` to `Task` --- Pinta.Core/Effects/BaseEffect.cs | 7 ++++--- Pinta.Core/Managers/ChromeManager.cs | 16 ++++------------ Pinta.Core/Managers/LivePreviewManager.cs | 4 ++-- .../Adjustments/BrightnessContrastEffect.cs | 2 +- Pinta.Effects/Adjustments/CurvesEffect.cs | 6 +++--- Pinta.Effects/Adjustments/HueSaturationEffect.cs | 2 +- Pinta.Effects/Adjustments/LevelsEffect.cs | 6 +++--- Pinta.Effects/Adjustments/PosterizeEffect.cs | 6 +++--- Pinta.Effects/Effects/AddNoiseEffect.cs | 2 +- Pinta.Effects/Effects/AlignObjectEffect.cs | 10 ++++++---- Pinta.Effects/Effects/BulgeEffect.cs | 2 +- Pinta.Effects/Effects/CloudsEffect.cs | 2 +- Pinta.Effects/Effects/DitheringEffect.cs | 2 +- Pinta.Effects/Effects/EdgeDetectEffect.cs | 2 +- Pinta.Effects/Effects/EmbossEffect.cs | 2 +- Pinta.Effects/Effects/FeatherEffect.cs | 2 +- Pinta.Effects/Effects/FragmentEffect.cs | 2 +- Pinta.Effects/Effects/FrostedGlassEffect.cs | 2 +- Pinta.Effects/Effects/GaussianBlurEffect.cs | 2 +- Pinta.Effects/Effects/GlowEffect.cs | 2 +- Pinta.Effects/Effects/InkSketchEffect.cs | 2 +- Pinta.Effects/Effects/JuliaFractalEffect.cs | 2 +- Pinta.Effects/Effects/MandelbrotFractalEffect.cs | 2 +- Pinta.Effects/Effects/MedianEffect.cs | 2 +- Pinta.Effects/Effects/MotionBlurEffect.cs | 2 +- Pinta.Effects/Effects/OilPaintingEffect.cs | 2 +- Pinta.Effects/Effects/OutlineEdgeEffect.cs | 2 +- Pinta.Effects/Effects/OutlineObjectEffect.cs | 2 +- Pinta.Effects/Effects/PencilSketchEffect.cs | 2 +- Pinta.Effects/Effects/PixelateEffect.cs | 2 +- Pinta.Effects/Effects/RadialBlurEffect.cs | 2 +- Pinta.Effects/Effects/RedEyeRemoveEffect.cs | 2 +- Pinta.Effects/Effects/ReduceNoiseEffect.cs | 2 +- Pinta.Effects/Effects/ReliefEffect.cs | 2 +- Pinta.Effects/Effects/SharpenEffect.cs | 2 +- Pinta.Effects/Effects/SoftenPortraitEffect.cs | 2 +- Pinta.Effects/Effects/TileEffect.cs | 2 +- Pinta.Effects/Effects/TwistEffect.cs | 2 +- Pinta.Effects/Effects/UnfocusEffect.cs | 2 +- Pinta.Effects/Effects/VignetteEffect.cs | 2 +- Pinta.Effects/Effects/VoronoiDiagramEffect.cs | 2 +- Pinta.Effects/Effects/WarpEffect.cs | 2 +- Pinta.Effects/Effects/ZoomBlurEffect.cs | 2 +- Pinta.Effects/Utilities/EffectHelper.cs | 2 +- Pinta.Gui.Widgets/Dialogs/SimpleEffectDialog.cs | 6 +++--- .../Mocks/MockChromeManager.cs | 2 +- tests/PintaBenchmarks/Mocks/MockChromeManager.cs | 2 +- 47 files changed, 67 insertions(+), 72 deletions(-) diff --git a/Pinta.Core/Effects/BaseEffect.cs b/Pinta.Core/Effects/BaseEffect.cs index 79989b10df..c714b1750f 100644 --- a/Pinta.Core/Effects/BaseEffect.cs +++ b/Pinta.Core/Effects/BaseEffect.cs @@ -84,12 +84,13 @@ public abstract class BaseEffect /// Launches the configuration dialog for this effect/adjustment. /// If IsConfigurable is true, the ConfigDialogResponse event will be invoked when the user accepts or cancels the dialog. /// - public virtual Task LaunchConfiguration () + /// Whether the user's response was positive or negative + public virtual Task LaunchConfiguration () { if (IsConfigurable) throw new NotImplementedException ($"{GetType ()} is marked as configurable, but has not implemented LaunchConfiguration"); - return Task.FromResult (Gtk.ResponseType.Ok); // Placeholder + return Task.FromResult (true); // Placeholder } /// @@ -99,7 +100,7 @@ public abstract class BaseEffect /// The localizer for the effect add-in. This is used to fetch translations for the /// strings in the dialog. /// - protected Task LaunchSimpleEffectDialog (AddinLocalizer localizer) + protected Task LaunchSimpleEffectDialog (AddinLocalizer localizer) { return PintaCore.Chrome.LaunchSimpleEffectDialog (this, new AddinLocalizerWrapper (localizer)); } diff --git a/Pinta.Core/Managers/ChromeManager.cs b/Pinta.Core/Managers/ChromeManager.cs index 23f83f9e9b..88cf22124e 100644 --- a/Pinta.Core/Managers/ChromeManager.cs +++ b/Pinta.Core/Managers/ChromeManager.cs @@ -33,7 +33,7 @@ namespace Pinta.Core; public interface IChromeService { Gtk.Window MainWindow { get; } - Task LaunchSimpleEffectDialog (BaseEffect effect, IAddinLocalizer localizer); + Task LaunchSimpleEffectDialog (BaseEffect effect, IAddinLocalizer localizer); } public sealed class ChromeManager : IChromeService @@ -60,11 +60,8 @@ public sealed class ChromeManager : IChromeService public Gio.Menu AdjustmentsMenu { get; private set; } = null!; public Gio.Menu EffectsMenu { get; private set; } = null!; - public ChromeManager () - { - } + public ChromeManager () { } - #region Public Properties public PointI LastCanvasCursorPoint { get => last_canvas_cursor_point; set { @@ -86,9 +83,7 @@ public bool MainWindowBusy { MainWindow.Cursor = Gdk.Cursor.NewFromName (Pinta.Resources.StandardCursors.Default, null); } } - #endregion - #region Public Methods public void InitializeApplication (Gtk.Application application) { Application = application; @@ -165,11 +160,10 @@ public void SetStatusBarText (string text) OnStatusBarTextChanged (text); } - public Task LaunchSimpleEffectDialog (BaseEffect effect, IAddinLocalizer localizer) + public Task LaunchSimpleEffectDialog (BaseEffect effect, IAddinLocalizer localizer) { return simple_effect_dialog_handler (effect, localizer); } - #endregion private void OnLastCanvasCursorPointChanged () { @@ -181,10 +175,8 @@ private void OnStatusBarTextChanged (string text) StatusBarTextChanged?.Invoke (this, new TextChangedEventArgs (text)); } - #region Public Events public event EventHandler? LastCanvasCursorPointChanged; public event EventHandler? StatusBarTextChanged; - #endregion } public interface IProgressDialog @@ -199,4 +191,4 @@ public interface IProgressDialog public delegate void ErrorDialogHandler (Gtk.Window parent, string message, string body, string details); public delegate void MessageDialogHandler (Gtk.Window parent, string message, string body); -public delegate Task SimpleEffectDialogHandler (BaseEffect effect, IAddinLocalizer localizer); +public delegate Task SimpleEffectDialogHandler (BaseEffect effect, IAddinLocalizer localizer); diff --git a/Pinta.Core/Managers/LivePreviewManager.cs b/Pinta.Core/Managers/LivePreviewManager.cs index 6610f63b63..b27d911602 100644 --- a/Pinta.Core/Managers/LivePreviewManager.cs +++ b/Pinta.Core/Managers/LivePreviewManager.cs @@ -138,9 +138,9 @@ public async void Start (BaseEffect effect) if (effect.IsConfigurable) { - Gtk.ResponseType response = await effect.LaunchConfiguration (); + bool response = await effect.LaunchConfiguration (); chrome_manager.MainWindowBusy = true; - if (response == Gtk.ResponseType.Ok) + if (response) Apply (); else Cancel (); diff --git a/Pinta.Effects/Adjustments/BrightnessContrastEffect.cs b/Pinta.Effects/Adjustments/BrightnessContrastEffect.cs index 0f7dd1488f..ced0d9e14e 100644 --- a/Pinta.Effects/Adjustments/BrightnessContrastEffect.cs +++ b/Pinta.Effects/Adjustments/BrightnessContrastEffect.cs @@ -51,7 +51,7 @@ void HandleEffectDataPropertyChanged (object? sender, System.ComponentModel.Prop table_calculated = false; } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); public override void Render (ImageSurface src, ImageSurface dest, ReadOnlySpan rois) diff --git a/Pinta.Effects/Adjustments/CurvesEffect.cs b/Pinta.Effects/Adjustments/CurvesEffect.cs index 3cae7854fc..a95dc56fe2 100644 --- a/Pinta.Effects/Adjustments/CurvesEffect.cs +++ b/Pinta.Effects/Adjustments/CurvesEffect.cs @@ -41,9 +41,9 @@ public CurvesEffect (IServiceProvider services) EffectData = new CurvesData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () { - TaskCompletionSource completionSource = new (); + TaskCompletionSource completionSource = new (); CurvesDialog dialog = new (chrome, Data) { Title = Name, @@ -51,7 +51,7 @@ public CurvesEffect (IServiceProvider services) }; dialog.OnResponse += (_, args) => { - completionSource.SetResult ((Gtk.ResponseType) args.ResponseId); + completionSource.SetResult (Gtk.ResponseType.Ok == (Gtk.ResponseType) args.ResponseId); dialog.Destroy (); }; diff --git a/Pinta.Effects/Adjustments/HueSaturationEffect.cs b/Pinta.Effects/Adjustments/HueSaturationEffect.cs index b39536bd1b..18c03ccf97 100644 --- a/Pinta.Effects/Adjustments/HueSaturationEffect.cs +++ b/Pinta.Effects/Adjustments/HueSaturationEffect.cs @@ -35,7 +35,7 @@ public HueSaturationEffect (IServiceProvider services) EffectData = new HueSaturationData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); private UnaryPixelOp CreateOptimalOp () diff --git a/Pinta.Effects/Adjustments/LevelsEffect.cs b/Pinta.Effects/Adjustments/LevelsEffect.cs index c850a6dbb6..80e8e62154 100644 --- a/Pinta.Effects/Adjustments/LevelsEffect.cs +++ b/Pinta.Effects/Adjustments/LevelsEffect.cs @@ -41,9 +41,9 @@ public LevelsEffect (IServiceProvider services) EffectData = new LevelsData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () { - TaskCompletionSource completionSource = new (); + TaskCompletionSource completionSource = new (); LevelsDialog dialog = new (chrome, workspace, Data) { Title = Name, @@ -51,7 +51,7 @@ public LevelsEffect (IServiceProvider services) }; dialog.OnResponse += (_, args) => { - completionSource.SetResult ((Gtk.ResponseType) args.ResponseId); + completionSource.SetResult (Gtk.ResponseType.Ok == (Gtk.ResponseType) args.ResponseId); dialog.Destroy (); }; diff --git a/Pinta.Effects/Adjustments/PosterizeEffect.cs b/Pinta.Effects/Adjustments/PosterizeEffect.cs index 4b552b2566..3d80850274 100644 --- a/Pinta.Effects/Adjustments/PosterizeEffect.cs +++ b/Pinta.Effects/Adjustments/PosterizeEffect.cs @@ -39,9 +39,9 @@ public PosterizeEffect (IServiceProvider services) EffectData = new PosterizeData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () { - TaskCompletionSource completionSource = new (); + TaskCompletionSource completionSource = new (); PosterizeDialog dialog = new (chrome) { Title = Name, @@ -50,7 +50,7 @@ public PosterizeEffect (IServiceProvider services) }; dialog.OnResponse += (_, args) => { - completionSource.SetResult ((Gtk.ResponseType) args.ResponseId); + completionSource.SetResult (Gtk.ResponseType.Ok == (Gtk.ResponseType) args.ResponseId); dialog.Destroy (); }; diff --git a/Pinta.Effects/Effects/AddNoiseEffect.cs b/Pinta.Effects/Effects/AddNoiseEffect.cs index 2b03240df8..a895d60b42 100644 --- a/Pinta.Effects/Effects/AddNoiseEffect.cs +++ b/Pinta.Effects/Effects/AddNoiseEffect.cs @@ -43,7 +43,7 @@ public AddNoiseEffect (IServiceProvider services) EffectData = new NoiseData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/AlignObjectEffect.cs b/Pinta.Effects/Effects/AlignObjectEffect.cs index 06a7912dc6..995f145ff1 100644 --- a/Pinta.Effects/Effects/AlignObjectEffect.cs +++ b/Pinta.Effects/Effects/AlignObjectEffect.cs @@ -27,19 +27,21 @@ public AlignObjectEffect (IServiceProvider services) chrome = services.GetService (); EffectData = new AlignObjectData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () { - TaskCompletionSource completionSource = new (); + TaskCompletionSource completionSource = new (); AlignmentDialog dialog = new (chrome); // Align to the default position Data.Position = dialog.SelectedPosition; - dialog.PositionChanged += (_, _) => Data.Position = dialog.SelectedPosition; + dialog.PositionChanged += (_, _) => { + Data.Position = dialog.SelectedPosition; + }; dialog.OnResponse += (_, args) => { - completionSource.SetResult ((Gtk.ResponseType) args.ResponseId); + completionSource.SetResult (Gtk.ResponseType.Ok == (Gtk.ResponseType) args.ResponseId); dialog.Destroy (); }; diff --git a/Pinta.Effects/Effects/BulgeEffect.cs b/Pinta.Effects/Effects/BulgeEffect.cs index 4cdb03cac5..bc6c0d8d33 100644 --- a/Pinta.Effects/Effects/BulgeEffect.cs +++ b/Pinta.Effects/Effects/BulgeEffect.cs @@ -37,7 +37,7 @@ public BulgeEffect (IServiceProvider services) EffectData = new BulgeData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/CloudsEffect.cs b/Pinta.Effects/Effects/CloudsEffect.cs index f47188c8f5..dd96bc7ac0 100644 --- a/Pinta.Effects/Effects/CloudsEffect.cs +++ b/Pinta.Effects/Effects/CloudsEffect.cs @@ -51,7 +51,7 @@ public CloudsEffect (IServiceProvider services) EffectData = new CloudsData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/DitheringEffect.cs b/Pinta.Effects/Effects/DitheringEffect.cs index 3d8c5129d0..e6677c0aa6 100644 --- a/Pinta.Effects/Effects/DitheringEffect.cs +++ b/Pinta.Effects/Effects/DitheringEffect.cs @@ -25,7 +25,7 @@ public DitheringEffect (IServiceProvider services) EffectData = new DitheringData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); private sealed record DitheringSettings ( diff --git a/Pinta.Effects/Effects/EdgeDetectEffect.cs b/Pinta.Effects/Effects/EdgeDetectEffect.cs index 634839fe3b..d75471deaa 100644 --- a/Pinta.Effects/Effects/EdgeDetectEffect.cs +++ b/Pinta.Effects/Effects/EdgeDetectEffect.cs @@ -42,7 +42,7 @@ public EdgeDetectEffect (IServiceProvider services) EffectData = new EdgeDetectData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); public override void Render (ImageSurface src, ImageSurface dest, ReadOnlySpan rois) diff --git a/Pinta.Effects/Effects/EmbossEffect.cs b/Pinta.Effects/Effects/EmbossEffect.cs index f7e3e01a19..d38f5b2f8d 100644 --- a/Pinta.Effects/Effects/EmbossEffect.cs +++ b/Pinta.Effects/Effects/EmbossEffect.cs @@ -42,7 +42,7 @@ public EmbossEffect (IServiceProvider services) EffectData = new EmbossData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/FeatherEffect.cs b/Pinta.Effects/Effects/FeatherEffect.cs index bb6993c8e8..21b437c6ca 100644 --- a/Pinta.Effects/Effects/FeatherEffect.cs +++ b/Pinta.Effects/Effects/FeatherEffect.cs @@ -34,7 +34,7 @@ public FeatherEffect (IServiceProvider services) EffectData = new FeatherData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); protected override void Render ( diff --git a/Pinta.Effects/Effects/FragmentEffect.cs b/Pinta.Effects/Effects/FragmentEffect.cs index 2d39ff4970..74b5222add 100644 --- a/Pinta.Effects/Effects/FragmentEffect.cs +++ b/Pinta.Effects/Effects/FragmentEffect.cs @@ -44,7 +44,7 @@ public FragmentEffect (IServiceProvider services) EffectData = new FragmentData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/FrostedGlassEffect.cs b/Pinta.Effects/Effects/FrostedGlassEffect.cs index 1abadef6d2..bbc647aba2 100644 --- a/Pinta.Effects/Effects/FrostedGlassEffect.cs +++ b/Pinta.Effects/Effects/FrostedGlassEffect.cs @@ -37,7 +37,7 @@ public FrostedGlassEffect (IServiceProvider services) EffectData = new FrostedGlassData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/GaussianBlurEffect.cs b/Pinta.Effects/Effects/GaussianBlurEffect.cs index 6e46acd06b..22fc48385a 100644 --- a/Pinta.Effects/Effects/GaussianBlurEffect.cs +++ b/Pinta.Effects/Effects/GaussianBlurEffect.cs @@ -38,7 +38,7 @@ public GaussianBlurEffect (IServiceProvider services) EffectData = new GaussianBlurData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/GlowEffect.cs b/Pinta.Effects/Effects/GlowEffect.cs index c6f3d0a480..e2f111430b 100644 --- a/Pinta.Effects/Effects/GlowEffect.cs +++ b/Pinta.Effects/Effects/GlowEffect.cs @@ -42,7 +42,7 @@ public GlowEffect (IServiceProvider services) this.services = services; } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/InkSketchEffect.cs b/Pinta.Effects/Effects/InkSketchEffect.cs index 46489dc726..2fc864ae6b 100644 --- a/Pinta.Effects/Effects/InkSketchEffect.cs +++ b/Pinta.Effects/Effects/InkSketchEffect.cs @@ -61,7 +61,7 @@ static InkSketchEffect () ); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/JuliaFractalEffect.cs b/Pinta.Effects/Effects/JuliaFractalEffect.cs index 3436b0b6b5..1d505fea2a 100644 --- a/Pinta.Effects/Effects/JuliaFractalEffect.cs +++ b/Pinta.Effects/Effects/JuliaFractalEffect.cs @@ -45,7 +45,7 @@ public JuliaFractalEffect (IServiceProvider services) EffectData = new JuliaFractalData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/MandelbrotFractalEffect.cs b/Pinta.Effects/Effects/MandelbrotFractalEffect.cs index e6e844123d..a037e27744 100644 --- a/Pinta.Effects/Effects/MandelbrotFractalEffect.cs +++ b/Pinta.Effects/Effects/MandelbrotFractalEffect.cs @@ -46,7 +46,7 @@ public MandelbrotFractalEffect (IServiceProvider services) EffectData = new MandelbrotFractalData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/MedianEffect.cs b/Pinta.Effects/Effects/MedianEffect.cs index b8011761de..ecdc1d6c46 100644 --- a/Pinta.Effects/Effects/MedianEffect.cs +++ b/Pinta.Effects/Effects/MedianEffect.cs @@ -40,7 +40,7 @@ public MedianEffect (IServiceProvider services) EffectData = new MedianData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/MotionBlurEffect.cs b/Pinta.Effects/Effects/MotionBlurEffect.cs index 3d4c2bc4a5..50881bdd38 100644 --- a/Pinta.Effects/Effects/MotionBlurEffect.cs +++ b/Pinta.Effects/Effects/MotionBlurEffect.cs @@ -44,7 +44,7 @@ public MotionBlurEffect (IServiceProvider services) EffectData = new MotionBlurData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/OilPaintingEffect.cs b/Pinta.Effects/Effects/OilPaintingEffect.cs index 148297a7d1..12740916f3 100644 --- a/Pinta.Effects/Effects/OilPaintingEffect.cs +++ b/Pinta.Effects/Effects/OilPaintingEffect.cs @@ -37,7 +37,7 @@ public OilPaintingEffect (IServiceProvider services) EffectData = new OilPaintingData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/OutlineEdgeEffect.cs b/Pinta.Effects/Effects/OutlineEdgeEffect.cs index 2bb2beb92e..e640f2dbf8 100644 --- a/Pinta.Effects/Effects/OutlineEdgeEffect.cs +++ b/Pinta.Effects/Effects/OutlineEdgeEffect.cs @@ -40,7 +40,7 @@ public OutlineEdgeEffect (IServiceProvider services) EffectData = new OutlineEdgeData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/OutlineObjectEffect.cs b/Pinta.Effects/Effects/OutlineObjectEffect.cs index 561924abf6..8b90a7f016 100644 --- a/Pinta.Effects/Effects/OutlineObjectEffect.cs +++ b/Pinta.Effects/Effects/OutlineObjectEffect.cs @@ -36,7 +36,7 @@ public OutlineObjectEffect (IServiceProvider services) EffectData = new OutlineObjectData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); protected override void Render (ImageSurface src, ImageSurface dest, RectangleI roi) diff --git a/Pinta.Effects/Effects/PencilSketchEffect.cs b/Pinta.Effects/Effects/PencilSketchEffect.cs index 095ce7333f..c672c83fc6 100644 --- a/Pinta.Effects/Effects/PencilSketchEffect.cs +++ b/Pinta.Effects/Effects/PencilSketchEffect.cs @@ -50,7 +50,7 @@ public PencilSketchEffect (IServiceProvider services) color_dodge_op = new UserBlendOps.ColorDodgeBlendOp (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/PixelateEffect.cs b/Pinta.Effects/Effects/PixelateEffect.cs index adebfeedd5..9c9bf7e690 100644 --- a/Pinta.Effects/Effects/PixelateEffect.cs +++ b/Pinta.Effects/Effects/PixelateEffect.cs @@ -38,7 +38,7 @@ public PixelateEffect (IServiceProvider services) EffectData = new PixelateData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/RadialBlurEffect.cs b/Pinta.Effects/Effects/RadialBlurEffect.cs index 797d830369..11fed5a39b 100644 --- a/Pinta.Effects/Effects/RadialBlurEffect.cs +++ b/Pinta.Effects/Effects/RadialBlurEffect.cs @@ -38,7 +38,7 @@ public RadialBlurEffect (IServiceProvider services) EffectData = new RadialBlurData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/RedEyeRemoveEffect.cs b/Pinta.Effects/Effects/RedEyeRemoveEffect.cs index 92a563f93d..c2533a1f3b 100644 --- a/Pinta.Effects/Effects/RedEyeRemoveEffect.cs +++ b/Pinta.Effects/Effects/RedEyeRemoveEffect.cs @@ -38,7 +38,7 @@ public RedEyeRemoveEffect (IServiceProvider services) EffectData = new RedEyeRemoveData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); public override void Render (ImageSurface src, ImageSurface dest, ReadOnlySpan rois) diff --git a/Pinta.Effects/Effects/ReduceNoiseEffect.cs b/Pinta.Effects/Effects/ReduceNoiseEffect.cs index 4d6e2b724c..7c0f2c61f7 100644 --- a/Pinta.Effects/Effects/ReduceNoiseEffect.cs +++ b/Pinta.Effects/Effects/ReduceNoiseEffect.cs @@ -41,7 +41,7 @@ public ReduceNoiseEffect (IServiceProvider services) EffectData = new ReduceNoiseData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/ReliefEffect.cs b/Pinta.Effects/Effects/ReliefEffect.cs index a3802b9e6e..d3ee6d8413 100644 --- a/Pinta.Effects/Effects/ReliefEffect.cs +++ b/Pinta.Effects/Effects/ReliefEffect.cs @@ -33,7 +33,7 @@ public ReliefEffect (IServiceProvider services) public override string EffectMenuCategory => Translations.GetString ("Stylize"); - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); public override string Icon => Pinta.Resources.Icons.EffectsStylizeRelief; diff --git a/Pinta.Effects/Effects/SharpenEffect.cs b/Pinta.Effects/Effects/SharpenEffect.cs index 653c5a8a7a..8dfd08ebd7 100644 --- a/Pinta.Effects/Effects/SharpenEffect.cs +++ b/Pinta.Effects/Effects/SharpenEffect.cs @@ -38,7 +38,7 @@ public SharpenEffect (IServiceProvider services) EffectData = new SharpenData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); public override void Render (ImageSurface src, ImageSurface dest, ReadOnlySpan rois) diff --git a/Pinta.Effects/Effects/SoftenPortraitEffect.cs b/Pinta.Effects/Effects/SoftenPortraitEffect.cs index b03d3e6c4d..8aee43911b 100644 --- a/Pinta.Effects/Effects/SoftenPortraitEffect.cs +++ b/Pinta.Effects/Effects/SoftenPortraitEffect.cs @@ -74,7 +74,7 @@ public SoftenPortraitEffect (IServiceProvider services) overlay_op = new UserBlendOps.OverlayBlendOp (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); private sealed record SoftenPortraitSettings ( diff --git a/Pinta.Effects/Effects/TileEffect.cs b/Pinta.Effects/Effects/TileEffect.cs index b0a7f69739..1e84412840 100644 --- a/Pinta.Effects/Effects/TileEffect.cs +++ b/Pinta.Effects/Effects/TileEffect.cs @@ -38,7 +38,7 @@ public TileEffect (IServiceProvider services) EffectData = new TileData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/TwistEffect.cs b/Pinta.Effects/Effects/TwistEffect.cs index 4fcded93fe..fcd7d7d3c3 100644 --- a/Pinta.Effects/Effects/TwistEffect.cs +++ b/Pinta.Effects/Effects/TwistEffect.cs @@ -39,7 +39,7 @@ public TwistEffect (IServiceProvider services) EffectData = new TwistData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/UnfocusEffect.cs b/Pinta.Effects/Effects/UnfocusEffect.cs index e27752153d..4d0d83b43c 100644 --- a/Pinta.Effects/Effects/UnfocusEffect.cs +++ b/Pinta.Effects/Effects/UnfocusEffect.cs @@ -40,7 +40,7 @@ public UnfocusEffect (IServiceProvider services) EffectData = new UnfocusData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Effects/VignetteEffect.cs b/Pinta.Effects/Effects/VignetteEffect.cs index 557c79482e..8d1ecb45c7 100644 --- a/Pinta.Effects/Effects/VignetteEffect.cs +++ b/Pinta.Effects/Effects/VignetteEffect.cs @@ -65,7 +65,7 @@ public VignetteEffect (IServiceProvider services) EffectData = new VignetteData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); private sealed record VignetteSettings ( diff --git a/Pinta.Effects/Effects/VoronoiDiagramEffect.cs b/Pinta.Effects/Effects/VoronoiDiagramEffect.cs index 5a7d34f201..e9805dd6be 100644 --- a/Pinta.Effects/Effects/VoronoiDiagramEffect.cs +++ b/Pinta.Effects/Effects/VoronoiDiagramEffect.cs @@ -37,7 +37,7 @@ public VoronoiDiagramEffect (IServiceProvider services) EffectData = new VoronoiDiagramData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); private sealed record VoronoiSettings ( diff --git a/Pinta.Effects/Effects/WarpEffect.cs b/Pinta.Effects/Effects/WarpEffect.cs index 087e219874..4bcf748575 100644 --- a/Pinta.Effects/Effects/WarpEffect.cs +++ b/Pinta.Effects/Effects/WarpEffect.cs @@ -49,7 +49,7 @@ public WarpEffect () EffectData = new WarpData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => Chrome.LaunchSimpleEffectDialog (this); protected double DefaultRadius { get; private set; } = 0; diff --git a/Pinta.Effects/Effects/ZoomBlurEffect.cs b/Pinta.Effects/Effects/ZoomBlurEffect.cs index bbf0b2d68a..64a00146d7 100644 --- a/Pinta.Effects/Effects/ZoomBlurEffect.cs +++ b/Pinta.Effects/Effects/ZoomBlurEffect.cs @@ -37,7 +37,7 @@ public ZoomBlurEffect (IServiceProvider services) EffectData = new ZoomBlurData (); } - public override Task LaunchConfiguration () + public override Task LaunchConfiguration () => chrome.LaunchSimpleEffectDialog (this); #region Algorithm Code Ported From PDN diff --git a/Pinta.Effects/Utilities/EffectHelper.cs b/Pinta.Effects/Utilities/EffectHelper.cs index c6a05c450e..1866bda0f5 100644 --- a/Pinta.Effects/Utilities/EffectHelper.cs +++ b/Pinta.Effects/Utilities/EffectHelper.cs @@ -35,7 +35,7 @@ internal static class EffectHelper /// /// Launch an effect dialog using Pinta's translation template. /// - internal static Task LaunchSimpleEffectDialog (this IChromeService chrome, BaseEffect effect) + internal static Task LaunchSimpleEffectDialog (this IChromeService chrome, BaseEffect effect) => chrome.LaunchSimpleEffectDialog (effect, new PintaLocalizer ()); } diff --git a/Pinta.Gui.Widgets/Dialogs/SimpleEffectDialog.cs b/Pinta.Gui.Widgets/Dialogs/SimpleEffectDialog.cs index a37dd9f31c..7594ab4820 100644 --- a/Pinta.Gui.Widgets/Dialogs/SimpleEffectDialog.cs +++ b/Pinta.Gui.Widgets/Dialogs/SimpleEffectDialog.cs @@ -86,12 +86,12 @@ public SimpleEffectDialog ( /// The IAddinLocalizer provides a generic way to get translated strings both for /// Pinta's effects and for effect add-ins. /// - public static Task Launch (BaseEffect effect, IAddinLocalizer localizer) + public static Task Launch (BaseEffect effect, IAddinLocalizer localizer) { if (effect.EffectData == null) throw new ArgumentException ($"{effect.EffectData} should not be null", nameof (effect)); - TaskCompletionSource responseCompletion = new (); + TaskCompletionSource responseCompletion = new (); SimpleEffectDialog dialog = new ( effect.Name, @@ -103,7 +103,7 @@ public SimpleEffectDialog ( dialog.EffectDataChanged += (o, e) => effect.EffectData.FirePropertyChanged (e.PropertyName); dialog.OnResponse += (_, args) => { - responseCompletion.SetResult ((Gtk.ResponseType) args.ResponseId); + responseCompletion.SetResult (Gtk.ResponseType.Ok == (Gtk.ResponseType) args.ResponseId); dialog.Destroy (); }; diff --git a/tests/Pinta.Effects.Tests/Mocks/MockChromeManager.cs b/tests/Pinta.Effects.Tests/Mocks/MockChromeManager.cs index f54a43c49b..ff229b7947 100644 --- a/tests/Pinta.Effects.Tests/Mocks/MockChromeManager.cs +++ b/tests/Pinta.Effects.Tests/Mocks/MockChromeManager.cs @@ -9,7 +9,7 @@ internal sealed class MockChromeManager : IChromeService { public Gtk.Window MainWindow => throw new NotImplementedException (); - public Task LaunchSimpleEffectDialog (BaseEffect effect, IAddinLocalizer localizer) + public Task LaunchSimpleEffectDialog (BaseEffect effect, IAddinLocalizer localizer) { throw new NotImplementedException (); } diff --git a/tests/PintaBenchmarks/Mocks/MockChromeManager.cs b/tests/PintaBenchmarks/Mocks/MockChromeManager.cs index e33eca0557..66cd271ca8 100644 --- a/tests/PintaBenchmarks/Mocks/MockChromeManager.cs +++ b/tests/PintaBenchmarks/Mocks/MockChromeManager.cs @@ -7,7 +7,7 @@ internal sealed class MockChromeManager : IChromeService { public Gtk.Window MainWindow => throw new NotImplementedException (); - public Task LaunchSimpleEffectDialog (BaseEffect effect, IAddinLocalizer localizer) + public Task LaunchSimpleEffectDialog (BaseEffect effect, IAddinLocalizer localizer) { throw new NotImplementedException (); }