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

Behavior: add a11y settings #446

Merged
merged 7 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 4 additions & 2 deletions src/Plug.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public class Pantheon.Keyboard.Plug : Switchboard.Plug {
default_theme.add_resource_path ("/io/elementary/switchboard/keyboard");

stack = new Gtk.Stack ();
stack.margin = 12;
stack.add_titled (new Keyboard.LayoutPage.Page (), "layout", _("Layout"));
stack.add_titled (new Keyboard.InputMethodPage.Page (), "inputmethod", _("Input Method"));
stack.add_titled (new Keyboard.Shortcuts.Page (), "shortcuts", _("Shortcuts"));
Expand Down Expand Up @@ -116,8 +115,11 @@ public class Pantheon.Keyboard.Plug : Switchboard.Plug {
search_results.set ("%s → %s → %s".printf (display_name, _("Input Method"), _("Embed preedit text in application window")), "Input Method");
search_results.set ("%s → %s".printf (display_name, _("Shortcuts")), "Shortcuts");
search_results.set ("%s → %s".printf (display_name, _("Behavior")), "Behavior");
search_results.set ("%s → %s → %s".printf (display_name, _("Behavior"), _("Repeat Keys")), "Behavior");
search_results.set ("%s → %s → %s".printf (display_name, _("Behavior"), _("Bounce Keys")), "Behavior");
search_results.set ("%s → %s → %s".printf (display_name, _("Behavior"), _("Cursor Blinking")), "Behavior");
search_results.set ("%s → %s → %s".printf (display_name, _("Behavior"), _("Repeat Keys")), "Behavior");
search_results.set ("%s → %s → %s".printf (display_name, _("Behavior"), _("Slow Keys")), "Behavior");
search_results.set ("%s → %s → %s".printf (display_name, _("Behavior"), _("Sticky Keys")), "Behavior");
return search_results;
}
}
Expand Down
196 changes: 175 additions & 21 deletions src/Views/Behavior.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class Pantheon.Keyboard.Behaviour.Page : Gtk.Box {
};

var switch_repeat = new Gtk.Switch () {
halign = Gtk.Align.START,
valign = Gtk.Align.CENTER
halign = END,
valign = CENTER
};

var repeat_delay_adjustment = new Gtk.Adjustment (-1, 100, 900, 1, 0, 0);
Expand Down Expand Up @@ -68,8 +68,8 @@ public class Pantheon.Keyboard.Behaviour.Page : Gtk.Box {
};

var switch_blink = new Gtk.Switch () {
halign = Gtk.Align.START,
valign = Gtk.Align.CENTER
halign = END,
valign = CENTER
};

var blink_speed_adjustment = new Gtk.Adjustment (-1, 100, 2500, 10, 0, 0);
Expand All @@ -93,6 +93,130 @@ public class Pantheon.Keyboard.Behaviour.Page : Gtk.Box {

var spin_blink_time = new Gtk.SpinButton.with_range (1, 29, 1);

var stickykeys_header = new Granite.HeaderLabel (_("Sticky Keys"));

var stickykeys_switch = new Gtk.Switch () {
halign = END,
hexpand = true,
valign = CENTER
};

// FIXME: Replace with Granite.HeaderLabel secondary_text in Gtk4
var stickykeys_subtitle = new Gtk.Label (
_("Use ⌘, Alt, Ctrl, or Shift keys in sequence")
) {
wrap = true,
xalign = 0
};
stickykeys_subtitle .get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);

var stickykeys_grid = new Gtk.Grid () {
column_spacing = 12
};
stickykeys_grid.attach (stickykeys_header, 0, 0);
stickykeys_grid.attach (stickykeys_subtitle, 0, 1);
stickykeys_grid.attach (stickykeys_switch, 1, 0, 1, 2);

var slowkeys_header = new Granite.HeaderLabel (_("Slow Keys"));

var slowkeys_switch = new Gtk.Switch () {
halign = END,
hexpand = true,
valign = CENTER
};

// FIXME: Replace with Granite.HeaderLabel secondary_text in Gtk4
var slowkeys_subtitle = new Gtk.Label (
_("Don't accept keypresses unless held")
) {
wrap = true,
xalign = 0
};
slowkeys_subtitle .get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);

var slowkeys_adjustment = new Gtk.Adjustment (0, 0, 1000, 1, 1, 1);

var slowkeys_scale = new Gtk.Scale (HORIZONTAL, slowkeys_adjustment) {
draw_value = false,
margin_top = 6
};
slowkeys_scale.add_mark (300, Gtk.PositionType.BOTTOM, null);

