Simplified Signal handling
* gdk/Display.custom: rework signal connection * gdk/Window.custom: rework signal connection * generator/Signal.cs: generate for new API. * glib/Object.cs: add (Add|Remove)SignalHandler methods and use them for the Notify connections. Move to generic collections for everything but the Data hash. * glib/Signal.cs: kill Lookup methods and add delegate fields * glib/ToggleRef.cs: remove Signals hash, it doesn't belong here. * gtk/Clipboard.custom: rework signal connection * gtk/ListStore.custom: rework signal connection * gtk/TextView.custom: remove obsolete signal * gtk/TreeModelAdapter.custom: rework signal connection * gtk/TreeModelFilter.custom: rework signal connection * gtk/TreeModelSort.custom: rework signal connection * gtk/TreeStore.custom: rework signal connection * gtk/Widget.custom: rework signal connection * gtk/Window.custom: remove obsolete signal
This commit is contained in:
parent
db738c401b
commit
6be0718ff2
15 changed files with 129 additions and 374 deletions
|
@ -79,9 +79,9 @@
|
|||
public void AddClientMessageFilter (Gdk.Atom message_type, Gdk.FilterFunc func)
|
||||
{
|
||||
GdkSharp.FilterFuncWrapper func_wrapper = new GdkSharp.FilterFuncWrapper (func);
|
||||
if (!PersistentData.Contains ("client_message_filter_func_list"))
|
||||
PersistentData ["client_message_filter_func_list"] = new ArrayList ();
|
||||
ArrayList func_list = PersistentData ["client_message_filter_func_list"] as ArrayList;
|
||||
if (!Data.Contains ("client_message_filter_func_list"))
|
||||
Data ["client_message_filter_func_list"] = new ArrayList ();
|
||||
ArrayList func_list = Data ["client_message_filter_func_list"] as ArrayList;
|
||||
func_list.Add (func_wrapper);
|
||||
gdk_display_add_client_message_filter (Handle, message_type == null ? IntPtr.Zero : message_type.Handle, func_wrapper.NativeDelegate, IntPtr.Zero);
|
||||
}
|
||||
|
|
|
@ -130,9 +130,9 @@
|
|||
|
||||
public void AddFilter (FilterFunc function)
|
||||
{
|
||||
if (!PersistentData.Contains ("filter_func_hash"))
|
||||
PersistentData ["filter_func_hash"] = new Hashtable ();
|
||||
Hashtable hash = PersistentData ["filter_func_hash"] as Hashtable;
|
||||
if (!Data.Contains ("filter_func_hash"))
|
||||
Data ["filter_func_hash"] = new Hashtable ();
|
||||
Hashtable hash = Data ["filter_func_hash"] as Hashtable;
|
||||
GdkSharp.FilterFuncWrapper wrapper = new GdkSharp.FilterFuncWrapper (function);
|
||||
hash [function] = wrapper;
|
||||
gdk_window_add_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
|
||||
|
@ -140,7 +140,7 @@
|
|||
|
||||
public void RemoveFilter (FilterFunc function)
|
||||
{
|
||||
Hashtable hash = PersistentData ["filter_func_hash"] as Hashtable;
|
||||
Hashtable hash = Data ["filter_func_hash"] as Hashtable;
|
||||
GdkSharp.FilterFuncWrapper wrapper = hash [function] as GdkSharp.FilterFuncWrapper;
|
||||
if (wrapper == null)
|
||||
return;
|
||||
|
|
|
@ -305,12 +305,10 @@ namespace GtkSharp.Generation {
|
|||
sw.Write("new ");
|
||||
sw.WriteLine("event " + EventHandlerQualifiedName + " " + Name + " {");
|
||||
sw.WriteLine("\t\t\tadd {");
|
||||
sw.WriteLine("\t\t\t\tGLib.Signal sig = GLib.Signal.Lookup (" + target + ", " + CName + args_type + ");");
|
||||
sw.WriteLine("\t\t\t\tsig.AddDelegate (value);");
|
||||
sw.WriteLine("\t\t\t\t{0}.AddSignalHandler ({1}, value{2});", target, CName, args_type);
|
||||
sw.WriteLine("\t\t\t}");
|
||||
sw.WriteLine("\t\t\tremove {");
|
||||
sw.WriteLine("\t\t\t\tGLib.Signal sig = GLib.Signal.Lookup (" + target + ", " + CName + args_type + ");");
|
||||
sw.WriteLine("\t\t\t\tsig.RemoveDelegate (value);");
|
||||
sw.WriteLine("\t\t\t\t{0}.RemoveSignalHandler ({1}, value);", target, CName);
|
||||
sw.WriteLine("\t\t\t}");
|
||||
sw.WriteLine("\t\t}");
|
||||
sw.WriteLine();
|
||||
|
|
199
glib/Object.cs
199
glib/Object.cs
|
@ -23,7 +23,7 @@
|
|||
namespace GLib {
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -34,9 +34,8 @@ namespace GLib {
|
|||
IntPtr handle;
|
||||
ToggleRef tref;
|
||||
bool disposed = false;
|
||||
Hashtable data;
|
||||
static Hashtable Objects = new Hashtable();
|
||||
static ArrayList PendingDestroys = new ArrayList ();
|
||||
static Dictionary<IntPtr, ToggleRef> Objects = new Dictionary<IntPtr, ToggleRef>();
|
||||
static List<ToggleRef> PendingDestroys = new List<ToggleRef> ();
|
||||
static bool idle_queued;
|
||||
|
||||
~Object ()
|
||||
|
@ -59,10 +58,10 @@ namespace GLib {
|
|||
|
||||
static bool PerformQueuedUnrefs ()
|
||||
{
|
||||
object [] references;
|
||||
ToggleRef[] references;
|
||||
|
||||
lock (PendingDestroys){
|
||||
references = new object [PendingDestroys.Count];
|
||||
references = new ToggleRef [PendingDestroys.Count];
|
||||
PendingDestroys.CopyTo (references, 0);
|
||||
PendingDestroys.Clear ();
|
||||
idle_queued = false;
|
||||
|
@ -80,8 +79,9 @@ namespace GLib {
|
|||
return;
|
||||
|
||||
disposed = true;
|
||||
ToggleRef toggle_ref = Objects [Handle] as ToggleRef;
|
||||
Objects.Remove (Handle);
|
||||
ToggleRef toggle_ref;
|
||||
if (Objects.TryGetValue (Handle, out toggle_ref))
|
||||
Objects.Remove (Handle);
|
||||
try {
|
||||
if (toggle_ref != null)
|
||||
toggle_ref.Free ();
|
||||
|
@ -103,8 +103,8 @@ namespace GLib {
|
|||
|
||||
Object obj = null;
|
||||
|
||||
if (Objects.Contains (o)) {
|
||||
ToggleRef toggle_ref = Objects [o] as ToggleRef;
|
||||
ToggleRef toggle_ref;
|
||||
if (Objects.TryGetValue (o, out toggle_ref)) {
|
||||
if (toggle_ref != null)
|
||||
obj = toggle_ref.Target;
|
||||
}
|
||||
|
@ -166,11 +166,11 @@ namespace GLib {
|
|||
|
||||
// Key: The pointer to the ParamSpec of the property
|
||||
// Value: The corresponding PropertyInfo object
|
||||
static Hashtable properties;
|
||||
static Hashtable Properties {
|
||||
static Dictionary<IntPtr, PropertyInfo> properties;
|
||||
static Dictionary<IntPtr, PropertyInfo> Properties {
|
||||
get {
|
||||
if (properties == null)
|
||||
properties = new Hashtable ();
|
||||
properties = new Dictionary<IntPtr, PropertyInfo> ();
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
|
@ -298,11 +298,11 @@ namespace GLib {
|
|||
|
||||
static void GetPropertyCallback (IntPtr handle, uint property_id, ref GLib.Value value, IntPtr param_spec)
|
||||
{
|
||||
if (!Properties.Contains (param_spec))
|
||||
if (!Properties.ContainsKey (param_spec))
|
||||
return;
|
||||
|
||||
GLib.Object obj = GLib.Object.GetObject (handle, false);
|
||||
value.Val = (Properties [param_spec] as PropertyInfo).GetValue (obj, new object [0]);
|
||||
value.Val = Properties [param_spec].GetValue (obj, new object [0]);
|
||||
}
|
||||
|
||||
static GetPropertyDelegate get_property_handler;
|
||||
|
@ -319,11 +319,11 @@ namespace GLib {
|
|||
|
||||
static void SetPropertyCallback(IntPtr handle, uint property_id, ref GLib.Value value, IntPtr param_spec)
|
||||
{
|
||||
if (!Properties.Contains (param_spec))
|
||||
if (!Properties.ContainsKey (param_spec))
|
||||
return;
|
||||
|
||||
GLib.Object obj = GLib.Object.GetObject (handle, false);
|
||||
(Properties [param_spec] as PropertyInfo).SetValue (obj, value.Val, new object [0]);
|
||||
Properties [param_spec].SetValue (obj, value.Val, new object [0]);
|
||||
}
|
||||
|
||||
static SetPropertyDelegate set_property_handler;
|
||||
|
@ -456,131 +456,47 @@ namespace GLib {
|
|||
}
|
||||
|
||||
public static GLib.GType GType {
|
||||
get {
|
||||
return GType.Object;
|
||||
}
|
||||
get { return GType.Object; }
|
||||
}
|
||||
|
||||
protected string TypeName {
|
||||
get {
|
||||
return NativeType.ToString ();
|
||||
}
|
||||
get { return NativeType.ToString (); }
|
||||
}
|
||||
|
||||
internal GLib.GType NativeType {
|
||||
get {
|
||||
return LookupGType ();
|
||||
}
|
||||
get { return LookupGType (); }
|
||||
}
|
||||
|
||||
internal ToggleRef ToggleRef {
|
||||
get {
|
||||
return tref;
|
||||
}
|
||||
get { return tref; }
|
||||
}
|
||||
|
||||
public IntPtr Handle {
|
||||
get {
|
||||
return handle;
|
||||
}
|
||||
get { return handle; }
|
||||
}
|
||||
|
||||
public IntPtr OwnedHandle {
|
||||
get {
|
||||
return g_object_ref (handle);
|
||||
}
|
||||
}
|
||||
|
||||
Hashtable before_signals;
|
||||
[Obsolete ("Replaced by GLib.Signal marshaling mechanism.")]
|
||||
protected internal Hashtable BeforeSignals {
|
||||
get {
|
||||
if (before_signals == null)
|
||||
before_signals = new Hashtable ();
|
||||
return before_signals;
|
||||
}
|
||||
}
|
||||
|
||||
Hashtable after_signals;
|
||||
[Obsolete ("Replaced by GLib.Signal marshaling mechanism.")]
|
||||
protected internal Hashtable AfterSignals {
|
||||
get {
|
||||
if (after_signals == null)
|
||||
after_signals = new Hashtable ();
|
||||
return after_signals;
|
||||
}
|
||||
}
|
||||
|
||||
EventHandlerList before_handlers;
|
||||
[Obsolete ("Replaced by GLib.Signal marshaling mechanism.")]
|
||||
protected EventHandlerList BeforeHandlers {
|
||||
get {
|
||||
if (before_handlers == null)
|
||||
before_handlers = new EventHandlerList ();
|
||||
return before_handlers;
|
||||
}
|
||||
}
|
||||
|
||||
EventHandlerList after_handlers;
|
||||
[Obsolete ("Replaced by GLib.Signal marshaling mechanism.")]
|
||||
protected EventHandlerList AfterHandlers {
|
||||
get {
|
||||
if (after_handlers == null)
|
||||
after_handlers = new EventHandlerList ();
|
||||
return after_handlers;
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
delegate void NotifyDelegate (IntPtr handle, IntPtr pspec, IntPtr gch);
|
||||
|
||||
void NotifyCallback (IntPtr handle, IntPtr pspec, IntPtr gch)
|
||||
{
|
||||
try {
|
||||
GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
|
||||
if (sig == null)
|
||||
throw new Exception("Unknown signal GC handle received " + gch);
|
||||
|
||||
NotifyArgs args = new NotifyArgs ();
|
||||
args.Args = new object[1];
|
||||
args.Args[0] = pspec;
|
||||
NotifyHandler handler = (NotifyHandler) sig.Handler;
|
||||
handler (GLib.Object.GetObject (handle), args);
|
||||
} catch (Exception e) {
|
||||
ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectNotification (string signal, NotifyHandler handler)
|
||||
{
|
||||
Signal sig = Signal.Lookup (this, signal, new NotifyDelegate (NotifyCallback));
|
||||
sig.AddDelegate (handler);
|
||||
get { return g_object_ref (handle); }
|
||||
}
|
||||
|
||||
public void AddNotification (string property, NotifyHandler handler)
|
||||
{
|
||||
ConnectNotification ("notify::" + property, handler);
|
||||
AddSignalHandler ("notify::" + property, handler, typeof(NotifyArgs));
|
||||
}
|
||||
|
||||
public void AddNotification (NotifyHandler handler)
|
||||
{
|
||||
ConnectNotification ("notify", handler);
|
||||
}
|
||||
|
||||
void DisconnectNotification (string signal, NotifyHandler handler)
|
||||
{
|
||||
Signal sig = Signal.Lookup (this, signal, new NotifyDelegate (NotifyCallback));
|
||||
sig.RemoveDelegate (handler);
|
||||
AddSignalHandler ("notify", handler, typeof(NotifyArgs));
|
||||
}
|
||||
|
||||
public void RemoveNotification (string property, NotifyHandler handler)
|
||||
{
|
||||
DisconnectNotification ("notify::" + property, handler);
|
||||
RemoveSignalHandler ("notify::" + property, handler);
|
||||
}
|
||||
|
||||
public void RemoveNotification (NotifyHandler handler)
|
||||
{
|
||||
DisconnectNotification ("notify", handler);
|
||||
RemoveSignalHandler ("notify", handler);
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
|
@ -588,25 +504,16 @@ namespace GLib {
|
|||
return Handle.GetHashCode ();
|
||||
}
|
||||
|
||||
public Hashtable Data {
|
||||
System.Collections.Hashtable data;
|
||||
public System.Collections.Hashtable Data {
|
||||
get {
|
||||
if (data == null)
|
||||
data = new Hashtable ();
|
||||
data = new System.Collections.Hashtable ();
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
Hashtable persistent_data;
|
||||
protected Hashtable PersistentData {
|
||||
get {
|
||||
if (persistent_data == null)
|
||||
persistent_data = new Hashtable ();
|
||||
|
||||
return persistent_data;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_object_get_property (IntPtr obj, IntPtr name, ref GLib.Value val);
|
||||
|
||||
|
@ -639,6 +546,52 @@ namespace GLib {
|
|||
GLib.Marshaller.Free (native_name);
|
||||
}
|
||||
|
||||
Dictionary<string, Signal> signals;
|
||||
Dictionary<string, Signal> Signals {
|
||||
get {
|
||||
if (signals == null)
|
||||
signals = new Dictionary<string, Signal> ();
|
||||
return signals;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddSignalHandler (string name, Delegate handler)
|
||||
{
|
||||
AddSignalHandler (name, handler, typeof (EventArgs));
|
||||
}
|
||||
|
||||
public void AddSignalHandler (string name, Delegate handler, Delegate marshaler)
|
||||
{
|
||||
Signal sig;
|
||||
if (!Signals.TryGetValue (name, out sig)) {
|
||||
sig = new Signal (this, name, marshaler);
|
||||
Signals [name] = sig;
|
||||
}
|
||||
|
||||
sig.AddDelegate (handler);
|
||||
}
|
||||
|
||||
public void AddSignalHandler (string name, Delegate handler, Type args_type)
|
||||
{
|
||||
if (args_type == null)
|
||||
args_type = handler.Method.GetParameters ()[1].ParameterType;
|
||||
|
||||
Signal sig;
|
||||
if (!Signals.TryGetValue (name, out sig)) {
|
||||
sig = new Signal (this, name, args_type);
|
||||
Signals [name] = sig;
|
||||
}
|
||||
|
||||
sig.AddDelegate (handler);
|
||||
}
|
||||
|
||||
public void RemoveSignalHandler (string name, Delegate handler)
|
||||
{
|
||||
Signal sig;
|
||||
if (Signals.TryGetValue (name, out sig))
|
||||
sig.RemoveDelegate (handler);
|
||||
}
|
||||
|
||||
protected static void OverrideVirtualMethod (GType gtype, string name, Delegate cb)
|
||||
{
|
||||
Signal.OverrideDefaultHandler (gtype, name, cb);
|
||||
|
|
|
@ -133,27 +133,27 @@ namespace GLib {
|
|||
}
|
||||
}
|
||||
|
||||
ToggleRef tref;
|
||||
GLib.Object obj;
|
||||
string name;
|
||||
Type args_type;
|
||||
SignalClosure before_closure;
|
||||
SignalClosure after_closure;
|
||||
Delegate after_handler;
|
||||
Delegate before_handler;
|
||||
Delegate marshaler;
|
||||
|
||||
private Signal (GLib.Object obj, string signal_name, Delegate marshaler)
|
||||
internal Signal (GLib.Object obj, string name, Delegate marshaler)
|
||||
{
|
||||
tref = obj.ToggleRef;
|
||||
name = signal_name;
|
||||
tref.Signals [name] = this;
|
||||
this.obj = obj;
|
||||
this.name = name;
|
||||
this.marshaler = marshaler;
|
||||
}
|
||||
|
||||
private Signal (GLib.Object obj, string signal_name, Type args_type)
|
||||
internal Signal (GLib.Object obj, string name, Type args_type)
|
||||
{
|
||||
tref = obj.ToggleRef;
|
||||
name = signal_name;
|
||||
this.obj = obj;
|
||||
this.name = name;
|
||||
this.args_type = args_type;
|
||||
tref.Signals [name] = this;
|
||||
}
|
||||
|
||||
internal void Free ()
|
||||
|
@ -170,19 +170,14 @@ namespace GLib {
|
|||
if (o == before_closure) {
|
||||
before_closure.Disposed -= new EventHandler (ClosureDisposedHandler);
|
||||
before_closure.Invoked -= new ClosureInvokedHandler (ClosureInvokedCB);
|
||||
if (tref.Target != null)
|
||||
tref.Target.BeforeSignals.Remove (name);
|
||||
before_closure = null;
|
||||
before_handler = null;
|
||||
} else if (o == after_closure) {
|
||||
after_closure.Disposed -= new EventHandler (ClosureDisposedHandler);
|
||||
after_closure.Invoked -= new ClosureInvokedHandler (ClosureInvokedCB);
|
||||
if (tref.Target != null)
|
||||
tref.Target.AfterSignals.Remove (name);
|
||||
after_closure = null;
|
||||
after_handler = null;
|
||||
}
|
||||
|
||||
if (before_closure == null && after_closure == null)
|
||||
tref.Signals.Remove (name);
|
||||
}
|
||||
|
||||
EventHandler closure_disposed_cb;
|
||||
|
@ -198,9 +193,9 @@ namespace GLib {
|
|||
{
|
||||
Delegate handler;
|
||||
if (o == before_closure)
|
||||
handler = args.Target.BeforeSignals [name] as Delegate;
|
||||
handler = before_handler;
|
||||
else
|
||||
handler = args.Target.AfterSignals [name] as Delegate;
|
||||
handler = after_handler;
|
||||
|
||||
if (handler != null)
|
||||
handler.DynamicInvoke (new object[] {args.Target, args.Args});
|
||||
|
@ -215,35 +210,13 @@ namespace GLib {
|
|||
}
|
||||
}
|
||||
|
||||
public static Signal Lookup (GLib.Object obj, string name)
|
||||
{
|
||||
return Lookup (obj, name, typeof (EventArgs));
|
||||
}
|
||||
|
||||
public static Signal Lookup (GLib.Object obj, string name, Delegate marshaler)
|
||||
{
|
||||
Signal result = obj.ToggleRef.Signals [name];
|
||||
if (result == null)
|
||||
result = new Signal (obj, name, marshaler);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Signal Lookup (GLib.Object obj, string name, Type args_type)
|
||||
{
|
||||
Signal result = obj.ToggleRef.Signals [name];
|
||||
if (result == null)
|
||||
result = new Signal (obj, name, args_type);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public Delegate Handler {
|
||||
get {
|
||||
InvocationHint hint = (InvocationHint) Marshal.PtrToStructure (g_signal_get_invocation_hint (tref.Handle), typeof (InvocationHint));
|
||||
InvocationHint hint = (InvocationHint) Marshal.PtrToStructure (g_signal_get_invocation_hint (obj.Handle), typeof (InvocationHint));
|
||||
if (hint.run_type == Flags.RunFirst)
|
||||
return tref.Target.BeforeSignals [name] as Delegate;
|
||||
return before_handler;
|
||||
else
|
||||
return tref.Target.AfterSignals [name] as Delegate;
|
||||
return after_handler;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,23 +226,23 @@ namespace GLib {
|
|||
args_type = d.Method.GetParameters ()[1].ParameterType;
|
||||
|
||||
if (d.Method.IsDefined (typeof (ConnectBeforeAttribute), false)) {
|
||||
tref.Target.BeforeSignals [name] = Delegate.Combine (tref.Target.BeforeSignals [name] as Delegate, d);
|
||||
before_handler = Delegate.Combine (before_handler, d);
|
||||
if (before_closure == null) {
|
||||
if (marshaler == null)
|
||||
before_closure = new SignalClosure (tref.Handle, name, args_type);
|
||||
before_closure = new SignalClosure (obj.Handle, name, args_type);
|
||||
else
|
||||
before_closure = new SignalClosure (tref.Handle, name, marshaler, this);
|
||||
before_closure = new SignalClosure (obj.Handle, name, marshaler, this);
|
||||
before_closure.Disposed += ClosureDisposedHandler;
|
||||
before_closure.Invoked += ClosureInvokedHandler;
|
||||
before_closure.Connect (false);
|
||||
}
|
||||
} else {
|
||||
tref.Target.AfterSignals [name] = Delegate.Combine (tref.Target.AfterSignals [name] as Delegate, d);
|
||||
after_handler = Delegate.Combine (after_handler, d);
|
||||
if (after_closure == null) {
|
||||
if (marshaler == null)
|
||||
after_closure = new SignalClosure (tref.Handle, name, args_type);
|
||||
after_closure = new SignalClosure (obj.Handle, name, args_type);
|
||||
else
|
||||
after_closure = new SignalClosure (tref.Handle, name, marshaler, this);
|
||||
after_closure = new SignalClosure (obj.Handle, name, marshaler, this);
|
||||
after_closure.Disposed += ClosureDisposedHandler;
|
||||
after_closure.Invoked += ClosureInvokedHandler;
|
||||
after_closure.Connect (true);
|
||||
|
@ -279,18 +252,15 @@ namespace GLib {
|
|||
|
||||
public void RemoveDelegate (Delegate d)
|
||||
{
|
||||
if (tref.Target == null)
|
||||
return;
|
||||
|
||||
if (d.Method.IsDefined (typeof (ConnectBeforeAttribute), false)) {
|
||||
tref.Target.BeforeSignals [name] = Delegate.Remove (tref.Target.BeforeSignals [name] as Delegate, d);
|
||||
if (tref.Target.BeforeSignals [name] == null && before_closure != null) {
|
||||
before_handler = Delegate.Remove (before_handler, d);
|
||||
if (before_handler == null && before_closure != null) {
|
||||
before_closure.Dispose ();
|
||||
before_closure = null;
|
||||
}
|
||||
} else {
|
||||
tref.Target.AfterSignals [name] = Delegate.Remove (tref.Target.AfterSignals [name] as Delegate, d);
|
||||
if (tref.Target.AfterSignals [name] == null && after_closure != null) {
|
||||
after_handler = Delegate.Remove (after_handler, d);
|
||||
if (after_handler == null && after_closure != null) {
|
||||
after_closure.Dispose ();
|
||||
after_closure = null;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ namespace GLib {
|
|||
IntPtr handle;
|
||||
object reference;
|
||||
GCHandle gch;
|
||||
Dictionary<string, Signal> signals;
|
||||
|
||||
public ToggleRef (GLib.Object target)
|
||||
{
|
||||
|
@ -46,14 +45,6 @@ namespace GLib {
|
|||
get { return handle; }
|
||||
}
|
||||
|
||||
public Dictionary<string, Signal> Signals {
|
||||
get {
|
||||
if (signals == null)
|
||||
signals = new Dictionary<string, Signal> ();
|
||||
return signals;
|
||||
}
|
||||
}
|
||||
|
||||
public GLib.Object Target {
|
||||
get {
|
||||
if (reference == null)
|
||||
|
@ -68,10 +59,6 @@ namespace GLib {
|
|||
|
||||
public void Free ()
|
||||
{
|
||||
Signal[] signals = new Signal [Signals.Count];
|
||||
Signals.Values.CopyTo (signals, 0);
|
||||
foreach (Signal s in signals)
|
||||
s.Free ();
|
||||
if (hardened)
|
||||
g_object_unref (handle);
|
||||
else
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
void ClearProxy (Clipboard clipboard)
|
||||
{
|
||||
if (PersistentData ["clear_func"] != null) {
|
||||
ClipboardClearFunc clear = PersistentData ["clear_func"] as ClipboardClearFunc;
|
||||
if (Data ["clear_func"] != null) {
|
||||
ClipboardClearFunc clear = Data ["clear_func"] as ClipboardClearFunc;
|
||||
clear (clipboard);
|
||||
}
|
||||
SetPersistentData (null, null, null);
|
||||
|
@ -36,9 +36,9 @@
|
|||
|
||||
void SetPersistentData (object get_func_wrapper, object clear_func, object clear_proxy_wrapper)
|
||||
{
|
||||
PersistentData ["get_func_wrapper"] = get_func_wrapper;
|
||||
PersistentData ["clear_func"] = clear_func;
|
||||
PersistentData ["clear_proxy_wrapper"] = clear_proxy_wrapper;
|
||||
Data ["get_func_wrapper"] = get_func_wrapper;
|
||||
Data ["clear_func"] = clear_func;
|
||||
Data ["clear_proxy_wrapper"] = clear_proxy_wrapper;
|
||||
}
|
||||
|
||||
public bool SetWithData (TargetEntry[] targets, ClipboardGetFunc get_func, ClipboardClearFunc clear_func)
|
||||
|
|
|
@ -281,12 +281,10 @@
|
|||
[GLib.Signal("rows_reordered")]
|
||||
public event Gtk.RowsReorderedHandler RowsReordered {
|
||||
add {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "rows_reordered", new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
sig.AddDelegate (value);
|
||||
AddSignalHandler ("rows_reordered", value, new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
}
|
||||
remove {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "rows_reordered", new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
sig.RemoveDelegate (value);
|
||||
RemoveSignalHandler ("rows_reordered", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,74 +35,3 @@
|
|||
Raw = gtk_text_view_new_with_buffer (buffer.Handle);
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
delegate void MoveFocusSignalDelegate (IntPtr arg0, int arg1, IntPtr gch);
|
||||
|
||||
static void MoveFocusSignalCallback (IntPtr arg0, int arg1, IntPtr gch)
|
||||
{
|
||||
Gtk.MoveFocusArgs args = new Gtk.MoveFocusArgs ();
|
||||
try {
|
||||
GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
|
||||
if (sig == null)
|
||||
throw new Exception("Unknown signal GC handle received " + gch);
|
||||
|
||||
args.Args = new object[1];
|
||||
args.Args[0] = (Gtk.DirectionType) arg1;
|
||||
Gtk.MoveFocusHandler handler = (Gtk.MoveFocusHandler) sig.Handler;
|
||||
handler (GLib.Object.GetObject (arg0), args);
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
delegate void MoveFocusVMDelegate (IntPtr text_view, int direction);
|
||||
|
||||
static MoveFocusVMDelegate MoveFocusVMCallback;
|
||||
|
||||
static void movefocus_cb (IntPtr text_view, int direction)
|
||||
{
|
||||
try {
|
||||
TextView text_view_managed = GLib.Object.GetObject (text_view, false) as TextView;
|
||||
text_view_managed.OnMoveFocus ((Gtk.DirectionType) direction);
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OverrideMoveFocus (GLib.GType gtype)
|
||||
{
|
||||
if (MoveFocusVMCallback == null)
|
||||
MoveFocusVMCallback = new MoveFocusVMDelegate (movefocus_cb);
|
||||
OverrideVirtualMethod (gtype, "move_focus", MoveFocusVMCallback);
|
||||
}
|
||||
|
||||
[Obsolete ("Replaced by keybinding signal on Gtk.Widget")]
|
||||
[GLib.DefaultSignalHandler(Type=typeof(Gtk.TextView), ConnectionMethod="OverrideMoveFocus")]
|
||||
protected virtual void OnMoveFocus (Gtk.DirectionType direction)
|
||||
{
|
||||
GLib.Value ret = GLib.Value.Empty;
|
||||
GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
|
||||
GLib.Value[] vals = new GLib.Value [2];
|
||||
vals [0] = new GLib.Value (this);
|
||||
inst_and_params.Append (vals [0]);
|
||||
vals [1] = new GLib.Value (direction);
|
||||
inst_and_params.Append (vals [1]);
|
||||
g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
|
||||
foreach (GLib.Value v in vals)
|
||||
v.Dispose ();
|
||||
}
|
||||
|
||||
[Obsolete ("Replaced by keybinding signal on Gtk.Widget")]
|
||||
[GLib.Signal("move_focus")]
|
||||
public event Gtk.MoveFocusHandler MoveFocus {
|
||||
add {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "move_focus", new MoveFocusSignalDelegate(MoveFocusSignalCallback));
|
||||
sig.AddDelegate (value);
|
||||
}
|
||||
remove {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "move_focus", new MoveFocusSignalDelegate(MoveFocusSignalCallback));
|
||||
sig.RemoveDelegate (value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -170,12 +170,10 @@
|
|||
[GLib.Signal("rows_reordered")]
|
||||
public event Gtk.RowsReorderedHandler RowsReordered {
|
||||
add {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (GLib.Object.GetObject (Handle), "rows_reordered", new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
sig.AddDelegate (value);
|
||||
GLib.Object.GetObject (Handle).AddSignalHandler ("rows_reordered", value, new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
}
|
||||
remove {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (GLib.Object.GetObject (Handle), "rows_reordered", new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
sig.RemoveDelegate (value);
|
||||
GLib.Object.GetObject (Handle).RemoveSignalHandler ("rows_reordered", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,12 +172,10 @@
|
|||
[GLib.Signal("rows_reordered")]
|
||||
public event Gtk.RowsReorderedHandler RowsReordered {
|
||||
add {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "rows_reordered", new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
sig.AddDelegate (value);
|
||||
AddSignalHandler ("rows_reordered", value, new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
}
|
||||
remove {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "rows_reordered", new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
sig.RemoveDelegate (value);
|
||||
RemoveSignalHandler ("rows_reordered", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -175,12 +175,10 @@
|
|||
[GLib.Signal("rows_reordered")]
|
||||
public event Gtk.RowsReorderedHandler RowsReordered {
|
||||
add {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "rows_reordered", new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
sig.AddDelegate (value);
|
||||
AddSignalHandler ("rows_reordered", value, new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
}
|
||||
remove {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "rows_reordered", new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
sig.RemoveDelegate (value);
|
||||
RemoveSignalHandler ("rows_reordered", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -397,12 +397,11 @@
|
|||
[GLib.Signal("rows_reordered")]
|
||||
public event Gtk.RowsReorderedHandler RowsReordered {
|
||||
add {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "rows_reordered", new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
sig.AddDelegate (value);
|
||||
AddSignalHandler ("rows_reordered", value, new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
}
|
||||
remove {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "rows_reordered", new RowsReorderedSignalDelegate(RowsReorderedSignalCallback));
|
||||
sig.RemoveDelegate (value);
|
||||
RemoveSignalHandler ("rows_reordered", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -347,12 +347,10 @@ public void Path (out string path, out string path_reversed)
|
|||
|
||||
event EventHandler InternalDestroyed {
|
||||
add {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "destroy");
|
||||
sig.AddDelegate (value);
|
||||
AddSignalHandler ("destroy", value);
|
||||
}
|
||||
remove {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "destroy");
|
||||
sig.RemoveDelegate (value);
|
||||
RemoveSignalHandler ("destroy", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,74 +86,3 @@
|
|||
}
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
delegate void MoveFocusSignalDelegate (IntPtr arg0, int arg1, IntPtr gch);
|
||||
|
||||
static void MoveFocusSignalCallback (IntPtr arg0, int arg1, IntPtr gch)
|
||||
{
|
||||
Gtk.MoveFocusArgs args = new Gtk.MoveFocusArgs ();
|
||||
try {
|
||||
GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
|
||||
if (sig == null)
|
||||
throw new Exception("Unknown signal GC handle received " + gch);
|
||||
|
||||
args.Args = new object[1];
|
||||
args.Args[0] = (Gtk.DirectionType) arg1;
|
||||
Gtk.MoveFocusHandler handler = (Gtk.MoveFocusHandler) sig.Handler;
|
||||
handler (GLib.Object.GetObject (arg0), args);
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
delegate void MoveFocusVMDelegate (IntPtr window, int direction);
|
||||
|
||||
static MoveFocusVMDelegate MoveFocusVMCallback;
|
||||
|
||||
static void movefocus_cb (IntPtr window, int direction)
|
||||
{
|
||||
try {
|
||||
Window window_managed = GLib.Object.GetObject (window, false) as Window;
|
||||
window_managed.OnMoveFocus ((Gtk.DirectionType) direction);
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OverrideMoveFocus (GLib.GType gtype)
|
||||
{
|
||||
if (MoveFocusVMCallback == null)
|
||||
MoveFocusVMCallback = new MoveFocusVMDelegate (movefocus_cb);
|
||||
OverrideVirtualMethod (gtype, "move_focus", MoveFocusVMCallback);
|
||||
}
|
||||
|
||||
[Obsolete ("Replaced by Keybinding signal on Gtk.Widget")]
|
||||
[GLib.DefaultSignalHandler(Type=typeof(Gtk.Window), ConnectionMethod="OverrideMoveFocus")]
|
||||
protected virtual void OnMoveFocus (Gtk.DirectionType direction)
|
||||
{
|
||||
GLib.Value ret = GLib.Value.Empty;
|
||||
GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
|
||||
GLib.Value[] vals = new GLib.Value [2];
|
||||
vals [0] = new GLib.Value (this);
|
||||
inst_and_params.Append (vals [0]);
|
||||
vals [1] = new GLib.Value (direction);
|
||||
inst_and_params.Append (vals [1]);
|
||||
g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
|
||||
foreach (GLib.Value v in vals)
|
||||
v.Dispose ();
|
||||
}
|
||||
|
||||
[Obsolete ("Replaced by Keybinding signal on Gtk.Widget")]
|
||||
[GLib.Signal("move_focus")]
|
||||
public event Gtk.MoveFocusHandler MoveFocus {
|
||||
add {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "move_focus", new MoveFocusSignalDelegate(MoveFocusSignalCallback));
|
||||
sig.AddDelegate (value);
|
||||
}
|
||||
remove {
|
||||
GLib.Signal sig = GLib.Signal.Lookup (this, "move_focus", new MoveFocusSignalDelegate(MoveFocusSignalCallback));
|
||||
sig.RemoveDelegate (value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue