GNOME Bugzilla – Bug 625833
RFE: provide a G_SETTINGS_BIND_INVERTED flag for booleans
Last modified: 2010-08-03 06:09:49 UTC
You could have "edit-disabled" and a button in the UI that says "Enable edit", you would like to have the button sensitive=TRUE when edit-disabled=FALSE.
call it G_SETTINGS_BIND_INVERT_BOOLEAN i guess, to make it more clear doc that the flag can only be passed to g_settings_bind -- not bind_with_mapping. add an assert to bind_with_mapping to enforce that. do all the work in g_settings_bind itself: - check that the key and property are, in fact, boolean - write a pair of callbacks to do the invert - if the flag is set, clear it (to miss the assertion) and use your callbacks instead of NULL
btw: since you provide non-NULL callbacks, bind_with_mapping() won't duplicate the effort of checking the key and property types for compatibility.
commit ca3b7b75bff00ea05c967eea06e2c3397da17e41 Author: Ryan Lortie <desrt@desrt.ca> Date: Tue Aug 3 02:08:03 2010 -0400 GSettings: add G_SETTINGS_BIND_INVERT_BOOLEAN flag When binding a boolean setting to a boolean property, invert the values. This avoids the requirement for writing a pair of mapping functions for this extremely common case. Add a test. https://bugzilla.gnome.org/show_bug.cgi?id=625833