GNOME Bugzilla – Bug 532904
missing methods in Glib::KeyFile
Last modified: 2008-05-16 16:21:24 UTC
Hi, I was playing with Glib::KeyFile and I observed there are no methods to create (add) a new Group or a new Key to an existing group. I think it would be useful to have such methods: - add_group(Glib::ustring group_name) - to create a new group - add_group(Glib::ustring group_name, Glib::ustring before_group) - to create a new group before group named 'before_group' .... - add_key(Glib::ustring group_name, Glib::ustring key_name, Glib::ustring key_value) etc., similar for keys
> add_group(Glib::ustring group_name) Presumably groups are added automatically when specified to set*() methods. > add_group(Glib::ustring group_name, Glib::ustrsing before_group) I don't believe that anything else in the GKeyFile API makes any use of the sequence of groups or keys. How would this be useful?
>> add_group(Glib::ustring group_name) > Presumably groups are added automatically when specified to set*() methods. You are right, using set methods groups are automatically added if they don't exist. But, I believe a set*() method is not as intuitive as an add*() method to create a new group or a new key. >> add_group(Glib::ustring group_name, Glib::ustrsing before_group) >I don't believe that anything else in the GKeyFile API makes any use of the >sequence of groups or keys. How would this be useful? It is only an example. I don't know the GKeyFile API. First, I thought there are no methods to add new groups or keys because I didn't see any method named "add" or "create". You solved my problem and for that I thank you! And so, I don't know if this bug should remain valid, on the other hand, it would be an enhancement for Glib::KeyFile to have such intuitive methods. Thanks again!
Personally, I don't think it would make the API clearer. It would be an unnecessary extra step. However, we should make sure that the documenation says that groups and keys are added automatically.
I checked. It's already documented: http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1KeyFile.html#38bf60f9bdd209d28ae818e7dee6ea17 If you are still convinced that group creation should not be automatic then please file a bug in GTK+. I don't think they would want that though.