var slowkeys_grid = new Gtk.Grid () {
column_spacing = 12
};
slowkeys_grid.attach (slowkeys_header, 0, 0);
slowkeys_grid.attach (slowkeys_subtitle, 0, 1);
slowkeys_grid.attach (slowkeys_switch, 1, 0, 1, 2);
slowkeys_grid.attach (slowkeys_scale, 0, 2, 2);

var bouncekeys_header = new Granite.HeaderLabel (_("Bounce Keys"));

var bouncekeys_switch = new Gtk.Switch () {
halign = END,
hexpand = true,
valign = CENTER
};

// FIXME: Replace with Granite.HeaderLabel secondary_text in Gtk4
var bouncekeys_subtitle = new Gtk.Label (
_("Ignore fast duplicate keypresses ")
) {
wrap = true,
xalign = 0
};
bouncekeys_subtitle .get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);

var bouncekeys_adjustment = new Gtk.Adjustment (0, 0, 1000, 1, 1, 1);

var bouncekeys_scale = new Gtk.Scale (HORIZONTAL, bouncekeys_adjustment) {
draw_value = false,
margin_top = 6
};
bouncekeys_scale.add_mark (300, Gtk.PositionType.BOTTOM, null);

var bouncekeys_grid = new Gtk.Grid () {
column_spacing = 12
};
bouncekeys_grid.attach (bouncekeys_header, 0, 0);
bouncekeys_grid.attach (bouncekeys_subtitle, 0, 1);
bouncekeys_grid.attach (bouncekeys_switch, 1, 0, 1, 2);
bouncekeys_grid.attach (bouncekeys_scale, 0, 2, 2);

var events_header = new Granite.HeaderLabel (_("Event Alerts"));

// FIXME: Replace with Granite.HeaderLabel secondary_text in Gtk4
var events_subtitle = new Gtk.Label (
_("Play a sound or flash the screen. %s").printf (
"<a href='settings:///sound/output'>%s</a>".printf (
_("Sound Settings…")
)
)
) {
use_markup = true,
wrap = true,
xalign = 0
};
events_subtitle.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);

var togglekeys_check = new Gtk.CheckButton.with_label (_("Caps Lock ⇪ or Num Lock keys are pressed"));
var bouncekeys_check = new Gtk.CheckButton.with_label (_("Bounce Keys are rejected"));
var stickykeys_check = new Gtk.CheckButton.with_label (_("Sticky Keys are pressed"));
var slowkeys_check = new Gtk.CheckButton.with_label (_("Slow Keys are rejected"));

var events_checks_box = new Gtk.Box (VERTICAL, 6) {
margin_top = 12
};
events_checks_box.add (togglekeys_check);
events_checks_box.add (stickykeys_check);
events_checks_box.add (bouncekeys_check);
events_checks_box.add (slowkeys_check);

var events_box = new Gtk.Box (VERTICAL, 0);
events_box.add (events_header);
events_box.add (events_subtitle);
events_box.add (events_checks_box);

