class GObject::ParamSpec

Overview

#GParamSpec is an object structure that encapsulates the metadata required to specify parameters, such as e.g. #GObject properties.

Parameter names # {#canonical-parameter-names}

A property name consists of one or more segments consisting of ASCII letters and digits, separated by either the - or _ character. The first character of a property name must be a letter. These are the same rules as for signal naming (see g_signal_new()).

When creating and looking up a #GParamSpec, either separator can be used, but they cannot be mixed. Using - is considerably more efficient, and is the ‘canonical form’. Using _ is discouraged.

Defined in:

lib/gi-crystal/src/auto/g_object-2.0/param_spec.cr
lib/gi-crystal/src/bindings/g_object/param_spec.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


def self.is_valid_name(name : String) : Bool #

Validate a property name for a #GParamSpec. This can be useful for dynamically-generated properties which need to be validated at run-time before actually trying to create them.

See [canonical parameter names][canonical-parameter-names] for details of the rules for valid names.


Instance Method Detail

def blurb : String? #

Get the short description of a #GParamSpec.


def default_value : GObject::Value #

Gets the default value of @pspec as a pointer to a #GValue.

The #GValue will remain valid for the life of @pspec.


def finalize #

Called by the garbage collector. Decreases the reference count of object. (i.e. its memory is freed).


def name : String #

Get the name of a #GParamSpec.

The name is always an "interned" string (as per g_intern_string()). This allows for pointer-value comparisons.


def name_quark : UInt32 #

Gets the GQuark for the name.


def nick : String #

Get the nickname of a #GParamSpec.


def qdata(quark : UInt32) : Pointer(Void)? #

Gets back user data pointers stored via g_param_spec_set_qdata().


def redirect_target : GObject::ParamSpec? #

If the paramspec redirects operations to another paramspec, returns that paramspec. Redirect is used typically for providing a new implementation of a property in a derived type while preserving all the properties from the parent type. Redirection is established by creating a property of type #GParamSpecOverride. See g_object_class_override_property() for an example of the use of this capability.


def ref_count : UInt32 #

Returns ParamSpec reference counter.


def set_qdata(quark : UInt32, data : Pointer(Void)?) : Nil #

Sets an opaque, named pointer on a #GParamSpec. The name is specified through a #GQuark (retrieved e.g. via g_quark_from_static_string()), and the pointer can be gotten back from the @pspec with g_param_spec_get_qdata(). Setting a previously set user data pointer, overrides (frees) the old pointer set, using nil as pointer essentially removes the data stored.


def sink : Nil #

The initial reference count of a newly created #GParamSpec is 1, even though no one has explicitly called g_param_spec_ref() on it yet. So the initial reference count is flagged as "floating", until someone calls g_param_spec_ref (pspec); g_param_spec_sink (pspec); in sequence on it, taking over the initial reference count (thus ending up with a @pspec that has a reference count of 1 still, but is not flagged "floating" anymore).


def steal_qdata(quark : UInt32) : Pointer(Void)? #

Gets back user data pointers stored via g_param_spec_set_qdata() and removes the @data from @pspec without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier.


def to_unsafe : Pointer(Void) #

Returns a pointer to the C object.