The GSettings Vala docs are not very detailed and I can't find a way to read an item from an array of dictionaries stored in GSettings. Right now I have this in my schema:
<key type="aa{ss}" name="services">
<default>[{"id": "postgresql", "name": "PostgreSQL"}]</default>
<summary></summary>
<description></description>
</key>
How can I read the values for the keys id
and name
of the first value of the services
array?
I tried a lot of possibilities (using get_value("services")
then get_child(0)
, for example) to read the dictionary but it simply breaks and I don't know how to debug it.
I discovered the problem was that somehow my settings instance wasn't being initialized correctly when created inside a
static construct
block. Moving the creation of that to a memoized method solved the problem.