Search code examples
glibgio

Is there any way to append data to existing GVariant dictionary?


I use GSettings to store my application settings. Format of these is "a{q(bsyssbyqqqq)}", so it is Dictionary.

Sometimes I need to add new record to that dictionary. I can retrieve it from GSettings as GVariant. Is there any way to just add one record?

I have created new GVariantBuilder to create that new entry and it works OK but result of its operation is just one record. To add all remaining I need to iterate over all existing dictionary entries and add them to the builder. Is there any simplier and more efficient way to do that?


Solution

  • Probably too late, but just for the record, glib documentation (http://developer.gnome.org/glib/2.32/glib-GVariant.html) says:

    GVariant instances always have a type and a value (which are given at construction time). The type and value of a GVariant instance can never change other than by the GVariant itself being destroyed.

    Therefore it is not possible to change (add some record to your dictionary) GVariant. The only way to do what you want is exactly what you are doing now.