LwRange

LwRange — handling a range of values

Functions

Types and Values

struct LwRange

Object Hierarchy

    GBoxed
    ╰── LwRange

Description

LwRange is used to give a plugin more diversity by using random values between a specific minimum and maximum value. The advantage of LwRange is, that you only have to handle one property instead of two.

The main purpose of LwRange is to get a minimum and a maximum value from the configurator, so the first step is to create such a key in your

GSettings schema file.

The next step is to create a property that can hold a LwRange and bind the property to the key from the schema file by using lw_settings_bind_range(). You have to create the property with g_param_spec_boxed() to hold a LwRange.

The example plugins hold some example code for how to use a LwRange.

Functions

lw_range_copy ()

LwRange *
lw_range_copy (const LwRange *range);

Makes a copy of a LwRange structure.

Parameters

range

A LwRange

 

Returns

A newly allocated LwRange. It should be freed through lw_range_free().

Since: 0.4


lw_range_free ()

void
lw_range_free (LwRange *range);

Frees a LwRange structure created with lw_range_copy().

Parameters

range

A LwRange

 

Since: 0.4


lw_range_clamp()

#define lw_range_clamp(r, v)  ((int) clampf(v, (r).min, (r).max))

Parameters

r

A LwRange structure

 

v

An int value

 

Returns

An integer that is next to v and contained in the range r

Since: 0.4


lw_range_clampf()

#define lw_range_clampf(r, v) (clampf(v, (r).min, (r).max))

Parameters

r

A LwRange structure

 

v

A float value

 

Returns

A float that is next to v and contained in the range r

Since: 0.4


lw_range_rand()

#define lw_range_rand(r)  ((int) rand2f((r).min, (r).max))

Parameters

r

A LwRange structure

 

Returns

A random integer that is contained in the range r

Since: 0.4


lw_range_randf()

#define lw_range_randf(r) (rand2f((r).min, (r).max))

Parameters

r

A LwRange structure

 

Returns

A random float that is contained in the range r

Since: 0.4


lw_range_get_range_mapping ()

gboolean
lw_range_get_range_mapping (GValue *value,
                            GVariant *variant,
                            gpointer p);

This function is used to convert a GSettings key to a LwRange. Use this function as get mapping function of g_settings_bind_with_mapping() or take a look at the lw_settings_bind_range() macro.

Parameters

value

Return location for the property value

 

variant

The GVariant

 

p

User data that was specified when the binding was created

 

Returns

TRUE if the conversion succeeded, FALSE in case of an error

Since: 0.4


lw_range_set_range_mapping ()

GVariant *
lw_range_set_range_mapping (const GValue *value,
                            const GVariantType *type,
                            gpointer p);

This function is used to convert a LwRange to a GSettings key. Use this function as set mapping function of g_settings_bind_with_mapping() or take a look at the lw_settings_bind_range() macro.

Parameters

value

A GValue containing the property value to map

 

type

The GVariantType to create

 

p

User data that was specified when the binding was created

 

Returns

A new GVariant holding the data from value, or NULL in case of an error

Since: 0.4

Types and Values

struct LwRange

struct LwRange {
	gfloat min;
	gfloat max;
};

Members

gfloat min;

lower endpoint of the range

 

gfloat max;

upper endpoint of the range

 

Since: 0.4