Browse Source

Mono support

pull/875/head
Nikita Tsukanov 10 years ago
parent
commit
480801864a
  1. 3
      src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs
  2. 4
      src/Gtk/Avalonia.Gtk3/Interop/Native.cs
  3. 11
      src/Gtk/Avalonia.Gtk3/Interop/Signal.cs

3
src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs

@ -24,7 +24,8 @@ namespace Avalonia.Gtk3
{ {
Resolver.Resolve(); Resolver.Resolve();
Native.GtkInit(0, IntPtr.Zero); Native.GtkInit(0, IntPtr.Zero);
App = Native.GtkApplicationNew("avalonia.app." + Guid.NewGuid(), 0); using (var utf = new Utf8Buffer("avalonia.app." + Guid.NewGuid()))
App = Native.GtkApplicationNew(utf, 0);
//Mark current thread as UI thread //Mark current thread as UI thread
s_tlsMarker = true; s_tlsMarker = true;

4
src/Gtk/Avalonia.Gtk3/Interop/Native.cs

@ -20,7 +20,7 @@ namespace Avalonia.Gtk3.Interop
public static class D public static class D
{ {
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate IntPtr gtk_application_new([MarshalAs(UnmanagedType.AnsiBStr)] string appId, int flags); public delegate IntPtr gtk_application_new(Utf8Buffer appId, int flags);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)]
public delegate void gtk_main_iteration(); public delegate void gtk_main_iteration();
@ -113,7 +113,7 @@ namespace Avalonia.Gtk3.Interop
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)] [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)]
public delegate void gdk_window_invalidate_rect(IntPtr window, ref GdkRectangle rect, bool invalidate_children); public delegate void gdk_window_invalidate_rect(IntPtr window, ref GdkRectangle rect, bool invalidate_children);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)] [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)]
public delegate ulong g_signal_connect_object(IntPtr instance, [MarshalAs(UnmanagedType.AnsiBStr)]string signal, IntPtr handler, IntPtr userData, int flags); public delegate ulong g_signal_connect_object(IntPtr instance, Utf8Buffer signal, IntPtr handler, IntPtr userData, int flags);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)] [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)]
public delegate ulong g_signal_handler_disconnect(IntPtr instance, ulong connectionId); public delegate ulong g_signal_handler_disconnect(IntPtr instance, ulong connectionId);
[UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Glib)] [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Glib)]

11
src/Gtk/Avalonia.Gtk3/Interop/Signal.cs

@ -36,10 +36,13 @@ namespace Avalonia.Gtk3.Interop
{ {
var handle = GCHandle.Alloc(handler); var handle = GCHandle.Alloc(handler);
var ptr = Marshal.GetFunctionPointerForDelegate((Delegate)(object)handler); var ptr = Marshal.GetFunctionPointerForDelegate((Delegate)(object)handler);
var id = Native.GSignalConnectObject(obj, name, ptr, IntPtr.Zero, 0); using (var utf = new Utf8Buffer(name))
if (id == 0) {
throw new ArgumentException("Unable to connect to signal " + name); var id = Native.GSignalConnectObject(obj, utf, ptr, IntPtr.Zero, 0);
return new ConnectedSignal(obj, handle, id); if (id == 0)
throw new ArgumentException("Unable to connect to signal " + name);
return new ConnectedSignal(obj, handle, id);
}
} }
} }
} }

Loading…
Cancel
Save