GObject.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using System.Diagnostics;
  3. using System.Runtime.InteropServices;
  4. namespace Avalonia.Gtk3.Interop
  5. {
  6. class GObject : SafeHandle
  7. {
  8. public GObject() : base(IntPtr.Zero, true)
  9. {
  10. }
  11. public GObject(IntPtr handle, bool owned = true) : base(IntPtr.Zero, owned)
  12. {
  13. this.handle = handle;
  14. }
  15. protected override bool ReleaseHandle()
  16. {
  17. if (handle != IntPtr.Zero)
  18. {
  19. Debug.Assert(Native.GTypeCheckInstanceIsFundamentallyA(handle, new IntPtr(Native.G_TYPE_OBJECT)),
  20. "Handle is not a GObject");
  21. Native.GObjectUnref(handle);
  22. }
  23. handle = IntPtr.Zero;
  24. return true;
  25. }
  26. public override bool IsInvalid => handle == IntPtr.Zero;
  27. }
  28. class GInputStream : GObject
  29. {
  30. }
  31. class GtkWidget : GObject
  32. {
  33. }
  34. class GtkWindow : GtkWidget
  35. {
  36. public static GtkWindow Null { get; } = new GtkWindow();
  37. }
  38. class GtkImContext : GObject
  39. {
  40. }
  41. class GdkScreen : GObject
  42. {
  43. public GdkScreen() : base(IntPtr.Zero, false)
  44. {
  45. }
  46. public GdkScreen(IntPtr handle, bool owned = true) : base(handle, owned)
  47. {
  48. this.handle = handle;
  49. }
  50. }
  51. class UnownedGdkScreen : GdkScreen
  52. {
  53. public UnownedGdkScreen() : base(IntPtr.Zero, false)
  54. {
  55. }
  56. public UnownedGdkScreen(IntPtr handle, bool owned = true) : base(IntPtr.Zero, false)
  57. {
  58. this.handle = handle;
  59. }
  60. }
  61. class GtkDialog : GtkWindow
  62. {
  63. }
  64. class GtkFileChooser : GtkDialog
  65. {
  66. }
  67. }