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 746724 - Implement g_settings_bind_with_mapping and handle range/flag __setitem__
Implement g_settings_bind_with_mapping and handle range/flag __setitem__
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
Git master
Other Linux
: Normal enhancement
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2015-03-25 03:43 UTC by dalcde
Modified: 2018-01-10 20:49 UTC
See Also:
GNOME target: ---
GNOME version: 3.15/3.16


Attachments
fix patch (4.66 KB, patch)
2015-03-25 03:43 UTC, dalcde
none Details | Review
Update to previous patch (5.01 KB, patch)
2015-03-30 03:14 UTC, dalcde
none Details | Review

Description dalcde 2015-03-25 03:43:56 UTC
Created attachment 300247 [details] [review]
fix patch

g_settings_bind is a function that binds an object property with a settings key. This is available in the python binding.

g_settings_bind_with_mapping allows users to assign a mapping that converts the settings value to the desired widget value and vice versa, eg. when the widget value should be twice the settings value. This is not available in the python binding (possibly due to the difficulty in introspecting functions). This patch implements this function in the gi overrides.

Implementing this requires properly implementing the __setitem__ override. The __setitem__ override allows users to access schema values through

    settings = Gio.Settings.new(schema)
    value = settings[key]

However, this is only implemented for key types "type" and "enum". Attempting to use it for the other types "range" and "flags" will raise a NotImplementedError. So this patch implements this functionality for all possible key types.

For reference, support for "enum" was implemented here: https://bugzilla.gnome.org/show_bug.cgi?id=685947
Comment 1 dalcde 2015-03-30 03:14:51 UTC
Created attachment 300560 [details] [review]
Update to previous patch

Don't re-implement range checking as GSettings already does that (and nicely returns a False instead of abruptly crashing when the value is out of range)
Comment 2 GNOME Infrastructure Team 2018-01-10 20:49:22 UTC
-- 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/pygobject/issues/98.