2006-07-13 16:16:51 +00:00
|
|
|
//
|
|
|
|
// BindingHelper.cs: Utility methods to make creating
|
2009-04-07 09:27:20 +00:00
|
|
|
// element bindings by hand an easier task
|
2006-07-13 16:16:51 +00:00
|
|
|
//
|
|
|
|
// Authors:
|
|
|
|
// Aaron Bockover (abockover@novell.com)
|
|
|
|
//
|
2009-04-08 08:16:48 +00:00
|
|
|
// Copyright (C) 2006 Novell, Inc.
|
2006-07-13 16:16:51 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using GLib;
|
|
|
|
|
2009-04-07 09:27:20 +00:00
|
|
|
namespace Gst {
|
|
|
|
public static class BindingHelper {
|
2009-05-28 10:29:59 +00:00
|
|
|
public static Delegate AddProxySignalDelegate (GLib.Object o, string signal,
|
2009-04-07 09:27:20 +00:00
|
|
|
DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate addHandler) {
|
|
|
|
if (existingHandler == null) {
|
2009-05-28 10:29:59 +00:00
|
|
|
DynamicSignal.Connect (o, signal, baseHandler);
|
2009-04-07 09:27:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Delegate.Combine (existingHandler, addHandler);
|
|
|
|
}
|
|
|
|
|
2009-05-28 10:29:59 +00:00
|
|
|
public static Delegate RemoveProxySignalDelegate (GLib.Object o, string signal,
|
2009-04-07 09:27:20 +00:00
|
|
|
DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate removeHandler) {
|
|
|
|
Delegate temp_delegate = Delegate.Remove (existingHandler, removeHandler);
|
|
|
|
if (temp_delegate == null) {
|
2009-05-28 10:29:59 +00:00
|
|
|
DynamicSignal.Disconnect (o, signal, baseHandler);
|
2009-04-07 09:27:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return temp_delegate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void InvokeProxySignalDelegate (Delegate raiseDelegate, Type type,
|
|
|
|
object o, GLib.SignalArgs args) {
|
|
|
|
if (!type.IsSubclassOf (typeof (GLib.SignalArgs))) {
|
|
|
|
throw new ArgumentException ("Args type must derive SignalArgs");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (raiseDelegate != null) {
|
|
|
|
GLib.SignalArgs new_args = (GLib.SignalArgs) Activator.CreateInstance (type);
|
|
|
|
new_args.RetVal = args.RetVal;
|
|
|
|
new_args.Args = args.Args;
|
|
|
|
|
|
|
|
raiseDelegate.DynamicInvoke (new object [] { o, new_args });
|
|
|
|
}
|
2006-07-13 16:16:51 +00:00
|
|
|
}
|
2009-04-07 09:27:20 +00:00
|
|
|
}
|
2006-07-13 16:16:51 +00:00
|
|
|
}
|