Example #1
0
		public SignalClosure (IntPtr obj, string signal_name, Delegate custom_marshaler, Signal signal)
		{
			gch = GCHandle.Alloc (signal);
			raw_closure = g_cclosure_new (custom_marshaler, (IntPtr) gch, Notify);
			closures [raw_closure] = this;
			handle = obj;
			name = signal_name;
			this.custom_marshaler = custom_marshaler;
		}
Example #2
0
  		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
				g_object_remove_toggle_ref (handle, ToggleNotifyCallback, (IntPtr) gch);
			reference = null;
			gch.Free ();
		}
Example #3
0
        static void DeviceChangeSignalCallback(IntPtr arg0, int arg1, IntPtr gch)
        {
            DeviceChangeArgs args = new DeviceChangeArgs();

            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] = arg1;
                GlibDeviceChangeHandler handler = (GlibDeviceChangeHandler)sig.Handler;
                handler(GLib.Object.GetObject(arg0), args);
            } catch (Exception e) {
                GLib.ExceptionManager.RaiseUnhandledException(e, false);
            }
        }
Example #4
0
        static void ErrorSignalCallback(IntPtr arg0, IntPtr arg1, IntPtr gch)
        {
            ErrorArgs args = new ErrorArgs();

            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] = GLib.Marshaller.Utf8PtrToString(arg1);
                GlibErrorHandler handler = (GlibErrorHandler)sig.Handler;
                handler(GLib.Object.GetObject(arg0), args);
            } catch (Exception e) {
                GLib.ExceptionManager.RaiseUnhandledException(e, false);
            }
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
		public static Signal Lookup (GLib.Object obj, string name, Type args_type)
		{
			Signal result = obj.ToggleRef.Signals [name] as Signal;
			if (result == null)
				result = new Signal (obj, name, args_type);
			return result;
		}
Example #8
0
		public static Signal Lookup (GLib.Object obj, string name, Delegate marshaler)
		{
			Signal result = obj.ToggleRef.Signals [name] as Signal;
			if (result == null)
				result = new Signal (obj, name, marshaler);
			return result;
		}
Example #9
0
 public SignalClosure(IntPtr obj, string signal_name, Delegate custom_marshaler, Signal signal)
 {
     gch                    = GCHandle.Alloc(signal);
     raw_closure            = g_cclosure_new(custom_marshaler, (IntPtr)gch, Notify);
     closures [raw_closure] = this;
     handle                 = obj;
     name                   = signal_name;
     this.custom_marshaler  = custom_marshaler;
 }
Example #10
0
 protected static void OverrideVirtualMethod(GType gtype, string name, Delegate cb)
 {
     Signal.OverrideDefaultHandler(gtype, name, cb);
 }
 public SignalClosure(Signal sig, System.Type args_type)
 {
     raw_closure            = glibsharp_closure_new(Marshaler, Notify, IntPtr.Zero);
     closures [raw_closure] = this;
     signal = sig;
 }