Beispiel #1
0
        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());
        }
Beispiel #2
0
        /// <summary>
        /// Get the blurb for a GObject property.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        internal string GetBlurb(string name)
        {
            var pspec = GetPspec(name);

            if (!pspec.HasValue)
            {
                return(null);
            }

            var pspecValue = pspec.Value;

            return(Marshal.PtrToStringAnsi(GParamSpec.GParamSpecGetBlurb(ref pspecValue)));
        }
Beispiel #3
0
        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) {}
        }