本文整理汇总了C#中GLib.GType类的典型用法代码示例。如果您正苦于以下问题:C# GType类的具体用法?C# GType怎么用?C# GType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GType类属于GLib命名空间,在下文中一共展示了GType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OverrideNewWindowPolicyDecisionRequested
static void OverrideNewWindowPolicyDecisionRequested (GType gtype)
{
if (EtoWebView.NewWindowPolicyDecisionRequestedVMCallback == null) {
EtoWebView.NewWindowPolicyDecisionRequestedVMCallback = new EtoWebView.NewWindowPolicyDecisionRequestedVMDelegate (EtoWebView.newwindowpolicydecisionrequested_cb);
}
GLib.Object.OverrideVirtualMethod (gtype, "new-window-policy-decision-requested", EtoWebView.NewWindowPolicyDecisionRequestedVMCallback);
}
示例2: GetClassPtr
public static IntPtr GetClassPtr(GType type)
{
IntPtr klass = g_type_class_peek (type.Val);
if (klass == IntPtr.Zero)
klass = g_type_class_ref (type.Val);
return klass;
}
示例3: Register
public static void Register (GType native_type, System.Type type)
{
if (native_type != GType.Pointer && native_type != GType.Boxed && native_type != ManagedValue.GType)
types[native_type.Val] = type;
if (type != null)
gtypes[type] = native_type;
}
示例4: GetBaseType
public static GType GetBaseType(GType type)
{
IntPtr parent = g_type_parent (type.Val);
if (parent == IntPtr.Zero)
return GType.None;
else
return new GType (parent);
}
示例5: GetThresholdType
public static GType GetThresholdType(GType type)
{
GLib.GType curr_type = type;
while (curr_type.ToString ().StartsWith ("__gtksharp_")) {
curr_type = GetBaseType (curr_type);
}
return curr_type;
}
示例6: ParamSpec
public ParamSpec(string name, string nick, string blurb, GType type, bool readable, bool writable)
{
ParamFlags pflags = ParamFlags.None;
if (readable) pflags |= ParamFlags.Readable;
if (writable) pflags |= ParamFlags.Writable;
int flags = (int) pflags;
IntPtr p_name = GLib.Marshaller.StringToPtrGStrdup (name);
IntPtr p_nick = GLib.Marshaller.StringToPtrGStrdup (nick);
IntPtr p_blurb = GLib.Marshaller.StringToPtrGStrdup (blurb);
if (type == GType.Char)
handle = g_param_spec_char (p_name, p_nick, p_blurb, SByte.MinValue, SByte.MaxValue, 0, flags);
else if (type == GType.UChar)
handle = g_param_spec_uchar (p_name, p_nick, p_blurb, Byte.MinValue, Byte.MaxValue, 0, flags);
else if (type == GType.Boolean)
handle = g_param_spec_boolean (p_name, p_nick, p_blurb, false, flags);
else if (type == GType.Int)
handle = g_param_spec_int (p_name, p_nick, p_blurb, Int32.MinValue, Int32.MaxValue, 0, flags);
else if (type == GType.UInt)
handle = g_param_spec_uint (p_name, p_nick, p_blurb, 0, UInt32.MaxValue, 0, flags);
else if (type == GType.Long)
handle = g_param_spec_long (p_name, p_nick, p_blurb, IntPtr.Zero, IntPtr.Size == 4 ? new IntPtr (Int32.MaxValue) : new IntPtr (Int64.MaxValue), IntPtr.Zero, flags);
else if (type == GType.ULong)
handle = g_param_spec_ulong (p_name, p_nick, p_blurb, UIntPtr.Zero, UIntPtr.Size == 4 ? new UIntPtr (UInt32.MaxValue) : new UIntPtr (UInt64.MaxValue), UIntPtr.Zero, flags);
else if (type == GType.Int64)
handle = g_param_spec_int64 (p_name, p_nick, p_blurb, Int64.MinValue, Int64.MaxValue, 0, flags);
else if (type == GType.UInt64)
handle = g_param_spec_uint64 (p_name, p_nick, p_blurb, 0, UInt64.MaxValue, 0, flags);
/*
else if (type == GType.Enum)
else if (type == GType.Flags)
* TODO:
* Both g_param_spec_enum and g_param_spec_flags expect default property values and the members of the enum seemingly cannot be enumerated
*/
else if (type == GType.Float)
handle = g_param_spec_float (p_name, p_nick, p_blurb, Single.MinValue, Single.MaxValue, 0.0f, flags);
else if (type == GType.Double)
handle = g_param_spec_double (p_name, p_nick, p_blurb, Double.MinValue, Double.MaxValue, 0.0, flags);
else if (type == GType.String)
handle = g_param_spec_string (p_name, p_nick, p_blurb, IntPtr.Zero, flags);
else if (type == GType.Pointer)
handle = g_param_spec_pointer (p_name, p_nick, p_blurb, flags);
else if (type.Val == g_gtype_get_type ())
handle = g_param_spec_gtype (p_name, p_nick, p_blurb, GType.None.Val, flags);
else if (g_type_is_a (type.Val, GType.Boxed.Val))
handle = g_param_spec_boxed (p_name, p_nick, p_blurb, type.Val, flags);
else if (g_type_is_a (type.Val, GType.Object.Val))
handle = g_param_spec_object (p_name, p_nick, p_blurb, type.Val, flags);
else
throw new ArgumentException ("type");
GLib.Marshaller.Free (p_name);
GLib.Marshaller.Free (p_nick);
GLib.Marshaller.Free (p_blurb);
}
示例7: ConnectDefaultHandlers
private static void ConnectDefaultHandlers(GType gtype, System.Type t)
{
foreach (MethodInfo minfo in t.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly)) {
MethodInfo baseinfo = minfo.GetBaseDefinition ();
if (baseinfo == minfo)
continue;
foreach (object attr in baseinfo.GetCustomAttributes (typeof (DefaultSignalHandlerAttribute), false)) {
DefaultSignalHandlerAttribute sigattr = attr as DefaultSignalHandlerAttribute;
MethodInfo connector = sigattr.Type.GetMethod (sigattr.ConnectionMethod, BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof (GType) }, new ParameterModifier [0]);
object[] parms = new object [1];
parms [0] = gtype;
connector.Invoke (null, parms);
break;
}
}
}
示例8: PropertyInfo
public PropertyInfo(IntPtr pspec_ptr)
{
GParamSpec pspec = (GParamSpec) Marshal.PtrToStructure (pspec_ptr, typeof (GParamSpec));
IntPtr name = g_param_spec_get_name (pspec_ptr);
IntPtr nick = g_param_spec_get_nick (pspec_ptr);
IntPtr blurb = g_param_spec_get_blurb (pspec_ptr);
this.name = GLib.Marshaller.Utf8PtrToString (name);
this.nick = GLib.Marshaller.Utf8PtrToString (nick);
this.blurb = GLib.Marshaller.Utf8PtrToString (blurb);
this.readable = ( (pspec.Flags & (1 << 0)) != 0);
this.writeable = ( (pspec.Flags & (1 << 1)) != 0);
this.controllable = ( (pspec.Flags & (1 << 9)) != 0);
/* TODO: Add more flags later, like the mutable flags */
this.gtype = new GLib.GType (pspec.ValueType);
this.type = (System.Type) this.gtype;
this.dflt = this.min = this.max = null;
try {
GLib.Value v = new GLib.Value (new GLib.GType (pspec.ValueType));
g_param_value_set_default (pspec_ptr, ref v);
this.dflt = v.Val;
v.Dispose ();
if (EnumInfo.IsEnumType (this.gtype)) {
EnumInfo ei = new EnumInfo (this.gtype);
this.min = ei.Min;
this.max = ei.Max;
} else {
GLib.Value min = new GLib.Value (new GLib.GType (pspec.ValueType));
GLib.Value max = new GLib.Value (new GLib.GType (pspec.ValueType));
if (gstsharp_g_param_spec_get_range (pspec_ptr, ref min, ref max)) {
this.min = (object) min.Val;
this.max = (object) max.Val;
}
min.Dispose ();
max.Dispose ();
}
} catch (Exception) {}
}
示例9: InvokeTypeInitializers
private static void InvokeTypeInitializers(GType gtype, System.Type t)
{
object[] parms = {gtype, t};
BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic;
foreach (TypeInitializerAttribute tia in t.GetCustomAttributes (typeof (TypeInitializerAttribute), true)) {
MethodInfo m = tia.Type.GetMethod (tia.MethodName, flags);
if (m != null)
m.Invoke (null, parms);
}
}
示例10: AddInterfaces
static void AddInterfaces(GType gtype, Type t, ref bool handlers_overridden)
{
foreach (Type iface in t.GetInterfaces ()) {
if (!iface.IsDefined (typeof (GInterfaceAttribute), true))
continue;
GInterfaceAttribute attr = iface.GetCustomAttributes (typeof (GInterfaceAttribute), false) [0] as GInterfaceAttribute;
GInterfaceAdapter adapter = Activator.CreateInstance (attr.AdapterType, null) as GInterfaceAdapter;
if (!handlers_overridden) {
IntPtr class_ptr = gtype.GetClassPtr ();
GObjectClass gobject_class = (GObjectClass) Marshal.PtrToStructure (class_ptr, typeof (GObjectClass));
gobject_class.get_prop_cb = GetPropertyHandler;
gobject_class.set_prop_cb = SetPropertyHandler;
Marshal.StructureToPtr (gobject_class, class_ptr, false);
handlers_overridden = true;
}
if (!iface.IsAssignableFrom (t.BaseType)) {
GInterfaceInfo info = adapter.Info;
info.Data = gtype.GetClassPtr ();
//FIXME: overiding prop is done inside the init of interface adapter
// not sure that it is the good solution but
// it is the only one I found without exception or loop
g_type_add_interface_static (gtype.Val, adapter.GType.Val, ref info);
}
foreach (PropertyInfo p in iface.GetProperties ()) {
PropertyAttribute[] attrs = p.GetCustomAttributes (typeof (PropertyAttribute), true) as PropertyAttribute [];
if (attrs.Length == 0)
continue;
PropertyAttribute property_attr = attrs [0];
PropertyInfo declared_prop = t.GetProperty (p.Name, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance);
if (declared_prop == null)
continue;
IntPtr param_spec = FindInterfaceProperty (adapter.GType, property_attr.Name);
Properties [param_spec] = declared_prop;
}
}
}
示例11: AddProperties
static void AddProperties(GType gtype, System.Type t, bool register_instance_prop, ref bool handlers_overridden)
{
if (register_instance_prop) {
IntPtr declaring_class = gtype.GetClassPtr ();
ParamSpec pspec = new ParamSpec ("gtk-sharp-managed-instance", "", "", GType.Pointer, ParamFlags.Writable | ParamFlags.ConstructOnly);
g_object_class_install_property (declaring_class, idx, pspec.Handle);
idx++;
}
foreach (PropertyInfo pinfo in t.GetProperties (BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)) {
foreach (object attr in pinfo.GetCustomAttributes (typeof (PropertyAttribute), false)) {
if(pinfo.GetIndexParameters().Length > 0)
throw(new InvalidOperationException(String.Format("GLib.RegisterPropertyAttribute cannot be applied to property {0} of type {1} because the property expects one or more indexed parameters", pinfo.Name, t.FullName)));
if (!handlers_overridden) {
IntPtr class_ptr = gtype.GetClassPtr ();
GObjectClass gobject_class = (GObjectClass) Marshal.PtrToStructure (class_ptr, typeof (GObjectClass));
gobject_class.get_prop_cb = GetPropertyHandler;
gobject_class.set_prop_cb = SetPropertyHandler;
Marshal.StructureToPtr (gobject_class, class_ptr, false);
handlers_overridden = true;
}
PropertyAttribute property_attr = attr as PropertyAttribute;
try {
IntPtr param_spec = RegisterProperty (gtype, property_attr.Name, property_attr.Nickname, property_attr.Blurb, idx, (GType) pinfo.PropertyType, pinfo.CanRead, pinfo.CanWrite);
Properties.Add (param_spec, pinfo);
idx++;
} catch (ArgumentException) {
throw new InvalidOperationException (String.Format ("GLib.PropertyAttribute cannot be applied to property {0} of type {1} because the return type of the property is not supported", pinfo.Name, t.FullName));
}
}
}
}
示例12: ParamSpec
public ParamSpec(string name, string nick, string blurb, GType type, bool readable, bool writable)
: this(name, nick, blurb, type, (readable ? ParamFlags.Readable : ParamFlags.None) | (writable ? ParamFlags.Writable : ParamFlags.None))
{
}
示例13: AddInterfaces
static void AddInterfaces(GType gtype, Type t)
{
foreach (Type iface in t.GetInterfaces ()) {
if (!iface.IsDefined (typeof (GInterfaceAttribute), true) || iface.IsAssignableFrom (t.BaseType))
continue;
GInterfaceAttribute attr = iface.GetCustomAttributes (typeof (GInterfaceAttribute), false) [0] as GInterfaceAttribute;
GInterfaceAdapter adapter = Activator.CreateInstance (attr.AdapterType, null) as GInterfaceAdapter;
GInterfaceInfo info = adapter.Info;
g_type_add_interface_static (gtype.Val, adapter.GType.Val, ref info);
}
}
示例14: InitForProperty
void InitForProperty (GType gtype, string name)
{
IntPtr p_name = Marshaller.StringToPtrGStrdup (name);
IntPtr spec_ptr = g_object_class_find_property (gtype.GetClassPtr (), p_name);
Marshaller.Free (p_name);
if (spec_ptr == IntPtr.Zero)
throw new Exception (String.Format ("No property with name '{0}' in type '{1}'", name, gtype.ToString()));
ParamSpec spec = new ParamSpec (spec_ptr);
g_value_init (ref this, spec.ValueType.Val);
}
示例15: ToString
public override string ToString()
{
GParamSpec spec = (GParamSpec) Marshal.PtrToStructure (Handle, typeof (GParamSpec));
GType valtype= new GType (spec.value_type);
GType ownertype= new GType (spec.owner_type);
return "ParamSpec: name=" + Marshaller.Utf8PtrToString (spec.name) + " value_type=" + valtype.ToString() + " owner_type=" + ownertype.ToString();
}