Settings

Settings — Manage the settings

Synopsis

#include <rclib-settings.h>

void                rclib_settings_apply                ();
void                rclib_settings_exit                 ();
gboolean            rclib_settings_get_boolean          (const gchar *group_name,
                                                         const gchar *key,
                                                         GError **error);
gboolean *          rclib_settings_get_boolean_list     (const gchar *group_name,
                                                         const gchar *key,
                                                         gsize *length,
                                                         GError **error);
gdouble             rclib_settings_get_double           (const gchar *group_name,
                                                         const gchar *key,
                                                         GError **error);
gdouble *           rclib_settings_get_double_list      (const gchar *group_name,
                                                         const gchar *key,
                                                         gsize *length,
                                                         GError **error);
gint                rclib_settings_get_integer          (const gchar *group_name,
                                                         const gchar *key,
                                                         GError **error);
gint *              rclib_settings_get_integer_list     (const gchar *group_name,
                                                         const gchar *key,
                                                         gsize *length,
                                                         GError **error);
gchar *             rclib_settings_get_string           (const gchar *group_name,
                                                         const gchar *key,
                                                         GError **error);
gchar **            rclib_settings_get_string_list      (const gchar *group_name,
                                                         const gchar *key,
                                                         gsize *length,
                                                         GError **error);
gboolean            rclib_settings_has_key              (const gchar *group_name,
                                                         gchar *key,
                                                         GError **error);
gboolean            rclib_settings_init                 ();
gboolean            rclib_settings_load_from_file       (const gchar *filename);
void                rclib_settings_set_boolean          (const gchar *group_name,
                                                         const gchar *key,
                                                         gboolean value);
void                rclib_settings_set_boolean_list     (const gchar *group_name,
                                                         const gchar *key,
                                                         gboolean list[],
                                                         gsize length);
void                rclib_settings_set_double           (const gchar *group_name,
                                                         const gchar *key,
                                                         gdouble value);
void                rclib_settings_set_double_list      (const gchar *group_name,
                                                         const gchar *key,
                                                         gdouble list[],
                                                         gsize length);
void                rclib_settings_set_integer          (const gchar *group_name,
                                                         const gchar *key,
                                                         gint value);
void                rclib_settings_set_integer_list     (const gchar *group_name,
                                                         const gchar *key,
                                                         gint list[],
                                                         gsize length);
void                rclib_settings_set_string           (const gchar *group_name,
                                                         const gchar *key,
                                                         const gchar *string);
void                rclib_settings_set_string_list      (const gchar *group_name,
                                                         const gchar *key,
                                                         const gchar * const list[],
                                                         gsize length);
void                rclib_settings_sync                 ();
void                rclib_settings_update               ();

Description

Manage the settings in the player. The settings can be used in this library or the frontend UI. This module uses GKeyFile to store settings in .INI file style.

Notice: The settings are only used when the application is starting, or quiting, for load/save the settings. If you want to read or apply settings, you should check if the settings can be applied directly, if the settings are only used when the application is starting, then save them in this module.

Details

rclib_settings_apply ()

void                rclib_settings_apply                ();

Apply the settings to the modules in library.


rclib_settings_exit ()

void                rclib_settings_exit                 ();

Unload the setings module and save the settings to the settings file.


rclib_settings_get_boolean ()

gboolean            rclib_settings_get_boolean          (const gchar *group_name,
                                                         const gchar *key,
                                                         GError **error);

Returns the value associated with key under group_name as a boolean.

group_name :

a group name

key :

a key

error :

return location for a GError, or NULL

Returns :

The value associated with the key as a boolean, or FALSE if the key was not found or could not be parsed.

rclib_settings_get_boolean_list ()

gboolean *          rclib_settings_get_boolean_list     (const gchar *group_name,
                                                         const gchar *key,
                                                         gsize *length,
                                                         GError **error);

Returns the values associated with key under group_name as booleans.

group_name :

a group name

key :

a key

length :

the number of booleans returned

error :

return location for a GError, or NULL

Returns :

The values associated with the key as a list of booleans, or NULL if the key was not found or could not be parsed.

rclib_settings_get_double ()

gdouble             rclib_settings_get_double           (const gchar *group_name,
                                                         const gchar *key,
                                                         GError **error);

Returns the value associated with key under group_name as a double. If group_name is NULL, the start_group is used.

group_name :

a group name

key :

a key

error :

return location for a GError, or NULL

Returns :

The value associated with the key as a double, or 0.0 if the key was not found or could not be parsed.

rclib_settings_get_double_list ()

gdouble *           rclib_settings_get_double_list      (const gchar *group_name,
                                                         const gchar *key,
                                                         gsize *length,
                                                         GError **error);

Returns the values associated with key under group_name as doubles.

group_name :

a group name

key :

a key

length :

the number of doubles returned

error :

return location for a GError, or NULL

Returns :

The values associated with the key as a list of doubles, or NULL if the key was not found or could not be parsed.

rclib_settings_get_integer ()

gint                rclib_settings_get_integer          (const gchar *group_name,
                                                         const gchar *key,
                                                         GError **error);

Returns the value associated with key under group_name as an integer.

group_name :

a group name

