Exemplo n.º 1
0
 /// <summary>
 /// Installs a new property.
 /// </summary>
 /// <remarks>
 /// All properties should be installed during the class initializer.  It
 /// is possible to install properties after that, but doing so is not
 /// recommend, and specifically, is not guaranteed to be thread-safe vs.
 /// use of properties on the same type on other threads.
 ///
 /// Note that it is possible to redefine a property in a derived class,
 /// by installing a property with the same name. This can be useful at times,
 /// e.g. to change the range of allowed values or the default value.
 /// </remarks>
 /// <param name="propertyId">
 /// the id for the new property
 /// </param>
 /// <param name="pspec">
 /// the #GParamSpec for the new property
 /// </param>
 public void InstallProperty(uint propertyId, ParamSpec pspec)
 {
     if (pspec == null)
     {
         throw new ArgumentNullException(nameof(pspec));
     }
     g_object_class_install_property(Handle, propertyId, pspec.Handle);
     GC.KeepAlive(pspec);
 }
Exemplo n.º 2
0
            IntPtr pspec); // GParamSpec*

        public void Remove(ParamSpec pspec)
        {
            AssertNotDisposed();
            if (pspec == null)
            {
                throw new ArgumentNullException(nameof(pspec));
            }
            g_param_spec_pool_remove(Handle, pspec.Handle);
            GC.KeepAlive(pspec);
        }
Exemplo n.º 3
0
 public void Insert(ParamSpec pspec, GType ownerType)
 {
     AssertNotDisposed();
     if (pspec == null)
     {
         throw new ArgumentNullException(nameof(pspec));
     }
     g_param_spec_pool_insert(Handle, pspec.Handle, ownerType);
     GC.KeepAlive(pspec);
 }
Exemplo n.º 4
0
 static void ManagedNotify(IntPtr object_, IntPtr pspec_)
 {
     try {
         var obj   = Object.GetInstance(object_, Transfer.None);
         var pspec = ParamSpec.GetInstance(pspec_, Transfer.None);
         // FIXME
     } catch (Exception ex) {
         ex.LogUnhandledException();
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Looks up the <see cref="ParamSpec"/> for a property of a class.
        /// </summary>
        /// <param name="propertyName">
        /// the name of the property to look up
        /// </param>
        /// <returns>
        /// the <see cref="ParamSpec"/> for the property, or
        /// <c>null</c> if the class doesn't have a property of that name
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// Throw when <paramref name="propertyName"/> is <c>null</c>
        /// </exception>
        public ParamSpec FindProperty(string propertyName)
        {
            if (propertyName == null)
            {
                throw new ArgumentNullException(nameof(propertyName));
            }
            var propertyName_ = GMarshal.StringToUtf8Ptr(propertyName);
            var ret_          = g_object_class_find_property(Handle, propertyName_);
            var ret           = ParamSpec.GetInstance(ret_, Transfer.None);

            GMarshal.Free(propertyName_);
            return(ret);
        }
Exemplo n.º 6
0
        static void ManagedClassGetProperty(IntPtr objPtr, uint propertyId, ref Value value, IntPtr pspecPtr)
        {
            try {
                var obj   = Object.GetInstance(objPtr, Transfer.None);
                var pspec = ParamSpec.GetInstance(pspecPtr, Transfer.None);

                var propInfo = (PropertyInfo)pspec[managedClassPropertyInfoQuark];
                value.Set(propInfo.GetValue(obj));
            }
            catch (Exception ex) {
                ex.LogUnhandledException();
            }
        }
Exemplo n.º 7
0
            bool walk_ancestors); // gboolean

        public ParamSpec Lookup(string paramName, GType ownerType, bool walkAncestors)
        {
            AssertNotDisposed();
            if (paramName == null)
            {
                throw new ArgumentNullException(nameof(paramName));
            }
            var paramNamePtr = GMarshal.StringToUtf8Ptr(paramName);
            var retPtr       = g_param_spec_pool_lookup(Handle, paramNamePtr, ownerType, walkAncestors);

            GMarshal.Free(paramNamePtr);
            var ret = ParamSpec.GetInstance(retPtr, Transfer.None);

            return(ret);
        }
Exemplo n.º 8
0
        static IntPtr New(string name, string nick, string blurb, ParamSpec elementSpec, ParamFlags flags)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (nick == null)
            {
                throw new ArgumentNullException(nameof(nick));
            }
            if (blurb == null)
            {
                throw new ArgumentNullException(nameof(blurb));
            }
            var namePtr        = GMarshal.StringToUtf8Ptr(name);
            var nickPtr        = GMarshal.StringToUtf8Ptr(nick);
            var blurbPtr       = GMarshal.StringToUtf8Ptr(blurb);
            var elementSpecPtr = elementSpec?.Handle ?? IntPtr.Zero;
            var ret            = g_param_spec_value_array(namePtr, nickPtr, blurbPtr, elementSpecPtr, flags);

            GC.KeepAlive(elementSpec);

            // Any strings that have the cooresponding static flag set must not
            // be freed because they are passed to g_intern_static_string().
            if (!flags.HasFlag(ParamFlags.StaticName))
            {
                GMarshal.Free(namePtr);
            }
            if (!flags.HasFlag(ParamFlags.StaticNick))
            {
                GMarshal.Free(nickPtr);
            }
            if (!flags.HasFlag(ParamFlags.StaticBlurb))
            {
                GMarshal.Free(blurbPtr);
            }

            return(ret);
        }
Exemplo n.º 9
0
 public ParamSpecValueArray(string name, string nick, string blurb, ParamSpec elementSpec, ParamFlags flags)
     : this(New(name, nick, blurb, elementSpec, flags), Transfer.None)
 {
 }