photomator/Photomator/Program.cs

33 lines
1.7 KiB
C#
Raw Normal View History

2024-09-08 22:37:06 +02:00
using System.Reflection;
using Photomator.Views;
namespace Photomator;
2024-09-14 17:49:20 +02:00
public partial class Program {
2024-09-08 22:37:06 +02:00
public delegate void OpenCallback(nint application, nint[] files, int n_files, nint hint, nint data);
private readonly Adw.Application _application;
public static int Main() => new Program().Run();
2024-09-14 17:49:20 +02:00
public Program() {
2024-09-08 22:37:06 +02:00
_application = Adw.Application.New("de.cantorgymnasium.Photomator", Gio.ApplicationFlags.FlagsNone);
Gtk.Window.SetDefaultIconName("de.cantorgymnasium.Photomator");
2024-09-14 23:22:12 +02:00
string localPath = Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!) + "/de.cantorgymnasium.Photomator.gresource";
if (File.Exists(localPath))
Gio.Functions.ResourcesRegister(Gio.Functions.ResourceLoad(localPath));
2024-09-14 17:49:20 +02:00
else {
2024-09-08 22:37:06 +02:00
var prefixes = new List<string> {
Directory.GetParent(Directory.GetParent(Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!))!.FullName)!.FullName,
Directory.GetParent(Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!))!.FullName,
"/usr"
};
2024-09-14 17:49:20 +02:00
string? prefix = prefixes.Find(prefix => File.Exists(prefix + "/share/de.cantorgymnasium.Photomator/de.cantorgymnasium.Photomator.gresource"));
if (prefix != null)
Gio.Functions.ResourcesRegister(Gio.Functions.ResourceLoad(Path.GetFullPath(prefix + "/share/de.cantorgymnasium.Photomator/de.cantorgymnasium.Photomator.gresource")));
2024-09-08 22:37:06 +02:00
}
_application.OnActivate += (_, _) => new MainWindow(_application).Start();
}
public int Run() => _application.RunWithSynchronizationContext(null);
}