diff --git a/glib/InitiallyUnowned.cs b/glib/InitiallyUnowned.cs index fcd5e5821..ddca29262 100644 --- a/glib/InitiallyUnowned.cs +++ b/glib/InitiallyUnowned.cs @@ -35,6 +35,43 @@ namespace GLib { } } + [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + private static extern void g_object_ref_sink (IntPtr raw); + + protected override IntPtr Raw { + get { + return base.Raw; + } + set { + if (value != IntPtr.Zero) + g_object_ref_sink (value); + base.Raw = value; + } + } + + [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern bool g_object_is_floating (IntPtr raw); + + [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_object_force_floating (IntPtr raw); + + [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_object_unref (IntPtr raw); + + public bool IsFloating { + get { + return g_object_is_floating (Handle); + } + set { + if (value == true) { + if (!IsFloating) + g_object_force_floating (Handle); + } else { + g_object_ref_sink (Handle); + g_object_unref (Handle); + } + } + } } } diff --git a/gtk/Widget.custom b/gtk/Widget.custom index b64aafbb9..28dd96b6c 100644 --- a/gtk/Widget.custom +++ b/gtk/Widget.custom @@ -378,16 +378,11 @@ public void Path (out string path, out string path_reversed) base.Dispose (disposing); } - [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] - private static extern void g_object_ref_sink (IntPtr raw); - protected override IntPtr Raw { get { return base.Raw; } set { - if (value != IntPtr.Zero) - g_object_ref_sink (value); base.Raw = value; if (value != IntPtr.Zero) InternalDestroyed += NativeDestroyHandler; @@ -404,27 +399,3 @@ public void Path (out string path, out string path_reversed) gtk_widget_destroy (Handle); InternalDestroyed -= NativeDestroyHandler; } - - [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] - static extern bool g_object_is_floating (IntPtr raw); - - [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] - static extern void g_object_force_floating (IntPtr raw); - - [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] - static extern void g_object_unref (IntPtr raw); - - public bool IsFloating { - get { - return g_object_is_floating (Handle); - } - set { - if (value == true) { - if (!IsFloating) - g_object_force_floating (Handle); - } else { - g_object_ref_sink (Handle); - g_object_unref (Handle); - } - } - }