1.13 <GKeyFile>

Structure: <GKeyFile>

<GKeyFile> parses .ini-like config files.

<GKeyFile> lets you parse, edit or create files containing groups of key-value pairs, which we call ‘key files’ for lack of a better name. Several freedesktop.org specifications use key files. For example, the Desktop Entry Specification and the Icon Theme Specification.

The syntax of key files is described in detail in the Desktop Entry Specification, here is a quick summary: Key files consists of groups of key-value pairs, interspersed with comments.

# this is just an example
# there can be comments before the first group

[First Group]

Name=Key File Example\tthis value shows\nescaping

# localized strings are stored in multiple key-value pairs
Welcome=Hello
Welcome[de]=Hallo
Welcome[fr_FR]=Bonjour
Welcome[it]=Ciao

[Another Group]

Numbers=2;20;-200;0

Booleans=true;false;true;true

Lines beginning with a # and blank lines are considered comments.

Groups are started by a header line containing the group name enclosed in [ and ], and ended implicitly by the start of the next group or the end of the file. Each key-value pair must be contained in a group.

Key-value pairs generally have the form key=value, with the exception of localized strings, which have the form key[locale]=value, with a locale identifier of the form lang_COUNTRY@MODIFIER where COUNTRY and MODIFIER are optional. As a special case, the locale C is associated with the untranslated pair key=value (since GLib 2.84). Space before and after the = character is ignored. Newline, tab, carriage return and backslash characters in value are escaped as \n, \t, \r, and \\\\, respectively. To preserve leading spaces in values, these can also be escaped as \s.

Key files can store strings (possibly with localized variants), integers, booleans and lists of these. Lists are separated by a separator character, typically ; or ,. To use the list separator character in a value in a list, it has to be escaped by prefixing it with a backslash.

This syntax is obviously inspired by the .ini files commonly met on Windows, but there are some important differences:

  • .ini files use the ; character to begin comments, key files use the # character.
  • Key files do not allow for ungrouped keys meaning only comments can precede the first group.
  • Key files are always encoded in UTF-8.
  • Key and Group names are case-sensitive. For example, a group called [GROUP] is a different from [group].
  • .ini files don’t have a strongly typed boolean entry type, they only have GetProfileInt(). In key files, only true and false (in lower case) are allowed.

Note that in contrast to the Desktop Entry Specification, groups in key files may contain the same key multiple times; the last entry wins. Key files may also contain multiple groups with the same name; they are merged together. Another difference is that keys and group names in key files are not restricted to ASCII characters.

Here is an example of loading a key file and reading a value:

g_autoptr(GError) error = NULL;
g_autoptr(GKeyFile) key_file = g_key_file_new ();

if (!g_key_file_load_from_file (key_file, "key-file.ini", flags, &error))
  {
    if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
      g_warning ("Error loading key file: %s", error->message);
    return;
  }

g_autofree gchar *val = g_key_file_get_string (key_file, "Group Name", "SomeKey", &error);
if (val == NULL &&
    !g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND))
  {
    g_warning ("Error finding key in key file: %s", error->message);
    return;
  }
else if (val == NULL)
  {
    // Fall back to a default value.
    val = g_strdup ("default-value");
  }

Here is an example of creating and saving a key file:

g_autoptr(GKeyFile) key_file = g_key_file_new ();
const gchar *val = …;
g_autoptr(GError) error = NULL;

g_key_file_set_string (key_file, "Group Name", "SomeKey", val);

// Save as a file.
if (!g_key_file_save_to_file (key_file, "key-file.ini", &error))
  {
    g_warning ("Error saving key file: %s", error->message);
    return;
  }

// Or store to a GBytes for use elsewhere.
gsize data_len;
g_autofree guint8 *data = (guint8 *) g_key_file_to_data (key_file, &data_len, &error);
if (data == NULL)
  {
    g_warning ("Error saving key file: %s", error->message);
    return;
  }
g_autoptr(GBytes) bytes = g_bytes_new_take (g_steal_pointer (&data), data_len);

Procedures

Procedure: key-file:error-quark ⇒ %return
%return

Returned: an unsigned 32-bit integer.

Method: key-file:get-boolean-list self group-name key ⇒ %return
Method: get-boolean-list self group-name key ⇒ %return