var entry_test = new Gtk.Entry () {
hexpand = true,
placeholder_text = _("Type to test your settings")
Expand All @@ -102,8 +226,8 @@ public class Pantheon.Keyboard.Behaviour.Page : Gtk.Box {
column_spacing = 12,
row_spacing = 6
};
repeat_grid.attach (label_repeat, 0, 0);
repeat_grid.attach (switch_repeat, 1, 0);
repeat_grid.attach (label_repeat, 0, 0, 3);
repeat_grid.attach (switch_repeat, 3, 0);
repeat_grid.attach (label_repeat_delay, 0, 1);
repeat_grid.attach (scale_repeat_delay, 1, 1);
repeat_grid.attach (spin_repeat_delay, 2, 1);
Expand All @@ -117,27 +241,38 @@ public class Pantheon.Keyboard.Behaviour.Page : Gtk.Box {
column_spacing = 12,
row_spacing = 6
};
blink_grid.attach (label_blink, 0, 3);
blink_grid.attach (switch_blink, 1, 3);
blink_grid.attach (label_blink_speed, 0, 4);
blink_grid.attach (scale_blink_speed, 1, 4);
blink_grid.attach (spin_blink_speed, 2, 4);
blink_grid.attach (label_blink_ms, 3, 4);
blink_grid.attach (label_blink_time, 0, 5);
blink_grid.attach (scale_blink_time, 1, 5);
blink_grid.attach (spin_blink_time, 2, 5);
blink_grid.attach (label_blink_s, 3, 5);

var box = new Gtk.Box (VERTICAL, 24);
box.add (repeat_grid);
blink_grid.attach (label_blink, 0, 0, 3);
blink_grid.attach (switch_blink, 3, 0);
blink_grid.attach (label_blink_speed, 0, 1);
blink_grid.attach (scale_blink_speed, 1, 1);
blink_grid.attach (spin_blink_speed, 2, 1);
blink_grid.attach (label_blink_ms, 3, 1);
blink_grid.attach (label_blink_time, 0, 2);
blink_grid.attach (scale_blink_time, 1, 2);
blink_grid.attach (spin_blink_time, 2, 2);
blink_grid.attach (label_blink_s, 3, 2);

var box = new Gtk.Box (VERTICAL, 18);
box.add (blink_grid);
box.add (repeat_grid);
box.add (stickykeys_grid);
box.add (bouncekeys_grid);
box.add (slowkeys_grid);
box.add (events_box);
box.add (entry_test);

var clamp = new Hdy.Clamp () {
child = box
child = box,
margin_start = 12,
margin_end = 12,
margin_bottom = 12
};

add (clamp);
var scrolled = new Gtk.ScrolledWindow (null, null) {
child = clamp
};

add (scrolled);

var gsettings_blink = new Settings ("org.gnome.desktop.interface");
gsettings_blink.bind ("cursor-blink", switch_blink, "active", SettingsBindFlags.DEFAULT);
Expand Down Expand Up @@ -167,6 +302,25 @@ public class Pantheon.Keyboard.Behaviour.Page : Gtk.Box {
switch_repeat.bind_property ("active", spin_repeat_delay, "sensitive", BindingFlags.DEFAULT);
switch_repeat.bind_property ("active", spin_repeat_speed, "sensitive", BindingFlags.DEFAULT);

var a11y_settings = new Settings ("org.gnome.desktop.a11y.keyboard");
a11y_settings.bind ("bouncekeys-enable", bouncekeys_switch, "active", DEFAULT);
a11y_settings.bind ("bouncekeys-enable", bouncekeys_check, "sensitive", GET);
a11y_settings.bind ("bouncekeys-enable", bouncekeys_scale, "sensitive", GET);
a11y_settings.bind ("bouncekeys-beep-reject", bouncekeys_check, "active", DEFAULT);
a11y_settings.bind ("bouncekeys-delay", bouncekeys_adjustment, "value", DEFAULT);

a11y_settings.bind ("slowkeys-enable", slowkeys_switch, "active", DEFAULT);
a11y_settings.bind ("slowkeys-enable", slowkeys_check, "sensitive", GET);
a11y_settings.bind ("slowkeys-enable", slowkeys_scale, "sensitive", GET);
a11y_settings.bind ("slowkeys-beep-reject", slowkeys_check, "active", DEFAULT);
a11y_settings.bind ("slowkeys-delay", slowkeys_adjustment, "value", DEFAULT);

a11y_settings.bind ("stickykeys-enable", stickykeys_switch, "active", DEFAULT);
a11y_settings.bind ("stickykeys-enable", stickykeys_check, "sensitive", GET);
a11y_settings.bind ("stickykeys-modifier-beep", stickykeys_check, "active", DEFAULT);

a11y_settings.bind ("togglekeys-enable", togglekeys_check, "active", DEFAULT);

scale_repeat_delay.grab_focus (); /* We want entry unfocussed so that placeholder shows */
}
}
3 changes: 3 additions & 0 deletions src/Views/InputMethod.vala
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ public class Pantheon.Keyboard.InputMethodPage.Page : Gtk.Grid {
stack.add_named (main_grid, "main_view");
stack.show_all ();

margin_start = 12;
margin_end = 12;
margin_bottom = 12;
add (stack);

set_visible_view ();
Expand Down
3 changes: 3 additions & 0 deletions src/Views/Layout.vala
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ namespace Pantheon.Keyboard {
column_homogeneous = true;
column_spacing = 12;
row_spacing = 12;
margin_start = 12;
margin_end = 12;
margin_bottom = 12;
attach (display, 0, 0, 1, 12);
attach (switch_layout_label, 1, 0, 1, 1);
attach (switch_layout_combo, 2, 0, 1, 1);
Expand Down
3 changes: 3 additions & 0 deletions src/Views/Shortcuts.vala
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ namespace Pantheon.Keyboard.Shortcuts {

column_spacing = 12;
column_homogeneous = true;
margin_start = 12;
margin_end = 12;
margin_bottom = 12;
attach (switcher_frame, 0, 0);
attach (frame, 1, 0, 2, 1);

Expand Down