Пример #1
0
 internal ClassInitializer(Type type)
 {
     ClassInitManagedDelegate = this.ClassInit;
     Type              = type;
     gtype             = GType.RegisterGObjectType(this);
     is_first_subclass = gtype.GetBaseType() == gtype.GetThresholdType();
 }
Пример #2
0
        public GType GetThresholdType()
        {
            GType curr_type = this;

            while (IsManaged(curr_type))
            {
                curr_type = curr_type.GetBaseType();
            }
            return(curr_type);
        }
Пример #3
0
        public GType GetThresholdType()
        {
            GType curr_type = this;

            while (curr_type.ToString().StartsWith("__gtksharp_"))
            {
                curr_type = curr_type.GetBaseType();
            }
            return(curr_type);
        }
Пример #4
0
        internal ParamSpec(string name, string nick, string blurb, GType type, ParamFlags pflags)
        {
            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.GetBaseType () == GType.Enum)
                handle = g_param_spec_enum (p_name, p_nick, p_blurb, type.Val, (int) (Enum.GetValues((Type)type).GetValue (0)), flags);
            /*else if (type == GType.Flags)
            *	g_param_spec_flags (p_name, p_nick, p_blurb, type.Val, Enum.GetValues((Type)type) [0], 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:" + type.ToString ());

            GLib.Marshaller.Free (p_name);
            GLib.Marshaller.Free (p_nick);
            GLib.Marshaller.Free (p_blurb);
        }
Пример #5
0
        protected internal static GType RegisterGType(System.Type t)
        {
            GType gtype             = GType.RegisterGObjectType(t);
            bool  is_first_subclass = gtype.GetBaseType() == gtype.GetThresholdType();

            if (is_first_subclass)
            {
                IntPtr       class_ptr     = gtype.GetClassPtr();
                GObjectClass gobject_class = (GObjectClass)Marshal.PtrToStructure(class_ptr, typeof(GObjectClass));
                gobject_class.constructor_cb = ConstructorHandler;
                gobject_class.get_prop_cb    = GetPropertyHandler;
                gobject_class.set_prop_cb    = SetPropertyHandler;
                Marshal.StructureToPtr(gobject_class, class_ptr, false);
            }
            AddProperties(gtype, t, is_first_subclass);
            ConnectDefaultHandlers(gtype, t);
            InvokeTypeInitializers(gtype, t);
            AddInterfaces(gtype, t);
            return(gtype);
        }
Пример #6
0
 internal ClassInitializer(Type type)
 {
     ClassInitManagedDelegate = this.ClassInit;
     Type = type;
     gtype = GType.RegisterGObjectType (this);
     is_first_subclass = gtype.GetBaseType () == gtype.GetThresholdType ();
 }
Пример #7
0
        internal ParamSpec(string name, string nick, string blurb, GType type, ParamFlags pflags)
        {
            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.GetBaseType() == GType.Enum)
            {
                handle = g_param_spec_enum(p_name, p_nick, p_blurb, type.Val, (int)(Enum.GetValues((Type)type).GetValue(0)), flags);
            }

            /*else if (type == GType.Flags)
             *	g_param_spec_flags (p_name, p_nick, p_blurb, type.Val, Enum.GetValues((Type)type) [0], 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:" + type.ToString());
            }

            GLib.Marshaller.Free(p_name);
            GLib.Marshaller.Free(p_nick);
            GLib.Marshaller.Free(p_blurb);
        }