Returns the values associated with key under group-name as booleans.

If key cannot be found then GLib.KeyFileError.KEY_NOT_FOUND is returned. Likewise, if the values associated with key cannot be interpreted as booleans then GLib.KeyFileError.INVALID_VALUE is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: a vector, each a boolean.

the values associated with the key as a list of booleans, or NULL if the key was not found or could not be parsed. The returned list of booleans should be freed with byte-array:free when no longer needed.

length

Not returned: it is the length of %return.

the number of booleans returned

Method: key-file:get-boolean? self group-name key ⇒ %return
Method: get-boolean? self group-name key ⇒ %return

Returns the value associated with key under group-name as a boolean.

If key cannot be found then GLib.KeyFileError.KEY_NOT_FOUND is returned. Likewise, if the value associated with key cannot be interpreted as a boolean then GLib.KeyFileError.INVALID_VALUE is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: a boolean.

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

Method: key-file:get-comment self [group-name] [key] ⇒ %return
Method: get-comment self [group-name] [key] ⇒ %return

Retrieves a comment above key from group-name.

If key is NULL then comment will be read from above group-name. If both key and group-name are NULL, then comment will be read from above the first group in the file.

Note that the returned string does not include the # comment markers, but does include any whitespace after them (on each line). It includes the line breaks between lines, but does not include the final line break.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed, or left out: a string, or #f.

a group name, or NULL to get a top-level comment

key

Passed, or left out: a string, or #f.

a key, or NULL to get a group comment

%return

Returned: a string.

a comment that should be freed with byte-array:free

Method: key-file:get-double self group-name key ⇒ %return
Method: get-double self group-name key ⇒ %return

Returns the value associated with key under group-name as a double.

If key cannot be found then GLib.KeyFileError.KEY_NOT_FOUND is returned. Likewise, if the value associated with key cannot be interpreted as a double then GLib.KeyFileError.INVALID_VALUE is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: a real number.

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

Method: key-file:get-double-list self group-name key ⇒ %return
Method: get-double-list self group-name key ⇒ %return

Returns the values associated with key under group-name as doubles.

If key cannot be found then GLib.KeyFileError.KEY_NOT_FOUND is returned. Likewise, if the values associated with key cannot be interpreted as doubles then GLib.KeyFileError.INVALID_VALUE is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: a f64vector.

the values associated with the key as a list of doubles, or NULL if the key was not found or could not be parsed. The returned list of doubles should be freed with byte-array:free when no longer needed.

length

Not returned: it is the length of %return.

the number of doubles returned

Method: key-file:get-groups self ⇒ %return length
Method: get-groups self ⇒ %return length

Returns all groups in the key file loaded with self.

The array of returned groups will be NULL-terminated, so length may optionally be NULL.

self

Passed: a <GKeyFile>.

a key file

%return

Returned: a vector, each a string.

a newly-allocated NULL-terminated array of strings. Use strfreev to free it.

length

Returned: an unsigned 64-bit integer.

return location for the number of returned groups, or NULL to ignore

Method: key-file:get-int64 self group-name key ⇒ %return
Method: get-int64 self group-name key ⇒ %return

Returns the value associated with key under group-name as a signed 64-bit integer.

This is similar to key-file:get-integer but can return 64-bit results without truncation.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: a 64-bit integer.

the value associated with the key as a signed 64-bit integer, or 0 if the key was not found or could not be parsed.

Method: key-file:get-integer self group-name key ⇒ %return
Method: get-integer self group-name key ⇒ %return

Returns the value associated with key under group-name as an integer.

If key cannot be found then GLib.KeyFileError.KEY_NOT_FOUND is returned. Likewise, if the value associated with key cannot be interpreted as an integer, or is out of range for a gint, then GLib.KeyFileError.INVALID_VALUE is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: a 32-bit integer.

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

Method: key-file:get-integer-list self group-name key ⇒ %return
Method: get-integer-list self group-name key ⇒ %return

Returns the values associated with key under group-name as integers.

If key cannot be found then GLib.KeyFileError.KEY_NOT_FOUND is returned. Likewise, if the values associated with key cannot be interpreted as integers, or are out of range for gint, then GLib.KeyFileError.INVALID_VALUE is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: a s32vector.

