Open badcel opened 10 months ago
Hello @badcel
Great news!
I made Gtk4 into C# with modern function pointer ( delegate* <...>
) and some referenced instances like GTK_WINDOW
, G_APPLICATION
etc...
Example:
namespace Gtk4Test;
using static DeafMan1983.ConvFunctions;
using DeafMan1983.Interop.GTK4;
using static DeafMan1983.Interop.GTK4.Gtk;
using static DeafMan1983.Interop.GTK4.GObject;
using static DeafMan1983.Interop.GTK4.Gio;
unsafe class Program
{
static void activate(GtkApplication* app, void* user_data)
{
GtkWidget* window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), SBytePointerFromString("Window"));
gtk_window_set_default_size(GTK_WINDOW (window), 200, 200);
gtk_window_present(GTK_WINDOW(window));
}
static int Main(string[] args)
{
GtkApplication *app = gtk_application_new(SBytePointerFromString("org.gtk.example"), GApplicationFlags.G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, SBytePointerFromString("activate"), G_CALLBACK (&activate), null);
int status = g_application_run(G_APPLICATION (app), args.Length, SByteDoublePointersFromStringArray(args));
g_object_unref (app);
return status;
}
}
But It is still working in process with Gtk4 :)
Check out my workstatiion if you want know about this.
And I want to tell about GObject will to be as void*
because C# understands hard with instance like other structures example GtkButton
or GdkDisplay
etc....
They should to know void*
I hope I can complete Gtk4 then I will release my complete Gtk4 in C#.
I publish into native aot.
Woohoo! It works fine :D
And more details: adding button...
Great that it works.
In general I think unsafe code should only be used in areas where it makes sense to allow native aot to work. Making the whole internal namespace completely unsafe is probably not the way to go.
If you want to help out you could create a small test program which creates a new GObject (I think you need to derive from GObject.Object to use this constructor) and compile this program into native code and see what it is complaining about.
Optimize code to allow trimming / native AOT:
A first step is probably to enable analyzers and fix the resulting warnings, like @kant2002 mentioned in https://github.com/gircore/gir.core/pull/468#issuecomment-1807558061
Probably depends on #698.