elementary / switchboard-plug-mouse-touchpad

Switchboard Mouse & Touchpad Plug
GNU General Public License v3.0
24 stars 13 forks source link

Clicking: Fix issue with LTR primary button selection #112

Closed danirabbit closed 4 years ago

danirabbit commented 4 years ago

Fixes: #113

0 and 1 don't seem to bind to true/false

tintou commented 4 years ago

It'd be even better to just use: GLib.Settings.bind_with_mapping Something like this would just work:

mouse_settings.bind_with_mapping (
    "left-handed",
    primary_button_switcher,
    "selected",
    GLib.SettingsBindFlags.DEFAULT,
    (value, variant) => {
        GLib.return_val_if_fail (variant.is_of_type (GLib.VariantType.BOOLEAN), false);
        value.set_int (variant.get_boolean () ? 1 : 0);
        return true;
    },
    (value, expected_type) => {
        GLib.return_val_if_fail (expected_type.equal (GLib.VariantType.BOOLEAN), null);
        return new GLib.Variant.boolean (value.get_int () == 1);
    },
    null, null
);