After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 625833 - RFE: provide a G_SETTINGS_BIND_INVERTED flag for booleans
RFE: provide a G_SETTINGS_BIND_INVERTED flag for booleans
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gsettings
2.25.x
Other Linux
: Normal normal
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-08-02 14:25 UTC by Diego Escalante Urrelo (not reading bugmail)
Modified: 2010-08-03 06:09 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Diego Escalante Urrelo (not reading bugmail) 2010-08-02 14:25:04 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.
Comment 1 Allison Karlitskaya (desrt) 2010-08-02 14:28:49 UTC
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
Comment 2 Allison Karlitskaya (desrt) 2010-08-02 14:33:32 UTC
btw: since you provide non-NULL callbacks, bind_with_mapping() won't duplicate the effort of checking the key and property types for compatibility.
Comment 3 Allison Karlitskaya (desrt) 2010-08-03 06:09:49 UTC
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