key :

a key

error :

return location for a GError, or NULL

Returns :

The value associated with the key as an integer, or 0 if the key was not found or could not be parsed.

rclib_settings_get_integer_list ()

gint *              rclib_settings_get_integer_list     (const gchar *group_name,
                                                         const gchar *key,
                                                         gsize *length,
                                                         GError **error);

Returns the values associated with key under group_name as integers.

group_name :

a group name

key :

a key

length :

the number of integers returned

error :

return location for a GError, or NULL

Returns :

The values associated with the key as a list of integers, or NULL if the key was not found or could not be parsed.

rclib_settings_get_string ()

gchar *             rclib_settings_get_string           (const gchar *group_name,
                                                         const gchar *key,
                                                         GError **error);

Returns the string value associated with key under group_name.

group_name :

a group name

key :

a key

error :

return location for a GError, or NULL

Returns :

A newly allocated string or NULL if the specified key cannot be found.

rclib_settings_get_string_list ()

gchar **            rclib_settings_get_string_list      (const gchar *group_name,
                                                         const gchar *key,
                                                         gsize *length,
                                                         GError **error);

Returns the values associated with key under group_name.

group_name :

a group name

key :

a key

length :

return location for the number of returned strings, or NULL

error :

return location for a GError, or NULL

Returns :

A NULL-terminated string array or NULL if the specified key cannot be found. The array should be freed with g_strfreev(). [transfer full][array zero-terminated=1 length=length]

rclib_settings_has_key ()

gboolean            rclib_settings_has_key              (const gchar *group_name,
                                                         gchar *key,
                                                         GError **error);

Looks whether the key file has the key in the group.

group_name :

a group name

key :

a key

error :

return location for a GError

Returns :

TRUE if key is a part of group_name, FALSE otherwise.

rclib_settings_init ()

gboolean            rclib_settings_init                 ();

Initialize the settings module.

Returns :

Whether the initialization succeeded.

rclib_settings_load_from_file ()

gboolean            rclib_settings_load_from_file       (const gchar *filename);

Load settings from file.

filename :

the path of the settings file

Returns :

Whether the settings are loaded successfully.

rclib_settings_set_boolean ()

void                rclib_settings_set_boolean          (const gchar *group_name,
                                                         const gchar *key,
                                                         gboolean value);

Associates a new boolean value with key under group_name. If key cannot be found then it is created. If group_name cannot be found then it is created.

group_name :

a group name

key :

a key

value :

TRUE or FALSE

rclib_settings_set_boolean_list ()

void                rclib_settings_set_boolean_list     (const gchar *group_name,
                                                         const gchar *key,
                                                         gboolean list[],
                                                         gsize length);

Associates a list of boolean values with key under group_name. If key cannot be found then it is created. If group_name is NULL, the start_group is used.

group_name :

a group name

key :

a key

list :

an array of boolean values

length :

number of string values in list

rclib_settings_set_double ()

void                rclib_settings_set_double           (const gchar *group_name,
                                                         const gchar *key,
                                                         gdouble value);

Associates a new double value with key under group_name. If key cannot be found then it is created. If group_name cannot be found then it is created.

group_name :

a group name

key :

a key

value :

an double value

rclib_settings_set_double_list ()

void                rclib_settings_set_double_list      (const gchar *group_name,
                                                         const gchar *key,
                                                         gdouble list[],
                                                         gsize length);

Associates a list of double values with key under group_name. If key cannot be found then it is created. If group_name is NULL, the start_group is used.

group_name :

a group name

key :

a key

list :

an array of double values

length :

number of double values in list

rclib_settings_set_integer ()

void                rclib_settings_set_integer          (const gchar *group_name,
                                                         const gchar *key,
                                                         gint value);

Associates a new integer value with key under group_name. If key cannot be found then it is created. If group_name cannot be found then it is created.

group_name :

a group name

key :

a key

value :

an integer value

rclib_settings_set_integer_list ()

void                rclib_settings_set_integer_list     (const gchar *group_name,
                                                         const gchar *key,
                                                         gint list[],
                                                         gsize length);

Associates a list of integer values with key under group_name. If key cannot be found then it is created. If group_name is NULL, the start_group is used.

group_name :

a group name

key :

a key

list :

an array of integer values

length :

number of integer values in list

rclib_settings_set_string ()

void                rclib_settings_set_string           (const gchar *group_name,
                                                         const gchar *key,
                                                         const gchar *string);

Associates a new string value with key under group_name. If key cannot be found then it is created. If group_name cannot be found then it is created.

group_name :

a group name

key :

a key

string :

a string

rclib_settings_set_string_list ()

void                rclib_settings_set_string_list      (const gchar *group_name,
                                                         const gchar *key,
                                                         const gchar * const list[],
                                                         gsize length);

Associates a list of string values for key under group_name. If key cannot be found then it is created. If group_name cannot be found then it is created.

group_name :

a group name

key :

a key

list :

an array of string values

length :

number of string values in list

rclib_settings_sync ()

void                rclib_settings_sync                 ();

Save the settings to file if they are changed (become dirty).


rclib_settings_update ()

void                rclib_settings_update               ();

Update settings from the modules in the library.