the values associated with the key as a list of integers, or NULL if the key was not found or could not be parsed. The returned list of integers should be freed with byte-array:free when no longer needed.

length

Not returned: it is the length of %return.

the number of integers returned

Method: key-file:get-keys self group-name ⇒ %return length
Method: get-keys self group-name ⇒ %return length

Returns all keys for the group name group-name.

The array of returned keys will be NULL-terminated, so length may optionally be NULL. If the group-name cannot be found, GLib.KeyFileError.GROUP_NOT_FOUND is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

%return

Returned: a vector, each a string.

a newly-allocated NULL-terminated array of strings. Use strfreev to free it.

length

Returned: an unsigned 64-bit integer.

return location for the number of keys returned, or NULL to ignore

Method: key-file:get-locale-for-key self group-name key [locale] ⇒ %return
Method: get-locale-for-key self group-name key [locale] ⇒ %return

Returns the actual locale which the result of key-file:get-locale-string or key-file:get-locale-string-list came from.

If calling key-file:get-locale-string or key-file:get-locale-string-list with exactly the same self, group-name, key and locale, the result of those functions will have originally been tagged with the locale that is the result of this function.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

locale

Passed, or left out: a string, or #f.

a locale identifier or NULL to use the current locale

%return

Returned: a string, or #f.

the locale from the file, or NULL if the key was not found or the entry in the file was was untranslated

Method: key-file:get-locale-string self group-name key [locale] ⇒ %return
Method: get-locale-string self group-name key [locale] ⇒ %return

Returns the value associated with key under group-name translated in the given locale if available.

If locale is C then the untranslated value is returned (since GLib 2.84).

If locale is NULL then the current locale is assumed.

If locale is to be non-NULL, or if the current locale will change over the lifetime of the <GKeyFile>, it must be loaded with GLib.KeyFileFlags.KEEP_TRANSLATIONS in order to load strings for all locales.

If key cannot be found then GLib.KeyFileError.KEY_NOT_FOUND is returned. If the value associated with key cannot be interpreted or no suitable translation can be found then the untranslated value is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

locale

Passed, or left out: a string, or #f.

a locale identifier or NULL to use the current locale

%return

Returned: a string.

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

Method: key-file:get-locale-string-list self group-name key [locale] ⇒ %return
Method: get-locale-string-list self group-name key [locale] ⇒ %return

Returns the values associated with key under group-name translated in the given locale if available.

If locale is C then the untranslated value is returned (since GLib 2.84).

If locale is NULL then the current locale is assumed.

If locale is to be non-NULL, or if the current locale will change over the lifetime of the <GKeyFile>, it must be loaded with GLib.KeyFileFlags.KEEP_TRANSLATIONS in order to load strings for all locales.

If key cannot be found then GLib.KeyFileError.KEY_NOT_FOUND is returned. If the values associated with key cannot be interpreted or no suitable translations can be found then the untranslated values are returned. The returned array is NULL-terminated, so length may optionally be NULL.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

locale

Passed, or left out: a string, or #f.

a locale identifier or NULL to use the current locale

%return

Returned: a vector, each a string.

a newly allocated NULL-terminated string array or NULL if the key isn’t found. The string array should be freed with strfreev.

length

Not returned: it is the length of %return.

return location for the number of returned strings or NULL to ignore

Method: key-file:get-start-group self ⇒ %return
Method: get-start-group self ⇒ %return

Returns the name of the start group of the file.

self

Passed: a <GKeyFile>.

a key file

%return

Returned: a string, or #f.

The start group of the key file.

Method: key-file:get-string self group-name key ⇒ %return
Method: get-string self group-name key ⇒ %return

Returns the string value associated with key under group-name.

Unlike key-file:get-value, this function handles escape sequences like \s.

If the key cannot be found, GLib.KeyFileError.KEY_NOT_FOUND is returned. If the group-name cannot be found, GLib.KeyFileError.GROUP_NOT_FOUND is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: a string.

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

Method: key-file:get-string-list self group-name key ⇒ %return
Method: get-string-list self group-name key ⇒ %return

Returns the values associated with key under group-name.

