Well, mainly there should be one additional call which parses all files in different directories, merges all values in the defined order and gives one set of data back. Perhaps it is called:
gboolean g_key_file_load_from_conf_dirs (GKeyFile *key_file,
const gchar **conf_dirs,
GKeyFileFlags flags,
GError **error);
The rest of the interface in gkeyfile.h can be used as it is (e.g. g_key_file_get_string, g_key_file_get_boolean,…)
Adding API to GLib is somewhat complicated by the fact that the backward compatibility guarantees on API and ABI are kind of absolute, and that there aren’t many people actively working on the project. Unless there’s a pressing need, or multiple projects implementing the same thing, we do prefer that people open code their proposals first.
I am still fuzzy on what kind of problem you’re trying to solve; reaching out for an API is usually the last step in addressing an issue.
Loading a bunch of configuration files in a set of directories and merging them is not what I consider a “typical” use case—starting from the fact that the key file format was introduced for loading files in a “first location in a search path wins” scenario.
GLib already has support for priority order using g_key_file_load_from_dirs().
That could probably be extended to support masking with /dev/null without breaking API.
Supporting drop-ins would probably mean adding more API to allow apps to opt-in to it. Probably another variant of g_key_file_load_from_dirs() but with a flags variable.
Feel free to open an issue about it against GNOME / GLib · GitLab. We don’t have the development resources to implement this ourselves in the near future, so help with implementation would be appreciated.
Adding more API would be the plan. Perhaps adding a new variant of the call would be enough.
I could do this and have gotten permission from my manager to investigate time for it. I am only asking before I am starting if there is a general an interest from your side on that topic.
I would suggest that I am making a proposal for the API and if it is OK for you, I would start the implementation. My intention is to use already existing code as much as possible.
I have created an “issue” : https://gitlab.gnome.org/GNOME/glib/-/issues/3622