Skip to content

Commit

Permalink
Changed signature of MessageDialogHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehonti committed Oct 3, 2024
1 parent 6bff15e commit c13f80f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Pinta.Core/Managers/ChromeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ public void ShowErrorDialog (Gtk.Window parent, string message, string body, str
error_dialog_handler (parent, message, body, details);
}

public void ShowMessageDialog (Gtk.Window parent, string message, string body)
public Task ShowMessageDialog (Gtk.Window parent, string message, string body)
{
message_dialog_handler (parent, message, body);
return message_dialog_handler (parent, message, body);
}

public void SetStatusBarText (string text)
Expand Down Expand Up @@ -190,5 +190,5 @@ 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 MessageDialogHandler (Gtk.Window parent, string message, string body);
public delegate Task<bool> SimpleEffectDialogHandler (BaseEffect effect, IAddinLocalizer localizer);
6 changes: 3 additions & 3 deletions Pinta.Effects/Effects/ReduceNoiseEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed class ReduceNoiseEffect : LocalHistogramEffect
private int radius;
private double strength;

public override string Icon => Pinta.Resources.Icons.EffectsNoiseReduceNoise;
public override string Icon => Resources.Icons.EffectsNoiseReduceNoise;

public sealed override bool IsTileable => true;

Expand All @@ -47,13 +47,13 @@ public override Task<bool> LaunchConfiguration ()
#region Algorithm Code Ported From PDN
public override ColorBgra Apply (in ColorBgra color, int area, Span<int> hb, Span<int> hg, Span<int> hr, Span<int> ha)
{
ColorBgra normalized = GetPercentileOfColor (color, area, hb, hg, hr, ha);
ColorBgra normalized = GetPercentileOfColor (color, area, hb, hg, hr);
double lerp = strength * (1 - 0.75 * color.GetIntensity ());

return ColorBgra.Lerp (color, normalized, lerp);
}

private static ColorBgra GetPercentileOfColor (ColorBgra color, int area, Span<int> hb, Span<int> hg, Span<int> hr, Span<int> ha)
private static ColorBgra GetPercentileOfColor (ColorBgra color, int area, Span<int> hb, Span<int> hg, Span<int> hr)
{
int rc = 0;
int gc = 0;
Expand Down
12 changes: 10 additions & 2 deletions Pinta/Dialogs/ErrorDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System.Threading.Tasks;
using Pinta.Core;

namespace Pinta;
Expand All @@ -36,21 +37,28 @@ internal ErrorDialog (HelpActions help)
this.help = help;
}

internal static void ShowMessage (
internal static Task ShowMessage (
Gtk.Window parent,
string message,
string body)
{
TaskCompletionSource completionSource = new ();

System.Console.Error.WriteLine ("Pinta: {0}\n{1}", message, body);

var dialog = Adw.MessageDialog.New (parent, message, body);
Adw.MessageDialog dialog = Adw.MessageDialog.New (parent, message, body);

const string ok_response = "ok";

dialog.AddResponse (ok_response, Translations.GetString ("_OK"));
dialog.DefaultResponse = ok_response;
dialog.CloseResponse = ok_response;

dialog.OnResponse += (_, _) => completionSource.SetResult ();

dialog.Present ();

return completionSource.Task;
}

internal void ShowError (
Expand Down

0 comments on commit c13f80f

Please sign in to comment.