mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-08-03 00:27:11 +02:00
Basic impl of Error Applet (#1551)
This commit is contained in:
parent
f89b754abb
commit
4f65043ad7
8 changed files with 303 additions and 0 deletions
32
Ryujinx/Ui/ErrorAppletDialog.cs
Normal file
32
Ryujinx/Ui/ErrorAppletDialog.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using Gtk;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Ryujinx.Ui
|
||||
{
|
||||
internal class ErrorAppletDialog : MessageDialog
|
||||
{
|
||||
internal static bool _isExitDialogOpen = false;
|
||||
|
||||
public ErrorAppletDialog(Window parentWindow, DialogFlags dialogFlags, MessageType messageType, string[] buttons) : base(parentWindow, dialogFlags, messageType, ButtonsType.None, null)
|
||||
{
|
||||
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
|
||||
|
||||
int responseId = 0;
|
||||
|
||||
if (buttons != null)
|
||||
{
|
||||
foreach (string buttonText in buttons)
|
||||
{
|
||||
AddButton(buttonText, responseId);
|
||||
responseId++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton("OK", 0);
|
||||
}
|
||||
|
||||
ShowAll();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue