Class ParamSpec
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
ParamArray
,ParamFraction
,ParamSpec.ParamSpecImpl
,ParamSpecBoolean
,ParamSpecBoxed
,ParamSpecChar
,ParamSpecDouble
,ParamSpecEnum
,ParamSpecExpression
,ParamSpecFlags
,ParamSpecFloat
,ParamSpecGType
,ParamSpecInt
,ParamSpecInt64
,ParamSpecLong
,ParamSpecObject
,ParamSpecOverride
,ParamSpecParam
,ParamSpecPointer
,ParamSpecString
,ParamSpecUChar
,ParamSpecUInt
,ParamSpecUInt64
,ParamSpecULong
,ParamSpecUnichar
,ParamSpecValueArray
,ParamSpecVariant
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 GObjects.signalNew(java.lang.String, org.gnome.glib.Type, java.util.Set<org.gnome.gobject.SignalFlags>, int, org.gnome.gobject.SignalAccumulator, org.gnome.gobject.SignalCMarshaller, org.gnome.glib.Type, int, java.lang.Object...)
).
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The class structure for the GParamSpec type.static class
The ParamSpecImpl type represents a native instance of the abstract ParamSpec class. -
Constructor Summary
ConstructorDescriptionParamSpec
(MemorySegment address) Create a ParamSpec proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected ParamSpec
asParent()
Returns this instance as if it were its parent type.protected void
The instance finalization function (optional), should chain up to the finalize method of the parent class.getBlurb()
Get the short description of aGParamSpec
.Gets the default value of this ParamSpec as a pointer to aGValue
.static MemoryLayout
The memory layout of the native struct.getName()
Get the name of aGParamSpec
.Gets the GQuark for the name.getNick()
Get the nickname of aGParamSpec
.Gets back user data pointers stored via g_param_spec_set_qdata().If the paramspec redirects operations to another paramspec, returns that paramspec.static Type
getType()
Get the GType of the GParamSpec classstatic ParamSpec
internal
(Type paramType, String name, @Nullable String nick, @Nullable String blurb, Set<ParamFlags> flags) Creates a newGParamSpec
instance.static ParamSpec
internal
(Type paramType, String name, @Nullable String nick, @Nullable String blurb, ParamFlags... flags) Creates a newGParamSpec
instance.static boolean
isValidName
(String name) Validate a property name for aGParamSpec
.ref()
Increments the reference count of this ParamSpec.refSink()
Convenience function to ref and sink aGParamSpec
.void
setQdata
(Quark quark, @Nullable MemorySegment data) Sets an opaque, named pointer on aGParamSpec
.void
setQdataFull
(Quark quark, @Nullable MemorySegment data) This function works like g_param_spec_set_qdata(), but in addition, avoid (*destroy) (gpointer)
function may be specified which is called withdata
as argument when the this ParamSpec is finalized, or the data is being overwritten by a call to g_param_spec_set_qdata() with the samequark
.void
sink()
The initial reference count of a newly createdGParamSpec
is 1, even though no one has explicitly called g_param_spec_ref() on it yet.stealQdata
(Quark quark) Gets back user data pointers stored via g_param_spec_set_qdata() and removes thedata
from this ParamSpec without invoking its destroy() function (if any was set).void
unref()
Decrements the reference count of a this ParamSpec.protected boolean
valueIsValid
(Value value) Checks if contents ofvalue
comply with the specifications set out by this type, without modifying the value.protected int
Comparesvalue1
withvalue2
according to this type (recommended, the default is memcmp()), see g_param_values_cmp().protected void
valueSetDefault
(Value value) Resets avalue
to the default value for this type (recommended, the default is g_value_reset()), see g_param_value_set_default().protected boolean
valueValidate
(Value value) Ensures that the contents ofvalue
comply with the specifications set out by this type (optional), see g_param_value_validate().Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
ParamSpec
Create a ParamSpec proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
internal
public static ParamSpec internal(Type paramType, String name, @Nullable @Nullable String nick, @Nullable @Nullable String blurb, Set<ParamFlags> flags) Creates a newGParamSpec
instance.See
GObject.ParamSpec#parameter-names
for details of the rules forname
. Names which violate these rules lead to undefined behaviour.Beyond the name,
GParamSpecs
have two more descriptive strings, thenick
andblurb
, which may be used as a localized label and description. For GTK and related libraries these are considered deprecated and may be omitted, while for other libraries such as GStreamer and its plugins they are essential. When in doubt, follow the conventions used in the surrounding code and supporting libraries.- Parameters:
paramType
- theGType
for the property; must be derived fromG_TYPE_PARAM
name
- the canonical name of the propertynick
- the nickname of the propertyblurb
- a short description of the propertyflags
- a combination ofGParamFlags
- Returns:
- (transfer floating): a newly allocated
GParamSpec
instance, which is initially floating
-
internal
public static ParamSpec internal(Type paramType, String name, @Nullable @Nullable String nick, @Nullable @Nullable String blurb, ParamFlags... flags) Creates a newGParamSpec
instance.See
GObject.ParamSpec#parameter-names
for details of the rules forname
. Names which violate these rules lead to undefined behaviour.Beyond the name,
GParamSpecs
have two more descriptive strings, thenick
andblurb
, which may be used as a localized label and description. For GTK and related libraries these are considered deprecated and may be omitted, while for other libraries such as GStreamer and its plugins they are essential. When in doubt, follow the conventions used in the surrounding code and supporting libraries.- Parameters:
paramType
- theGType
for the property; must be derived fromG_TYPE_PARAM
name
- the canonical name of the propertynick
- the nickname of the propertyblurb
- a short description of the propertyflags
- a combination ofGParamFlags
- Returns:
- (transfer floating): a newly allocated
GParamSpec
instance, which is initially floating
-
isValidName
Validate a property name for aGParamSpec
. This can be useful for dynamically-generated properties which need to be validated at run-time before actually trying to create them.See
GObject.ParamSpec#parameter-names
for details of the rules for valid names.- Parameters:
name
- the canonical name of the property- Returns:
true
ifname
is a valid property name,false
otherwise.
-
getBlurb
Get the short description of aGParamSpec
.- Returns:
- the short description of this ParamSpec.
-
getDefaultValue
Gets the default value of this ParamSpec as a pointer to aGValue
.The
GValue
will remain valid for the life of this ParamSpec.- Returns:
- a pointer to a
GValue
which must not be modified
-
getName
Get the name of aGParamSpec
.The name is always an "interned" string (as per g_intern_string()). This allows for pointer-value comparisons.
- Returns:
- the name of this ParamSpec.
-
getNameQuark
Gets the GQuark for the name.- Returns:
- the GQuark for this ParamSpec->name.
-
getNick
-
getQdata
Gets back user data pointers stored via g_param_spec_set_qdata().- Parameters:
quark
- aGQuark
, naming the user data pointer- Returns:
- the user data pointer set, or
null
-
getRedirectTarget
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 typeGParamSpecOverride
. See g_object_class_override_property() for an example of the use of this capability.- Returns:
- paramspec to which requests on this
paramspec should be redirected, or
null
if none.
-
ref
Increments the reference count of this ParamSpec.- Returns:
- the
GParamSpec
that was passed into this function
-
refSink
Convenience function to ref and sink aGParamSpec
.- Returns:
- the
GParamSpec
that was passed into this function
-
setQdata
Sets an opaque, named pointer on aGParamSpec
. The name is specified through aGQuark
(retrieved e.g. via g_quark_from_static_string()), and the pointer can be gotten back from the this ParamSpec with g_param_spec_get_qdata(). Setting a previously set user data pointer, overrides (frees) the old pointer set, usingnull
as pointer essentially removes the data stored.- Parameters:
quark
- aGQuark
, naming the user data pointerdata
- an opaque user data pointer
-
setQdataFull
This function works like g_param_spec_set_qdata(), but in addition, avoid (*destroy) (gpointer)
function may be specified which is called withdata
as argument when the this ParamSpec is finalized, or the data is being overwritten by a call to g_param_spec_set_qdata() with the samequark
.- Parameters:
quark
- aGQuark
, naming the user data pointerdata
- an opaque user data pointer
-
sink
public void sink()The initial reference count of a newly createdGParamSpec
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 callsg_param_spec_ref (pspec); g_param_spec_sink (pspec);
in sequence on it, taking over the initial reference count (thus ending up with a this ParamSpec that has a reference count of 1 still, but is not flagged "floating" anymore). -
stealQdata
Gets back user data pointers stored via g_param_spec_set_qdata() and removes thedata
from this ParamSpec 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
- aGQuark
, naming the user data pointer- Returns:
- the user data pointer set, or
null
-
unref
public void unref()Decrements the reference count of a this ParamSpec. -
finalize_
protected void finalize_()The instance finalization function (optional), should chain up to the finalize method of the parent class. -
valueIsValid
Checks if contents ofvalue
comply with the specifications set out by this type, without modifying the value. This vfunc is optional. If it isn't set, GObject will usevalueValidate
. Since 2.74 -
valueSetDefault
Resets avalue
to the default value for this type (recommended, the default is g_value_reset()), see g_param_value_set_default(). -
valueValidate
Ensures that the contents ofvalue
comply with the specifications set out by this type (optional), see g_param_value_validate(). -
valuesCmp
-