Skip to content

GObject.ParamSpec

class

GParamSpec encapsulates the metadata required to specify parameters, such as GObject properties.

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 GObject.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.

Methods

get_blurb

def get_blurb(self) -> str | None

Get the short description of a ParamSpec.

get_default_value

def get_default_value(self) -> Value

Gets the default value of pspec as a pointer to a Value.

The Value will remain valid for the life of pspec.

get_name

def get_name(self) -> str

Get the name of a ParamSpec.

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

get_name_quark

def get_name_quark(self) -> GLib.Quark

Gets the GQuark for the name.

get_nick

def get_nick(self) -> str

Get the nickname of a ParamSpec.

get_qdata

def get_qdata(self, quark: GLib.Quark) -> int | None

Gets back user data pointers stored via ParamSpec.set_qdata.

Parameters:

  • quark — a GQuark, naming the user data pointer

get_redirect_target

def get_redirect_target(self) -> ParamSpec | None

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 ParamSpecOverride. See ObjectClass.override_property for an example of the use of this capability.

set_qdata

def set_qdata(self, quark: GLib.Quark, data: int | None = ...) -> None

Sets an opaque, named pointer on a ParamSpec. The name is specified through a GQuark (retrieved e.g. via GLib.quark_from_static_string), and the pointer can be gotten back from the pspec with ParamSpec.get_qdata. Setting a previously set user data pointer, overrides (frees) the old pointer set, using None as pointer essentially removes the data stored.

Parameters:

  • quark — a GQuark, naming the user data pointer
  • data — an opaque user data pointer

sink

def sink(self) -> None

The initial reference count of a newly created ParamSpec 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); [ParamSpec.sink](./ParamSpec.md#method-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).

steal_qdata

def steal_qdata(self, quark: GLib.Quark) -> int | None

Gets back user data pointers stored via ParamSpec.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.

Parameters:

  • quark — a GQuark, naming the user data pointer

Static functions

is_valid_name

@staticmethod
def is_valid_name(name: str) -> bool

Validate a property name for a ParamSpec. 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][classGObject.ParamSpec#parameter-names] for details of the rules for valid names.

Parameters:

  • name — the canonical name of the property

Virtual methods

do_finalize

def do_finalize(self) -> None

The instance finalization function (optional), should chain up to the finalize method of the parent class.

do_value_is_valid

def do_value_is_valid(self, value: Value) -> bool

Checks if contents of value comply with the specifications set out by this type, without modifying the value. This vfunc is optional. If it isn't set, GObject will use value_validate. Since 2.74

do_value_set_default

def do_value_set_default(self, value: Value) -> None

Resets a value to the default value for this type (recommended, the default is Value.reset), see param_value_set_default.

do_value_validate

def do_value_validate(self, value: Value) -> bool

Ensures that the contents of value comply with the specifications set out by this type (optional), see param_value_validate.

do_values_cmp

def do_values_cmp(self, value1: Value, value2: Value) -> int

Compares value1 with value2 according to this type (recommended, the default is memcmp()), see param_values_cmp.