2020-08-02 21:30:58 -04:00
|
|
|
using Gtk;
|
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
using Ryujinx.HLE;
|
|
|
|
using Ryujinx.HLE.HOS.Applets;
|
|
|
|
using System;
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
namespace Ryujinx.Ui
|
|
|
|
{
|
|
|
|
internal class GtkHostUiHandler : IHostUiHandler
|
|
|
|
{
|
|
|
|
private readonly Window _parent;
|
|
|
|
|
|
|
|
public GtkHostUiHandler(Window parent)
|
|
|
|
{
|
|
|
|
_parent = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool DisplayInputDialog(SoftwareKeyboardUiArgs args, out string userText)
|
|
|
|
{
|
|
|
|
ManualResetEvent dialogCloseEvent = new ManualResetEvent(false);
|
|
|
|
bool okPressed = false;
|
|
|
|
bool error = false;
|
|
|
|
string inputText = args.InitialText ?? "";
|
|
|
|
|
|
|
|
Application.Invoke(delegate
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var swkbdDialog = new InputDialog(_parent)
|
|
|
|
{
|
|
|
|
Title = "Software Keyboard",
|
|
|
|
Text = args.HeaderText,
|
|
|
|
SecondaryText = args.SubtitleText
|
|
|
|
};
|
|
|
|
|
|
|
|
swkbdDialog.InputEntry.Text = inputText;
|
|
|
|
swkbdDialog.InputEntry.PlaceholderText = args.GuideText;
|
|
|
|
swkbdDialog.OkButton.Label = args.SubmitText;
|
|
|
|
|
|
|
|
swkbdDialog.SetInputLengthValidation(args.StringLengthMin, args.StringLengthMax);
|
|
|
|
|
|
|
|
if (swkbdDialog.Run() == (int)ResponseType.Ok)
|
|
|
|
{
|
|
|
|
inputText = swkbdDialog.InputEntry.Text;
|
|
|
|
okPressed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
swkbdDialog.Dispose();
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
error = true;
|
2020-08-03 19:32:53 -04:00
|
|
|
Logger.Error?.Print(LogClass.Application, $"Error displaying Software Keyboard: {e}");
|
2020-08-02 21:30:58 -04:00
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
dialogCloseEvent.Set();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
dialogCloseEvent.WaitOne();
|
|
|
|
|
|
|
|
userText = error ? null : inputText;
|
|
|
|
|
|
|
|
return error || okPressed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|