If the key cannot be found, GLib.KeyFileError.KEY_NOT_FOUND is returned. If the group-name cannot be found, GLib.KeyFileError.GROUP_NOT_FOUND is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: a vector, each a string.

a NULL-terminated string array or NULL if the specified key cannot be found. The array should be freed with strfreev.

length

Not returned: it is the length of %return.

return location for the number of returned strings, or NULL to ignore

Method: key-file:get-uint64 self group-name key ⇒ %return
Method: get-uint64 self group-name key ⇒ %return

Returns the value associated with key under group-name as an unsigned 64-bit integer.

This is similar to key-file:get-integer but can return large positive results without truncation.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: an unsigned 64-bit integer.

the value associated with the key as an unsigned 64-bit integer, or 0 if the key was not found or could not be parsed.

Method: key-file:get-value self group-name key ⇒ %return
Method: get-value self group-name key ⇒ %return

Returns the raw value associated with key under group-name.

Use key-file:get-string to retrieve an unescaped UTF-8 string.

If the key cannot be found, GLib.KeyFileError.KEY_NOT_FOUND is returned. If the group-name cannot be found, GLib.KeyFileError.GROUP_NOT_FOUND is returned.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

%return

Returned: a string.

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

Method: key-file:has-group? self group-name ⇒ %return
Method: has-group? self group-name ⇒ %return

Looks whether the key file has the group group-name.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

%return

Returned: a boolean.

true if group-name is a part of self, false otherwise.

Method: key-file:load-from-bytes? self bytes flags ⇒ %return
Method: load-from-bytes? self bytes flags ⇒ %return

Loads a key file from the data in bytes into an empty <GKeyFile> structure.

If the object cannot be created then a <%GKeyFileError> is returned.

self

Passed: a <GKeyFile>.

an empty <GKeyFile> struct

bytes

Passed: a <GBytes>.

a <GBytes>

flags

Passed: a <%GKeyFileFlags>, or a list of its symbols, or one of them.

flags from <%GKeyFileFlags>

%return

Returned: a boolean.

true if a key file could be loaded, false otherwise

Method: key-file:load-from-data-dirs self file flags ⇒ %return full-path
Method: load-from-data-dirs self file flags ⇒ %return full-path

Looks for a key file named file in the paths returned from get-user-data-dir and get-system-data-dirs.

The search algorithm from key-file:load-from-dirs is used. If file is found, it’s loaded into self and its full path is returned in full-path.

If the file could not be loaded then either a <%GFileError> or <%GKeyFileError> is returned.

self

Passed: a <GKeyFile>.

an empty <GKeyFile> struct

file

Passed: a file name, as a string.

a relative path to a filename to open and parse

flags

Passed: a <%GKeyFileFlags>, or a list of its symbols, or one of them.

flags from <%GKeyFileFlags>

%return

Returned: a boolean.

true if a key file could be loaded, false otherwise

full-path

Returned: a file name, as a string.

return location for a string containing the full path of the file, or NULL to ignore

Method: key-file:load-from-data? self data length flags ⇒ %return
Method: load-from-data? self data length flags ⇒ %return

Loads a key file from memory into an empty <GKeyFile> structure.

