From 4f65043ad77dcc37d9195b2a5e976d102421b82a Mon Sep 17 00:00:00 2001 From: Ac_K <Acoustik666@gmail.com> Date: Mon, 28 Sep 2020 00:00:38 +0200 Subject: Basic impl of Error Applet (#1551) --- Ryujinx/Ui/GtkHostUiHandler.cs | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'Ryujinx/Ui/GtkHostUiHandler.cs') diff --git a/Ryujinx/Ui/GtkHostUiHandler.cs b/Ryujinx/Ui/GtkHostUiHandler.cs index fd193dd7..12ba81c4 100644 --- a/Ryujinx/Ui/GtkHostUiHandler.cs +++ b/Ryujinx/Ui/GtkHostUiHandler.cs @@ -128,5 +128,56 @@ namespace Ryujinx.Ui device.UserChannelPersistence.ExecuteProgram(kind, value); MainWindow.GlWidget?.Exit(); } + + public bool DisplayErrorAppletDialog(string title, string message, string[] buttons) + { + ManualResetEvent dialogCloseEvent = new ManualResetEvent(false); + bool showDetails = false; + + Application.Invoke(delegate + { + try + { + ErrorAppletDialog msgDialog = new ErrorAppletDialog(_parent, DialogFlags.DestroyWithParent, MessageType.Error, buttons) + { + Title = title, + Text = message, + UseMarkup = true, + WindowPosition = WindowPosition.CenterAlways + }; + + msgDialog.SetDefaultSize(400, 0); + + msgDialog.Response += (object o, ResponseArgs args) => + { + if (buttons != null) + { + if (buttons.Length > 1) + { + if (args.ResponseId != (ResponseType)(buttons.Length - 1)) + { + showDetails = true; + } + } + } + + dialogCloseEvent.Set(); + msgDialog?.Dispose(); + }; + + msgDialog.Show(); + } + catch (Exception e) + { + Logger.Error?.Print(LogClass.Application, $"Error displaying ErrorApplet Dialog: {e}"); + + dialogCloseEvent.Set(); + } + }); + + dialogCloseEvent.WaitOne(); + + return showDetails; + } } } -- cgit v1.2.3-70-g09d2