libswami Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Signals |
GParamSpec * (*SwamiControlGetSpecFunc) (SwamiControl *control
); gboolean (*SwamiControlSetSpecFunc) (SwamiControl *control
,GParamSpec *pspec
); void (*SwamiControlGetValueFunc) (SwamiControl *control
,GValue *value
); void (*SwamiControlSetValueFunc) (SwamiControl *control
,SwamiControlEvent *event
,const GValue *value
); SwamiControl; enum SwamiControlFlags; #define SWAMI_CONTROL_FLAGS_USER_MASK #define SWAMI_CONTROL_SENDRECV #define SWAMI_CONTROL_UNUSED_FLAG_SHIFT enum SwamiControlConnPriority; #define SWAMI_CONTROL_CONN_PRIORITY_MASK #define SWAMI_CONTROL_CONN_DEFAULT_PRIORITY_VALUE enum SwamiControlConnFlags; #define SWAMI_CONTROL_CONN_BIDIR_INIT #define SWAMI_CONTROL_CONN_BIDIR_SPEC_INIT SwamiControl * swami_control_new (void
); void swami_control_connect (SwamiControl *src
,SwamiControl *dest
,guint flags
); void swami_control_connect_transform (SwamiControl *src
,SwamiControl *dest
,guint flags
,SwamiValueTransform trans1
,SwamiValueTransform trans2
,gpointer data1
,gpointer data2
,GDestroyNotify destroy1
,GDestroyNotify destroy2
); void swami_control_connect_item_prop (SwamiControl *dest
,GObject *object
,GParamSpec *pspec
); void swami_control_disconnect (SwamiControl *src
,SwamiControl *dest
); void swami_control_disconnect_all (SwamiControl *control
); void swami_control_disconnect_unref (SwamiControl *control
); IpatchList * swami_control_get_connections (SwamiControl *control
,SwamiControlConnFlags dir
); void swami_control_set_transform (SwamiControl *src
,SwamiControl *dest
,SwamiValueTransform trans
,gpointer data
,GDestroyNotify destroy
); void swami_control_get_transform (SwamiControl *src
,SwamiControl *dest
,SwamiValueTransform *trans
); void swami_control_set_flags (SwamiControl *control
,int flags
); int swami_control_get_flags (SwamiControl *control
); void swami_control_set_queue (SwamiControl *control
,SwamiControlQueue *queue
); SwamiControlQueue * swami_control_get_queue (SwamiControl *control
); GParamSpec * swami_control_get_spec (SwamiControl *control
); gboolean swami_control_set_spec (SwamiControl *control
,GParamSpec *pspec
); gboolean swami_control_sync_spec (SwamiControl *control
,SwamiControl *source
,SwamiValueTransform trans
,gpointer data
); GParamSpec * swami_control_transform_spec (SwamiControl *control
,SwamiControl *source
,SwamiValueTransform trans
,gpointer data
); void swami_control_set_value_type (SwamiControl *control
,GType type
); void swami_control_get_value (SwamiControl *control
,GValue *value
); void swami_control_get_value_native (SwamiControl *control
,GValue *value
); void swami_control_set_value (SwamiControl *control
,const GValue *value
); void swami_control_set_value_no_queue (SwamiControl *control
,const GValue *value
); void swami_control_set_event (SwamiControl *control
,SwamiControlEvent *event
); void swami_control_set_event_no_queue (SwamiControl *control
,SwamiControlEvent *event
); void swami_control_set_event_no_queue_loop (SwamiControl *control
,SwamiControlEvent *event
); void swami_control_transmit_value (SwamiControl *control
,const GValue *value
); void swami_control_transmit_event (SwamiControl *control
,SwamiControlEvent *event
); void swami_control_transmit_event_loop (SwamiControl *control
,SwamiControlEvent *event
); void swami_control_do_event_expiration (void
); SwamiControlEvent * swami_control_new_event (SwamiControl *control
,SwamiControlEvent *origin
,const GValue *value
);
GObject +----SwamiLock +----SwamiControl +----SwamiControlFunc +----SwamiControlHub +----SwamiControlValue +----SwamiControlProp
GParamSpec * (*SwamiControlGetSpecFunc) (SwamiControl *control
);
A SwamiControlClass optional method type to get the parameter spec
from a control. If this method is not used or it returns NULL
then
the control is assumed to accept control events of any type.
Note: The control is locked while calling this method. Also, this method should return the parameter spec quickly, to speed up the event emission process.
|
Control to get parameter spec for |
Returns : |
Should return the parameter specification for the control or
NULL for type independent controls. Reference count should not be modified,
this is handled by the caller.
|
gboolean (*SwamiControlSetSpecFunc) (SwamiControl *control
,GParamSpec *pspec
);
A SwamiControlClass optional method type to set the parameter spec
for a control. The method should call g_param_spec_ref()
followed by
g_param_spec_sink()
to take over the reference.
If a control has a specific value type and the
SWAMI_CONTROL_SPEC_NO_CONV is not set then the parameter spec is
converted to the parameter spec type used for the given value type and the
min/max/default values of the parameter spec will be processed with the
set_trans value transform function if assigned,
otherwise the parameter spec is passed as is without conversion.
Note: The control is locked while calling this method.
void (*SwamiControlGetValueFunc) (SwamiControl *control
,GValue *value
);
A SwamiControlClass optional method type to get the value from a
value control that is readable (SWAMI_CONTROL_SENDS flag must be
set). The value
has been initialized to the native type of the
control's parameter spec. If this method is used then
SwamiControlGetSpecFunc must also be set.
Note: The control is not locked when calling this method.
|
Control to get value from |
|
Caller supplied value to store control value in |
void (*SwamiControlSetValueFunc) (SwamiControl *control
,SwamiControlEvent *event
,const GValue *value
);
A SwamiControlClass optional method type to receive control
values. If the SWAMI_CONTROL_NO_CONV flag is not set for this
control and the SwamiControlGetSpecFunc returns a parameter spec
then value
will be the result of the original event value
converted to the control's native type.
This method gets called for events received via a control's inputs
or when swami_control_set_event()
or swami_control_set_value()
is called.
Note: The control is not locked during this method call.
|
Control that is receiving an event |
|
Control event being received |
|
Value which is being received (possibly converted from original event value depending on the control's settings) |
typedef enum { SWAMI_CONTROL_SENDS = 1 << 0, /* control is readable/sends */ SWAMI_CONTROL_RECVS = 1 << 1, /* control is writable/receives */ SWAMI_CONTROL_NO_CONV = 1 << 2, /* don't convert incoming values */ SWAMI_CONTROL_NATIVE = 1 << 3, /* values of native value type only */ SWAMI_CONTROL_VALUE = 1 << 4, /* value control - queue optimization */ SWAMI_CONTROL_SPEC_NO_CONV = 1 << 5 /* don't convert parameter spec type */ } SwamiControlFlags;
typedef enum { SWAMI_CONTROL_CONN_PRIORITY_DEFAULT = 0, SWAMI_CONTROL_CONN_PRIORITY_LOW = 1, SWAMI_CONTROL_CONN_PRIORITY_MEDIUM = 2, SWAMI_CONTROL_CONN_PRIORITY_HIGH = 3 } SwamiControlConnPriority;
typedef enum /*< flags >*/ { SWAMI_CONTROL_CONN_INPUT = 1 << 2, /* set for inputs (used internally) */ SWAMI_CONTROL_CONN_OUTPUT = 1 << 3, /* set for outputs (used internally) */ SWAMI_CONTROL_CONN_INIT = 1 << 4, /* update value on connect */ SWAMI_CONTROL_CONN_BIDIR = 1 << 5, /* make a bi-directional connection */ SWAMI_CONTROL_CONN_SPEC = 1 << 6 /* synchronize the parameter spec on connect */ } SwamiControlConnFlags;
SwamiControl * swami_control_new (void
);
Create a new SwamiControl instance. SwamiControl is the base class for other control types as well. Creating an instance of a SwamiControl will create a send only event control.
Returns : |
New SwamiControl object, the caller owns a reference. |
void swami_control_connect (SwamiControl *src
,SwamiControl *dest
,guint flags
);
Connect two controls (i.e., when the src
control's value changes
the dest
control is set to this value). Useful flags include the
SWAMI_CONTROL_CONN_INIT flag which will cause dest
to be set to
the current value of src
and SWAMI_CONTROL_CONN_BIDIR which will
cause a bi-directional connection to be made (as if 2 calls where
made to this function with the src
and dest
swapped the second
time). The connection priority can also be set via the flags field
by or-ing in SwamiControlConnPriority values (assumes default
priority if not specified). The priority determines the order in
which connections are processed. The SWAMI_CONTROL_CONN_SPEC flag will
cause the parameter spec of the dest
control to be set to that of src
.
|
Source control to connect (readable) |
|
Destination control to connect (writable) |
|
Flags for this connection (SwamiControlConnFlags) |
void swami_control_connect_transform (SwamiControl *src
,SwamiControl *dest
,guint flags
,SwamiValueTransform trans1
,SwamiValueTransform trans2
,gpointer data1
,gpointer data2
,GDestroyNotify destroy1
,GDestroyNotify destroy2
);
Like swami_control_connect()
but transform functions can be specified
during connect, rather than having to call swami_control_set_transform()
later.
|
Source control to connect (readable) |
|
Destination control to connect (writable) |
|
Flags for this connection (SwamiControlConnFlags). |
|
Value transform function from src to dest (or NULL for no transform)
|
|
Value transform function from dest to src
(SWAMI_CONTROL_CONN_BIDIR only, NULL for no transform).
|
|
User data to pass to trans1 function.
|
|
User data to pass to trans2 function.
(SWAMI_CONTROL_CONN_BIDIR only, NULL for no transform).
|
|
Optional callback to free data1 when trans1 is disconnected.
|
|
Optional callback to free data2 when trans2 is disconnected.
|
void swami_control_connect_item_prop (SwamiControl *dest
,GObject *object
,GParamSpec *pspec
);
An ultra-convenience function to connect an existing control to a synthesis property of an object (IpatchItem property for example). The connection is bi-directional and transform functions are used to convert between the two unit types as needed.
|
Destination control |
|
Object of source parameter to convert to user units |
|
Parameter spec of property of object to connect to
|
void swami_control_disconnect (SwamiControl *src
,SwamiControl *dest
);
Disconnects a connection specified by its src
and dest
controls.
|
Source control of an existing connection |
|
Destination control of an existing connection |
void swami_control_disconnect_all (SwamiControl *control
);
Disconnect all connections from a control.
|
Swami control object |
void swami_control_disconnect_unref (SwamiControl *control
);
A convenience function to disconnect all connections of a control and unref it. This is often useful for GDestroyNotify callbacks where a control's creator wishes to destroy the control. The control is only destroyed if it is not referenced by anything else.
|
Swami control object |
IpatchList * swami_control_get_connections (SwamiControl *control
,SwamiControlConnFlags dir
);
Get a list of connections to a control.
|
Control to get connections of |
|
Direction of connections to get, SWAMI_CONTROL_CONN_INPUT for incoming connections, SWAMI_CONTROL_CONN_OUTPUT for outgoing (values can be OR'd to return all connections). |
Returns : |
List of SwamiControl objects connected to control or NULL if
none. Caller owns reference to returned list and should unref when done.
|
void swami_control_set_transform (SwamiControl *src
,SwamiControl *dest
,SwamiValueTransform trans
,gpointer data
,GDestroyNotify destroy
);
Assigns a value transform function to an existing control connection. The
connection is specified by src
and dest
controls. The transform function
will receive values from the src
control and should transform them
appropriately for the dest
.
void swami_control_get_transform (SwamiControl *src
,SwamiControl *dest
,SwamiValueTransform *trans
);
Gets the current value transform function to an existing control connection.
The connection is specified by src
and dest
controls. The value stored to
trans
may be NULL
if no transform function is assigned.
|
Source control of the connection |
|
Destination control of the connection |
|
Pointer to store transform function of the connection |
void swami_control_set_flags (SwamiControl *control
,int flags
);
Set flags of a control object. Flags can only be set for controls that don't have any connections yet.
|
Control object |
|
Value to assign to control flags (SwamiControlFlags) |
int swami_control_get_flags (SwamiControl *control
);
Get the flags from a control object.
|
Control object |
Returns : |
Flags value (SwamiControlFlags) for control
|
void swami_control_set_queue (SwamiControl *control
,SwamiControlQueue *queue
);
Set the queue used by a control object. When a control has a queue all receive/set events are sent to the queue. This queue can then be processed at a later time (a GUI thread for example).
|
Control object |
|
Queue to use for control or NULL to disable queuing
|
SwamiControlQueue * swami_control_get_queue (SwamiControl *control
);
Get the queue used by a control object.
|
Control object |
Returns : |
The queue assigned to a control or NULL if it does not have one.
The caller owns a reference to the returned queue object.
|
GParamSpec * swami_control_get_spec (SwamiControl *control
);
Get a control object's parameter specification.
|
Control object |
Returns : |
The parameter spec or NULL on error or if the given
control is type independent. The returned spec is used internally
and should not be modified or freed, however the caller does own a
reference to it and should unref it with g_param_spec_unref when
finished.
|
gboolean swami_control_set_spec (SwamiControl *control
,GParamSpec *pspec
);
Set a control object's parameter specification. This function uses
the pspec
directly (its refcount is incremented and ownership is
taken). The parameter spec is not permitted to be of a different
type than the previous parameter spec.
gboolean swami_control_sync_spec (SwamiControl *control
,SwamiControl *source
,SwamiValueTransform trans
,gpointer data
);
Synchronizes a control
object's parameter spec to the source
control.
The source
control must already have an assigned parameter spec and the
control
should have an assigned value type. The optional trans
parameter
can be used to specify a transform function, which is executed on the
min, max and default components of the parameter spec when creating the new
param spec.
GParamSpec * swami_control_transform_spec (SwamiControl *control
,SwamiControl *source
,SwamiValueTransform trans
,gpointer data
);
Transforms a parameter spec from a source
control in preperation for
assignment to control
(but doesn't actually assign it).
|
Destination control for the transformed parameter spec |
|
Source control with the parameter spec to transform |
|
Transform function |
|
User defined data to pass to transform function |
Returns : |
Transformed parameter spec or NULL on error, the reference count
is 1 and floating, which means it should be taken over by calling
g_param_spec_ref() followed by g_param_spec_sink() .
|
void swami_control_set_value_type (SwamiControl *control
,GType type
);
Usually only called by SwamiControl derived types from within
their instance init function. Sets the parameter spec value type
for control
and should be called once for specific type value
based controls before being used and cannot be changed
afterwards. If the type is not set then the control is a wild card
control (can handle any value). For GBoxed and GObject based values
use the specific GType for type
.
|
Control to set value type of |
|
Value type to assign to control |
void swami_control_get_value (SwamiControl *control
,GValue *value
);
Get the current value of a value control object. The control
must
have the SWAMI_CONTROL_SENDS flag set and be a value type control
with an assigned parameter spec. The value
parameter should be
initialized to the type of the control or a transformable type.
|
Control object of type SWAMI_CONTROL_VALUE |
|
Caller supplied initialized GValue structure to store the value in. |
void swami_control_get_value_native (SwamiControl *control
,GValue *value
);
Like swami_control_get_value()
but forces value
to be the native type of
the control, rather than transforming the value to the initialized value
type. Therefore value
should be un-initialized, contrary to
swami_control_get_value()
.
|
Control object of type SWAMI_CONTROL_VALUE |
|
Caller supplied uninitalized GValue structure to store the value in. |
void swami_control_set_value (SwamiControl *control
,const GValue *value
);
Sets/sends a value to a control object. If the control has a queue
assigned to it then the value is queued. The value
parameter
should be of a type transformable to the type used by control
(see
g_value_transformable). The control
must have the
SWAMI_CONTROL_RECVS flag set.
|
Control object |
|
Value to set control to |
void swami_control_set_value_no_queue (SwamiControl *control
,const GValue *value
);
Sets/sends a value to a control object bypassing the control's
queue if it has one assigned to it. The value
parameter should be
of a type transformable to the type used by control
(see
g_value_transformable). The control
must have the
SWAMI_CONTROL_RECVS flag set. Normally the swami_control_set_value()
function should be used instead to send a value to a control, use this
only if you know what you are doing since some controls are sensitive to
when they are processed (within a GUI thread for instance).
|
Control object |
|
Value to set control to |
void swami_control_set_event (SwamiControl *control
,SwamiControlEvent *event
);
Sets the value of a control object (value controls) or sends an
event (stream controls). This is like swami_control_set_value()
but
uses an existing event, rather than creating a new one. The
control
must have the SWAMI_CONTROL_RECVS flag set. If the
control has a queue then the event will be added to the queue.
|
Control object |
|
Event to set control to |
void swami_control_set_event_no_queue (SwamiControl *control
,SwamiControlEvent *event
);
Like swami_control_set_event()
but bypasses any queue that a
control might have. The control
must have the SWAMI_CONTROL_RECVS
flag set.
|
Control object |
|
Event to set control to |
void swami_control_set_event_no_queue_loop (SwamiControl *control
,SwamiControlEvent *event
);
Like swami_control_set_event_no_queue()
but doesn't do an event
loop check. This function is usually only used by
SwamiControlQueue objects. The control
must have the
SWAMI_CONTROL_RECVS flag set.
|
Control object |
|
Event to set control to |
void swami_control_transmit_value (SwamiControl *control
,const GValue *value
);
Sends a value to all output connections of control
. Usually only
used by SwamiControl object implementations. The value
is used if
not NULL
or the control's value is used (readable value controls
only). This is a convenience function that creates a
SwamiControlEvent based on the new transmit value, use
swami_control_transmit_event()
to send an existing event.
|
Control object |
|
Value to transmit or NULL (readable value controls only, sends
value changed event).
|
void swami_control_transmit_event (SwamiControl *control
,SwamiControlEvent *event
);
This function sends an event to all destination connected controls. Usually only used by SwamiControl object implementations.
|
Control object |
|
Event to send to output connections of control
|
void swami_control_transmit_event_loop (SwamiControl *control
,SwamiControlEvent *event
);
Like swami_control_transmit_event()
but doesn't do an event loop check.
This is useful for control implementations that receive an event and
want to re-transmit it (swami_control_transmit_event()
would stop it,
since the event is already in the active list for the control).
|
Control object |
|
Event to send to output connections of control
|
void swami_control_do_event_expiration (void
);
Processes all controls in search of inactive expired events. This should
be called periodically to expire events in controls that don't receive any
events for a long period after previous activity. Note that currently this
is handled automatically if swami_init()
is called.
SwamiControlEvent * swami_control_new_event (SwamiControl *control
,SwamiControlEvent *origin
,const GValue *value
);
Create an event for control
. If value
is non NULL
then
it is used as the value of the event otherwise the control
is used as
the value of the event (a value changed event).
|
Control object |
|
Origin event or NULL if new event is origin
|
|
Value to use as event value or NULL to use control as the
value (a value change event)
|
Returns : |
New event with a refcount of 1 which the caller owns. Remember
that a SwamiControlEvent is not a GObject and has its own reference
counting routines swami_control_event_ref() and
swami_control_event_unref() .
|
"connect"
signalvoid user_function (SwamiControl *swamicontrol, GObject *arg1, guint arg2, gpointer user_data) : Run First
"disconnect"
signalvoid user_function (SwamiControl *swamicontrol, GObject *arg1, guint arg2, gpointer user_data) : Run Last
"spec-changed"
signalvoid user_function (SwamiControl *swamicontrol, GParamSpec *arg1, gpointer user_data) : Run Last