diff --git a/ChangeLog b/ChangeLog index 7bdb91cd0..7fe84f67f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-04-01 Mike Kestner + + * gtk/TreeModelFilter.custom : manually implement SetVisibleFunc and + SetModifyFunc to handle delegate persistence. + * gtk/Gtk.metadata : hide methods. + 2005-04-01 Mike Kestner * gtk/Clipboard.custom : manually implement SetWithData and diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index c3628dbe7..7d3d6f99f 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -341,6 +341,8 @@ TooltipSet out out + 1 + 1 model out out diff --git a/gtk/TreeModelFilter.custom b/gtk/TreeModelFilter.custom index 50241e850..14c7a65f3 100644 --- a/gtk/TreeModelFilter.custom +++ b/gtk/TreeModelFilter.custom @@ -57,3 +57,54 @@ val.Dispose (); return ret; } + + [GLib.CDeclCallback] + delegate void DestroyNotify (IntPtr data); + + static void ReleaseCallback (IntPtr data) + { + if (data == IntPtr.Zero) + return; + GCHandle gch = (GCHandle) data; + gch.Free (); + } + + static DestroyNotify release_callback; + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_tree_model_filter_set_visible_func (IntPtr raw, GtkSharp.TreeModelFilterVisibleFuncNative func, IntPtr data, GtkSharp.DestroyNotifyNative destroy); + + [Obsolete ("Replaced by SetVisibleFunc (TreeModelFilterVisibleFunc) overload.")] + public void SetVisibleFunc (TreeModelFilterVisibleFunc func, IntPtr data, Gtk.DestroyNotify destroy) + { + GtkSharp.TreeModelFilterVisibleFuncWrapper func_wrapper = new GtkSharp.TreeModelFilterVisibleFuncWrapper (func); + GtkSharp.DestroyNotifyWrapper destroy_wrapper = new GtkSharp.DestroyNotifyWrapper (destroy); + gtk_tree_model_filter_set_visible_func (Handle, func_wrapper.NativeDelegate, data, destroy_wrapper.NativeDelegate); + } + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_tree_model_filter_set_visible_func (IntPtr raw, GtkSharp.TreeModelFilterVisibleFuncNative func, IntPtr data, DestroyNotify destroy); + public void SetVisibleFunc (TreeModelFilterVisibleFunc func) + { + GtkSharp.TreeModelFilterVisibleFuncWrapper func_wrapper = new GtkSharp.TreeModelFilterVisibleFuncWrapper (func); + if (release_callback == null) + release_callback = new DestroyNotify (ReleaseCallback); + GCHandle gch = GCHandle.Alloc (func_wrapper); + gtk_tree_model_filter_set_visible_func (Handle, func_wrapper.NativeDelegate, (IntPtr) gch, release_callback); + } + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_tree_model_filter_set_modify_func(IntPtr raw, int n_columns, IntPtr[] types, GtkSharp.TreeModelFilterModifyFuncNative func, IntPtr data, DestroyNotify destroy); + + public void SetModifyFunc (int n_columns, GLib.GType[] types, TreeModelFilterModifyFunc func) + { + GtkSharp.TreeModelFilterModifyFuncWrapper func_wrapper = new GtkSharp.TreeModelFilterModifyFuncWrapper (func); + if (release_callback == null) + release_callback = new DestroyNotify (ReleaseCallback); + IntPtr[] native_types = new IntPtr [types.Length]; + for (int i = 0; i < types.Length; i++) + native_types [i] = types [i].Val; + GCHandle gch = GCHandle.Alloc (func_wrapper); + gtk_tree_model_filter_set_modify_func (Handle, n_columns, native_types, func_wrapper.NativeDelegate, (IntPtr) gch, release_callback); + } +