GNOME Bugzilla – Bug 350000
Missing setter for GKeyFileFlags for GKeyFile
Last modified: 2018-05-24 10:51:07 UTC
The API lacks a setter function for the GKeyFileFlags of a newly created GKeyFile. If you generate a new GKeyFile you can add values and comments just fine, but the comments won't get written out by g_key_file_to_data (), since G_KEY_FILE_KEEP_COMMENTS is not set. It cannot be set without sideeffects with the current API. My workaround is kfile = g_key_file_new (); g_key_file_load_from_data (kfile, "\n", 1, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL); [set the values and invoke _to_data()] but this has the side effect that the newline gets written to the output file as well - it is also not possible to load 0 bytes from data to avoid that. A g_key_file_[gs]et_flags () would not hurt.
Good catch.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/60.