2007-10-04 Mike Kestner <mkestner@novell.com>
* glib/DestroyNotify.cs: add CDeclCallback to the delegate. * glib/Signal.cs: use DestroyHelper. * gdk/Input.custom: use DestroyHelper. * gtk/Quit.custom: remove new on DestroyHelper handler. * gtk/TreeModelFilter.custom: remove new on DestroyHelper handler. * gtk/TreeViewColumn.custom: remove new on DestroyHelper handler. svn path=/trunk/gtk-sharp/; revision=86897
This commit is contained in:
parent
b2db2cda9e
commit
925a2b63c3
7 changed files with 18 additions and 46 deletions
|
@ -1,3 +1,12 @@
|
|||
2007-10-04 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* glib/DestroyNotify.cs: add CDeclCallback to the delegate.
|
||||
* glib/Signal.cs: use DestroyHelper.
|
||||
* gdk/Input.custom: use DestroyHelper.
|
||||
* gtk/Quit.custom: remove new on DestroyHelper handler.
|
||||
* gtk/TreeModelFilter.custom: remove new on DestroyHelper handler.
|
||||
* gtk/TreeViewColumn.custom: remove new on DestroyHelper handler.
|
||||
|
||||
2007-10-02 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* generator/*.cs: implement the interfaces on the adapters too.
|
||||
|
|
|
@ -20,43 +20,21 @@
|
|||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
[GLib.CDeclCallback]
|
||||
delegate void InputDestroyNotify (IntPtr data);
|
||||
|
||||
static void ReleaseGCHandle (IntPtr data)
|
||||
{
|
||||
try {
|
||||
if (data == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
GCHandle gch = (GCHandle) data;
|
||||
gch.Free ();
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
}
|
||||
|
||||
static InputDestroyNotify release_gchandle;
|
||||
|
||||
[DllImport("libgdk-win32-2.0-0.dll")]
|
||||
static extern int gdk_input_add_full (int source, int condition, GdkSharp.InputFunctionNative function, IntPtr data, InputDestroyNotify destroy);
|
||||
static extern int gdk_input_add_full (int source, int condition, GdkSharp.InputFunctionNative function, IntPtr data, GLib.DestroyNotify destroy);
|
||||
|
||||
[Obsolete]
|
||||
public static int AddFull (int source, Gdk.InputCondition condition, Gdk.InputFunction function, IntPtr data, Gdk.DestroyNotify destroy)
|
||||
{
|
||||
if (release_gchandle == null)
|
||||
release_gchandle = new InputDestroyNotify (ReleaseGCHandle);
|
||||
GdkSharp.InputFunctionWrapper function_wrapper = new GdkSharp.InputFunctionWrapper (function);
|
||||
GCHandle gch = GCHandle.Alloc (function_wrapper);
|
||||
return gdk_input_add_full (source, (int) condition, function_wrapper.NativeDelegate, (IntPtr) gch, release_gchandle);
|
||||
return gdk_input_add_full (source, (int) condition, function_wrapper.NativeDelegate, (IntPtr) gch, GLib.DestroyHelper.NotifyHandler);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static int Add (int source, Gdk.InputCondition condition, Gdk.InputFunction function)
|
||||
{
|
||||
if (release_gchandle == null)
|
||||
release_gchandle = new InputDestroyNotify (ReleaseGCHandle);
|
||||
GdkSharp.InputFunctionWrapper function_wrapper = new GdkSharp.InputFunctionWrapper (function);
|
||||
GCHandle gch = GCHandle.Alloc (function_wrapper);
|
||||
return gdk_input_add_full (source, (int) condition, function_wrapper.NativeDelegate, (IntPtr) gch, release_gchandle);
|
||||
return gdk_input_add_full (source, (int) condition, function_wrapper.NativeDelegate, (IntPtr) gch, GLib.DestroyHelper.NotifyHandler);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace GLib {
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[GLib.CDeclCallback]
|
||||
public delegate void DestroyNotify (IntPtr data);
|
||||
|
||||
public class DestroyHelper {
|
||||
|
|
|
@ -51,22 +51,6 @@ namespace GLib {
|
|||
uint after_id = UInt32.MaxValue;
|
||||
Delegate marshaler;
|
||||
|
||||
static SignalDestroyNotify notify = new SignalDestroyNotify (OnNativeDestroy);
|
||||
[CDeclCallback]
|
||||
delegate void SignalDestroyNotify (IntPtr data, IntPtr obj);
|
||||
static void OnNativeDestroy (IntPtr data, IntPtr obj)
|
||||
{
|
||||
try {
|
||||
GCHandle gch = (GCHandle) data;
|
||||
Signal s = gch.Target as Signal;
|
||||
s.DisconnectHandler (s.before_id);
|
||||
s.DisconnectHandler (s.after_id);
|
||||
gch.Free ();
|
||||
} catch (Exception e) {
|
||||
ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
}
|
||||
|
||||
private Signal (GLib.Object obj, string signal_name, Delegate marshaler)
|
||||
{
|
||||
handle = obj.Handle;
|
||||
|
@ -75,7 +59,7 @@ namespace GLib {
|
|||
gc_handle = GCHandle.Alloc (this);
|
||||
IntPtr native_key = GLib.Marshaller.StringToPtrGStrdup (name + "_signal_marshaler");
|
||||
if (handle != IntPtr.Zero)
|
||||
g_object_set_data_full (handle, native_key, (IntPtr) gc_handle, notify);
|
||||
g_object_set_data_full (handle, native_key, (IntPtr) gc_handle, DestroyHelper.NotifyHandler);
|
||||
GLib.Marshaller.Free (native_key);
|
||||
}
|
||||
|
||||
|
@ -209,7 +193,7 @@ namespace GLib {
|
|||
static extern void g_object_set_data (IntPtr instance, IntPtr key, IntPtr data);
|
||||
|
||||
[DllImport("libgobject-2.0-0.dll")]
|
||||
static extern void g_object_set_data_full (IntPtr instance, IntPtr key, IntPtr data, SignalDestroyNotify notify);
|
||||
static extern void g_object_set_data_full (IntPtr instance, IntPtr key, IntPtr data, DestroyNotify notify);
|
||||
|
||||
[DllImport("libgobject-2.0-0.dll")]
|
||||
static extern uint g_signal_connect_data(IntPtr obj, IntPtr name, Delegate cb, IntPtr gc_handle, IntPtr dummy, int flags);
|
||||
|
|
|
@ -69,6 +69,6 @@
|
|||
{
|
||||
GtkSharp.FunctionWrapper function_wrapper = new GtkSharp.FunctionWrapper (function);
|
||||
GCHandle gch = GCHandle.Alloc (function_wrapper);
|
||||
return gtk_quit_add_full (main_level, function_wrapper.NativeDelegate, null, (IntPtr) gch, new GLib.DestroyNotify (GLib.DestroyHelper.NotifyHandler));
|
||||
return gtk_quit_add_full (main_level, function_wrapper.NativeDelegate, null, (IntPtr) gch, GLib.DestroyHelper.NotifyHandler);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
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, new GLib.DestroyNotify (GLib.DestroyHelper.NotifyHandler));
|
||||
gtk_tree_model_filter_set_modify_func (Handle, n_columns, native_types, func_wrapper.NativeDelegate, (IntPtr) gch, GLib.DestroyHelper.NotifyHandler);
|
||||
}
|
||||
|
||||
[DllImport("libgtk-win32-2.0-0.dll")]
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
NodeCellDataFuncWrapper func_wrapper = new NodeCellDataFuncWrapper (func);
|
||||
GCHandle gch = GCHandle.Alloc (func_wrapper);
|
||||
gtk_cell_layout_set_cell_data_func (Handle, cell_renderer == null ? IntPtr.Zero : cell_renderer.Handle, func_wrapper.NativeDelegate, (IntPtr) gch, new GLib.DestroyNotify (GLib.DestroyHelper.NotifyHandler));
|
||||
gtk_cell_layout_set_cell_data_func (Handle, cell_renderer == null ? IntPtr.Zero : cell_renderer.Handle, func_wrapper.NativeDelegate, (IntPtr) gch, GLib.DestroyHelper.NotifyHandler);
|
||||
}
|
||||
|
||||
[Obsolete ("Replaced by SetCellDataFunc (CellRenderer, TreeCellDataFunc) overload")]
|
||||
|
|
Loading…
Reference in a new issue