diff options
author | Mary Guillemard <mary@mary.zone> | 2024-03-02 12:51:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-02 12:51:05 +0100 |
commit | ec6cb0abb4b7669895b6e96fd7581c93b5abd691 (patch) | |
tree | 128c862ff5faea0b219467656d4023bee7faefb5 /src/Ryujinx.Gtk3/UI/Widgets/GtkDialog.cs | |
parent | 53b5985da6b9d7b281d9fc25b93bfd1d1918a107 (diff) |
infra: Make Avalonia the default UI (#6375)1.1.1216
* misc: Move Ryujinx project to Ryujinx.Gtk3
This breaks release CI for now but that's fine.
Signed-off-by: Mary Guillemard <mary@mary.zone>
* misc: Move Ryujinx.Ava project to Ryujinx
This breaks CI for now, but it's fine.
Signed-off-by: Mary Guillemard <mary@mary.zone>
* infra: Make Avalonia the default UI
Should fix CI after the previous changes.
GTK3 isn't build by the release job anymore, only by PR CI.
This also ensure that the test-ava update package is still generated to
allow update from the old testing channel.
Signed-off-by: Mary Guillemard <mary@mary.zone>
* Fix missing copy in create_app_bundle.sh
Signed-off-by: Mary Guillemard <mary@mary.zone>
* Fix syntax error
Signed-off-by: Mary Guillemard <mary@mary.zone>
---------
Signed-off-by: Mary Guillemard <mary@mary.zone>
Diffstat (limited to 'src/Ryujinx.Gtk3/UI/Widgets/GtkDialog.cs')
-rw-r--r-- | src/Ryujinx.Gtk3/UI/Widgets/GtkDialog.cs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/Ryujinx.Gtk3/UI/Widgets/GtkDialog.cs b/src/Ryujinx.Gtk3/UI/Widgets/GtkDialog.cs new file mode 100644 index 00000000..567f9ad6 --- /dev/null +++ b/src/Ryujinx.Gtk3/UI/Widgets/GtkDialog.cs @@ -0,0 +1,114 @@ +using Gtk; +using Ryujinx.Common.Logging; +using Ryujinx.UI.Common.Configuration; +using System.Collections.Generic; +using System.Reflection; + +namespace Ryujinx.UI.Widgets +{ + internal class GtkDialog : MessageDialog + { + private static bool _isChoiceDialogOpen; + + private GtkDialog(string title, string mainText, string secondaryText, MessageType messageType = MessageType.Other, ButtonsType buttonsType = ButtonsType.Ok) + : base(null, DialogFlags.Modal, messageType, buttonsType, null) + { + Title = title; + Icon = new Gdk.Pixbuf(Assembly.GetAssembly(typeof(ConfigurationState)), "Ryujinx.UI.Common.Resources.Logo_Ryujinx.png"); + Text = mainText; + SecondaryText = secondaryText; + WindowPosition = WindowPosition.Center; + SecondaryUseMarkup = true; + + Response += GtkDialog_Response; + + SetSizeRequest(200, 20); + } + + private void GtkDialog_Response(object sender, ResponseArgs args) + { + Dispose(); + } + + internal static void CreateInfoDialog(string mainText, string secondaryText) + { + new GtkDialog("Ryujinx - Info", mainText, secondaryText, MessageType.Info).Run(); + } + + internal static void CreateUpdaterInfoDialog(string mainText, string secondaryText) + { + new GtkDialog("Ryujinx - Updater", mainText, secondaryText, MessageType.Info).Run(); + } + + internal static MessageDialog CreateWaitingDialog(string mainText, string secondaryText) + { + return new GtkDialog("Ryujinx - Waiting", mainText, secondaryText, MessageType.Info, ButtonsType.None); + } + + internal static void CreateWarningDialog(string mainText, string secondaryText) + { + new GtkDialog("Ryujinx - Warning", mainText, secondaryText, MessageType.Warning).Run(); + } + + internal static void CreateErrorDialog(string errorMessage) + { + Logger.Error?.Print(LogClass.Application, errorMessage); + + new GtkDialog("Ryujinx - Error", "Ryujinx has encountered an error", errorMessage, MessageType.Error).Run(); + } + + internal static MessageDialog CreateConfirmationDialog(string mainText, string secondaryText = "") + { + return new GtkDialog("Ryujinx - Confirmation", mainText, secondaryText, MessageType.Question, ButtonsType.YesNo); + } + + internal static bool CreateChoiceDialog(string title, string mainText, string secondaryText) + { + if (_isChoiceDialogOpen) + { + return false; + } + + _isChoiceDialogOpen = true; + + ResponseType response = (ResponseType)new GtkDialog(title, mainText, secondaryText, MessageType.Question, ButtonsType.YesNo).Run(); + + _isChoiceDialogOpen = false; + + return response == ResponseType.Yes; + } + + internal static ResponseType CreateCustomDialog(string title, string mainText, string secondaryText, Dictionary<int, string> buttons, MessageType messageType = MessageType.Other) + { + GtkDialog gtkDialog = new(title, mainText, secondaryText, messageType, ButtonsType.None); + + foreach (var button in buttons) + { + gtkDialog.AddButton(button.Value, button.Key); + } + + return (ResponseType)gtkDialog.Run(); + } + + internal static string CreateInputDialog(Window parent, string title, string mainText, uint inputMax) + { + GtkInputDialog gtkDialog = new(parent, title, mainText, inputMax); + ResponseType response = (ResponseType)gtkDialog.Run(); + string responseText = gtkDialog.InputEntry.Text.TrimEnd(); + + gtkDialog.Dispose(); + + if (response == ResponseType.Ok) + { + return responseText; + } + + return ""; + } + + internal static bool CreateExitDialog() + { + return CreateChoiceDialog("Ryujinx - Exit", "Are you sure you want to close Ryujinx?", "All unsaved data will be lost!"); + } + } +} |