ui: migrate client to gtk

This commit is contained in:
2025-06-17 09:40:10 +02:00
parent 0aa6ed98c6
commit 30b1832cd0
14 changed files with 664 additions and 2646 deletions

View File

@@ -1,9 +1,12 @@
using Castle.Core.Logging;
using Gtk;
using ModpackUpdater.Manager;
using Newtonsoft.Json;
using Pilz;
using Pilz.Configuration;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
[assembly: AssemblyAppVersion("1.7.0.0")]
@@ -13,6 +16,7 @@ public static class Program
{
private static readonly SettingsManager settingsManager;
private static readonly ILogger log = new ConsoleLogger();
private static Application uiApp;
public static ISettings Settings => settingsManager.Instance;
@@ -49,11 +53,46 @@ public static class Program
private static void RunApp(UpdateCheckOptionsAdv updateOptions)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
AppGlobals.Initialize();
Application.Run(new Form1(updateOptions));
Application.Init();
uiApp = new Application("ModpackUpdater.Apps.Client", GLib.ApplicationFlags.None);
uiApp.Register(GLib.Cancellable.Current);
var win = new MainWindow(updateOptions);
uiApp.AddWindow(win);
win.Show();
Application.Run();
}
public static void Restart()
{
var process = Process.GetCurrentProcess();
var arguments = Environment.GetCommandLineArgs();
ProcessStartInfo currentStartInfo = new()
{
FileName = Environment.ProcessPath,
};
if (arguments.Length >= 2)
{
var sb = new StringBuilder((arguments.Length - 1) * 16);
for (int argumentIndex = 1; argumentIndex < arguments.Length; argumentIndex++)
sb.Append($"\"{arguments[argumentIndex]}\" ");
currentStartInfo.Arguments = sb.ToString(0, sb.Length - 1);
}
// Close the current application
Application.Quit();
// Start a new process
Process.Start(currentStartInfo);
// Close this proccess
Environment.Exit(0);
}
private static string GetSettingsPath(int? settingsVersion = 3)