Miscellaneous Utilities

Miscellaneous Utilities — functions to simplify some common tasks

Functions

Description

This section provides several functions and macros that reduce the code size or simplify some common tasks.

Functions

LW_BIND()

#define LW_BIND(obj, prop)                g_settings_bind (self->priv->settings, prop, obj, prop, G_SETTINGS_BIND_GET)

This macro is used to make a very common call to g_settings_bind shorter. It binds a key called prop from the settings to a property called prop of the GObject obj . For color, enum or range properties see LW_BIND_COLOR(), LW_BIND_ENUM() or LW_BIND_RANGE().

This macro assumes that self->priv->settings exists in the current context and is a GSettings object, and that the property and key names are the same.

Parameters

obj

A GObject with a property named prop .

 

prop

The property and key to bind to. Property name and key name will both be set to prop .

 

Since: 0.5


LW_BIND_COLOR()

#define LW_BIND_COLOR(obj, prop)   lw_settings_bind_color (self->priv->settings, prop, obj, prop, G_SETTINGS_BIND_GET)

The same as LW_BIND(), but it binds a color property to a settings key.

This macro assumes that self->priv->settings exists in the current context and is a GSettings object, and that the property and key names are the same.

Parameters

obj

A GObject with a property named prop .

 

prop

The property and key to bind to. Property name and key name will both be set to prop .

 

Since: 0.5


LW_BIND_ENUM()

#define LW_BIND_ENUM(obj, prop)    lw_settings_bind_enum  (self->priv->settings, prop, obj, prop, G_SETTINGS_BIND_GET)

The same as LW_BIND(), but it binds an enum property to a settings key.

This macro assumes that self->priv->settings exists in the current context and is a GSettings object, and that the property and key names are the same.

Parameters

obj

A GObject with a property named prop .

 

prop

The property and key to bind to. Property name and key name will both be set to prop .

 

Since: 0.5


LW_BIND_RANGE()

#define LW_BIND_RANGE(obj, prop)   lw_settings_bind_range (self->priv->settings, prop, obj, prop, G_SETTINGS_BIND_GET)

The same as LW_BIND(), but it binds a range property to a settings key.

This macro assumes that self->priv->settings exists in the current context and is a GSettings object, and that the property and key names are the same.

Parameters

obj

A GObject with a property named prop .

 

prop

The property and key to bind to. Property name and key name will both be set to prop .

 

Since: 0.5


LW_OPENGL_1_4_HELPER()

#define             LW_OPENGL_1_4_HELPER(fun20, fun14, params)

This macro calls fun20 with params as parameters if OpenGL 2.0 or later is available on the system. For systems with OpenGL before version 2.0 it calls fun14 with params as parameters.

Parameters

fun20

Name of the function for OpenGL 2.0+

 

fun14

Name of the function before OpenGL 2.0

 

params

The function's parameters

 

Since: 0.5


lw_settings_bind_color ()

void
lw_settings_bind_color (GSettings *settings,
                        const gchar *key,
                        gpointer object,
                        const gchar *property,
                        GSettingsBindFlags flags);

This function calls g_settings_bind_with_mapping() with the required mapping functions for colors. It uses lw_color_get_color_mapping() and lw_color_set_color_mapping() as mapping functions.

Parameters

settings

A GSettings object

 

key

The key to bind

 

object

A GObject.

[type GObject.Object]

property

The name of the property to bind

 

flags

Flags for the binding

 

Since: 0.4


lw_settings_bind_range ()

void
lw_settings_bind_range (GSettings *settings,
                        const gchar *key,
                        gpointer object,
                        const gchar *property,
                        GSettingsBindFlags flags);

This function calls g_settings_bind_with_mapping() with the required mapping functions for LwRange properties. It uses lw_range_get_range_mapping() and lw_range_set_range_mapping() as mapping functions.

Parameters

settings

A GSettings object

 

key

The key to bind

 

object

A GObject.

[type GObject.Object]

property

The name of the property to bind

 

flags

Flags for the binding

 

Since: 0.4


lw_settings_bind_enum ()

void
lw_settings_bind_enum (GSettings *settings,
                       const gchar *key,
                       gpointer object,
                       const gchar *property,
                       GSettingsBindFlags flags);

Creates a binding between an enum key and a guint property . This function passes all params to g_settings_bind_with_mapping() and sets the required mapping functions.

Parameters

settings

A GSettings object

 

key

The key to bind

 

object

A GObject.

[type GObject.Object]

property

The name of the property to bind

 

flags

Flags for the binding

 

Since: 0.4


lw_load_gresource ()

GResource *
lw_load_gresource (const gchar *path);

Parameters

path

the path to the gresource file

 

Returns

a pointer to the GResource or NULL in case of fail

Load a gresource file so that you can load resources in any function of the application. Displays an error in case of fail

Since: 0.5


lw_unload_gresource ()

void
lw_unload_gresource (GResource *resource);

Unload a gresource, making its files unavailable

Parameters

resource

the GResource to unload

 

Since: 0.5

Types and Values