2006-07-13 16:16:51 +00:00
|
|
|
//
|
|
|
|
// BindingHelper.cs: Utility methods to make creating
|
|
|
|
// element bindings by hand an easier task
|
|
|
|
//
|
|
|
|
// Authors:
|
|
|
|
// Aaron Bockover (abockover@novell.com)
|
|
|
|
//
|
|
|
|
// (C) 2006 Novell, Inc.
|
|
|
|
//
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using GLib;
|
|
|
|
|
|
|
|
namespace Gst
|
|
|
|
{
|
|
|
|
public static class BindingHelper
|
|
|
|
{
|
|
|
|
public static Delegate AddProxySignalDelegate(Element element, string signal,
|
|
|
|
GLib.DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate addHandler)
|
|
|
|
{
|
|
|
|
if(existingHandler == null) {
|
|
|
|
element.Connect(signal, baseHandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Delegate.Combine(existingHandler, addHandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Delegate RemoveProxySignalDelegate(Element element, string signal,
|
|
|
|
GLib.DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate removeHandler)
|
|
|
|
{
|
|
|
|
Delegate temp_delegate = Delegate.Remove(existingHandler, removeHandler);
|
|
|
|
if(temp_delegate == null) {
|
|
|
|
element.Disconnect(signal, baseHandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
return temp_delegate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void InvokeProxySignalDelegate(Delegate raiseDelegate, Type type,
|
2006-08-04 04:00:43 +00:00
|
|
|
object o, GLib.SignalArgs args)
|
2006-07-13 16:16:51 +00:00
|
|
|
{
|
2006-08-04 04:00:43 +00:00
|
|
|
if(!type.IsSubclassOf(typeof(GLib.SignalArgs))) {
|
|
|
|
throw new ArgumentException("Args type must derive SignalArgs");
|
2006-07-13 16:16:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(raiseDelegate != null) {
|
2009-04-04 14:53:59 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|