GObject.cs 1.8 KB

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