If the object cannot be created then a [error@GLib.KeyFileError is returned.

self

Passed: a <GKeyFile>.

an empty key file

data

Passed: a string.

key file loaded in memory

length

Passed: an unsigned 64-bit integer.

the length of data in bytes (or (gsize)-1 if data is nul-terminated)

flags

Passed: a <%GKeyFileFlags>, or a list of its symbols, or one of them.

flags from <%GKeyFileFlags>

%return

Returned: a boolean.

true if a key file could be loaded, false otherwise

Method: key-file:load-from-dirs self file search-dirs flags ⇒ %return full-path
Method: load-from-dirs self file search-dirs flags ⇒ %return full-path

Looks for a key file named file in the paths specified in search-dirs, loads the file into self and returns the file’s full path in full-path.

search-dirs are checked in the order listed in the array, with the highest priority directory listed first. Within each directory, file is looked for. If it’s not found, - characters in file are progressively replaced with directory separators to search subdirectories of the search directory. If the file has not been found after all - characters have been replaced, the next search directory in search-dirs is checked.

If the file could not be found in any of the search-dirs, GLib.KeyFileError.NOT_FOUND is returned. If the file is found but the OS returns an error when opening or reading the file, a <%GFileError> is returned. If there is a problem parsing the file, a <%GKeyFileError> is returned.

self

Passed: a <GKeyFile>.

an empty <GKeyFile> struct

file

Passed: a file name, as a string.

a relative path to a filename to open and parse

search-dirs

Passed: a list or vector, each a file name, as a string.

NULL-terminated array of directories to search

flags

Passed: a <%GKeyFileFlags>, or a list of its symbols, or one of them.

flags from <%GKeyFileFlags>

%return

Returned: a boolean.

true if a key file could be loaded, false otherwise

full-path

Returned: a file name, as a string.

return location for a string containing the full path of the file, or NULL to ignore

Method: key-file:load-from-file? self file flags ⇒ %return
Method: load-from-file? self file flags ⇒ %return

Loads a key file into an empty <GKeyFile> structure.

If the OS returns an error when opening or reading the file, a <%GFileError> is returned. If there is a problem parsing the file, a <%GKeyFileError> is returned.

This function will never return a GLib.KeyFileError.NOT_FOUND error. If the file is not found, GLib.FileError.NOENT is returned.

self

Passed: a <GKeyFile>.

an empty key file

file

Passed: a file name, as a string.

the path of a filename to load, in the GLib filename encoding

flags

Passed: a <%GKeyFileFlags>, or a list of its symbols, or one of them.

flags from <%GKeyFileFlags>

%return

Returned: a boolean.

true if a key file could be loaded, false otherwise

Procedure: key-file:new ⇒ %return

Creates a new empty <GKeyFile> object.

Use key-file:load-from-file?, key-file:load-from-data?, key-file:load-from-dirs or key-file:load-from-data-dirs to read an existing key file.

%return

Returned: a <GKeyFile>.

an empty <GKeyFile>.

Method: key-file:remove-comment? self [group-name] [key] ⇒ %return
Method: remove-comment? self [group-name] [key] ⇒ %return

Removes a comment above key from group-name.

If key is NULL then comment will be removed above group-name. If both key and group-name are NULL, then comment will be removed above the first group in the file.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed, or left out: a string, or #f.

a group name, or NULL to get a top-level comment

key

Passed, or left out: a string, or #f.

a key, or NULL to get a group comment

%return

Returned: a boolean.

true if the comment was removed, false otherwise

Method: key-file:remove-group? self group-name ⇒ %return
Method: remove-group? self group-name ⇒ %return

Removes the specified group, group-name, from the key file.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

%return

Returned: a boolean.

true if the group was removed, false otherwise

Method: key-file:remove-key? self group-name key ⇒ %return
Method: remove-key? self group-name key ⇒ %return

Removes key in group-name from the key file.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key name to remove

%return

Returned: a boolean.

true if the key was removed, false otherwise

Method: key-file:save-to-file? self filename ⇒ %return
Method: save-to-file? self filename ⇒ %return

Writes the contents of self to filename using file-set-contents?.

If you need stricter guarantees about durability of the written file than are provided by file-set-contents?, use file-set-contents-full? with the return value of key-file:to-data.

This function can fail for any of the reasons that file-set-contents? may fail.

self

Passed: a <GKeyFile>.

a key file

filename

Passed: a string.

the name of the file to write to

%return

Returned: a boolean.

true if successful, false otherwise

Method: key-file:set-boolean self group-name key value
Method: set-boolean self group-name key value

Associates a new boolean value with key under group-name.

If key cannot be found then it is created.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

value

Passed: a boolean.

true or false

Method: key-file:set-boolean-list self group-name key list
Method: set-boolean-list self group-name key list

Associates a list of boolean values with key under group-name.

If key cannot be found then it is created.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

list

Passed: a list or vector, each a boolean.

an array of boolean values

length

Not passed: guile-gi gives the length of list.

length of list

Method: key-file:set-comment? self group-name key comment ⇒ %return
Method: set-comment? self group-name key comment ⇒ %return

Places a comment above key from group-name.

If key is NULL then comment will be written above group-name. If both key and group-name are NULL, then comment will be written above the first group in the file.

Passing a non-existent group-name or key to this function returns false and populates error. (In contrast, passing a non-existent group_name or key to key-file:set-string creates the associated group name and key.)

Note that this function prepends a # comment marker to each line of comment.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string, or #f.

a group name, or NULL to write a top-level comment

key

Passed: a string, or #f.

a key, or NULL to write a group comment

comment

Passed: a string.

a comment

%return

Returned: a boolean.

true if the comment was written, false otherwise

Method: key-file:set-double self group-name key value
Method: set-double self group-name key value

Associates a new double value with key under group-name.

If key cannot be found then it is created.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

value

Passed: a real number.

a double value

Method: key-file:set-double-list self group-name key list
Method: set-double-list self group-name key list

Associates a list of double values with key under group-name.

If key cannot be found then it is created.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

list

Passed: a f64vector, or a list or vector, each a real number.

an array of double values

length

Not passed: guile-gi gives the length of list.

number of double values in list

Method: key-file:set-int64 self group-name key value
Method: set-int64 self group-name key value

Associates a new integer value with key under group-name.

If key cannot be found then it is created.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

value

Passed: a 64-bit integer.

an integer value

Method: key-file:set-integer self group-name key value
Method: set-integer self group-name key value

Associates a new integer value with key under group-name.

If key cannot be found then it is created.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

value

Passed: a 32-bit integer.

an integer value

Method: key-file:set-integer-list self group-name key list
Method: set-integer-list self group-name key list

Associates a list of integer values with key under group-name.

If key cannot be found then it is created.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

list

Passed: a s32vector, or a list or vector, each a 32-bit integer.

an array of integer values

length

Not passed: guile-gi gives the length of list.

number of integer values in list

Method: key-file:set-list-separator self separator
Method: set-list-separator self separator

Sets the character which is used to separate values in lists.

Typically ; or , are used as separators. The default list separator is ;.

self

Passed: a <GKeyFile>.

a key file

separator

Passed: an 8-bit integer, or a character.

the separator

Method: key-file:set-locale-string self group-name key locale string
Method: set-locale-string self group-name key locale string

Associates a string value for key and locale under group-name.

If the translation for key cannot be found then it is created.

If locale is C then the untranslated value is set (since GLib 2.84).

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

locale

Passed: a string.

a locale identifier

string

Passed: a string.

a string

Method: key-file:set-locale-string-list self group-name key locale list
Method: set-locale-string-list self group-name key locale list

Associates a list of string values for key and locale under group-name.

If locale is C then the untranslated value is set (since GLib 2.84).

If the translation for key cannot be found then it is created.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

locale

Passed: a string.

a locale identifier

list

Passed: a list or vector, each a string.

a NULL-terminated array of locale string values

length

Not passed: guile-gi gives the length of list.

the length of list

Method: key-file:set-string self group-name key string
Method: set-string self group-name key 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. Unlike key-file:set-value, this function handles characters that need escaping, such as newlines.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

string

Passed: a string.

a string

Method: key-file:set-string-list self group-name key list
Method: set-string-list self group-name key list

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.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

list

Passed: a list or vector, each a string.

an array of string values

length

Not passed: guile-gi gives the length of list.

number of string values in list

Method: key-file:set-uint64 self group-name key value
Method: set-uint64 self group-name key value

Associates a new integer value with key under group-name.

If key cannot be found then it is created.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

value

Passed: an unsigned 64-bit integer.

an integer value

Method: key-file:set-value self group-name key value
Method: set-value self group-name key value

Associates a new 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. To set an UTF-8 string which may contain characters that need escaping (such as newlines or spaces), use key-file:set-string.

self

Passed: a <GKeyFile>.

a key file

group-name

Passed: a string.

a group name

key

Passed: a string.

a key

value

Passed: a string.

a string

Method: key-file:to-data self ⇒ %return length
Method: to-data self ⇒ %return length

Outputs self as a string.

Note that this function never reports an error.

self

Passed: a <GKeyFile>.

a key file

%return

Returned: a string.

a newly allocated string holding the contents of the key file

length

Returned: an unsigned 64-bit integer.

return location for the length of the returned string, or NULL to ignore

Method: key-file:unref self
Method: unref self

Decreases the reference count of self by 1.

If the reference count reaches zero, frees the key file and all its allocated memory.

self

Passed: a <GKeyFile>.

a key file