Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add left handed #44

Merged
merged 2 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions data/io.elementary.SettingsDaemon.AccountsService.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
<annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/>
</property>

<property name="LeftHanded" type="b" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="false"/>
</property>

</interface>
</node>
1 change: 1 addition & 0 deletions src/AccountsService.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public interface SettingsDaemon.AccountsService : Object {

public abstract KeyboardLayout[] keyboard_layouts { owned get; set; }
public abstract uint active_keyboard_layout { get; set; }
public abstract bool left_handed { get; set; }
}

[DBus (name = "io.elementary.pantheon.AccountsService")]
Expand Down
3 changes: 3 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class SettingsDaemon.Application : GLib.Application {

private Backends.KeyboardSettings keyboard_settings;

private Backends.MouseSettings mouse_settings;

private Backends.PrefersColorSchemeSettings prefers_color_scheme_settings;

private Backends.Housekeeping housekeeping;
Expand Down Expand Up @@ -91,6 +93,7 @@ public class SettingsDaemon.Application : GLib.Application {

if (accounts_service != null) {
keyboard_settings = new Backends.KeyboardSettings (accounts_service);
mouse_settings = new Backends.MouseSettings (accounts_service);
}

try {
Expand Down
53 changes: 53 additions & 0 deletions src/Backends/MouseSettings.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2021 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
* Authored by: Marius Meisenzahl <mariusmeisenzahl@gmail.com>
*/

public class SettingsDaemon.Backends.MouseSettings : GLib.Object {
public unowned AccountsService accounts_service { get; construct; }

private GLib.Settings mouse_settings;

public MouseSettings (AccountsService accounts_service) {
Object (accounts_service: accounts_service);
}

construct {
mouse_settings = new GLib.Settings ("org.gnome.desktop.peripherals.mouse");

if (accounts_service.left_handed != mouse_settings.get_boolean ("left-handed")) {
sync_accountsservice_to_gsettings ();
}

sync_gsettings_to_accountsservice ();

mouse_settings.changed.connect ((key) => {
if (key == "left-handed") {
sync_gsettings_to_accountsservice ();
}
});
}

private void sync_accountsservice_to_gsettings () {
mouse_settings.set_boolean ("left-handed", accounts_service.left_handed);
}

private void sync_gsettings_to_accountsservice () {
accounts_service.left_handed = mouse_settings.get_boolean ("left-handed");
}
}
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sources = files(
'SessionManager.vala',
'Backends/Housekeeping.vala',
'Backends/KeyboardSettings.vala',
'Backends/MouseSettings.vala',
'Backends/PrefersColorSchemeSettings.vala',
'Utils/SunriseSunsetCalculator.vala',
)
Expand Down