diff options
author | Colomban Wendling <[email protected]> | 2020-06-10 18:54:37 +0200 |
---|---|---|
committer | Robert Antoni Buj Gelonch <[email protected]> | 2020-08-08 23:24:58 +0200 |
commit | 24a04f3b71f18e37b655a5e717540a3dc3bef598 (patch) | |
tree | ef19fe4e2ef56947410c4fe9c19a490ddbfc03f6 /plugins/a11y-keyboard/msd-a11y-preferences-dialog.c | |
parent | 372c9903f7c8518eae842077bb7006f75fc27dfe (diff) | |
download | mate-settings-daemon-24a04f3b71f18e37b655a5e717540a3dc3bef598.tar.bz2 mate-settings-daemon-24a04f3b71f18e37b655a5e717540a3dc3bef598.tar.xz |
a11y-keyboard: Add support for ringing the bell when CapsLock is active
Diffstat (limited to 'plugins/a11y-keyboard/msd-a11y-preferences-dialog.c')
-rw-r--r-- | plugins/a11y-keyboard/msd-a11y-preferences-dialog.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c b/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c index fa6d426..69cf418 100644 --- a/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c +++ b/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c @@ -49,6 +49,7 @@ #define KEY_BOUNCE_KEYS_ENABLED "bouncekeys-enable" #define KEY_SLOW_KEYS_ENABLED "slowkeys-enable" #define KEY_MOUSE_KEYS_ENABLED "mousekeys-enable" +#define KEY_CAPSLOCK_BEEP_ENABLED "capslock-beep-enable" #define KEY_AT_SCHEMA "org.mate.applications-at" #define KEY_AT_SCREEN_KEYBOARD_ENABLED "screen-keyboard-enabled" @@ -91,6 +92,7 @@ struct MsdA11yPreferencesDialogPrivate GtkWidget *sticky_keys_checkbutton; GtkWidget *slow_keys_checkbutton; GtkWidget *bounce_keys_checkbutton; + GtkWidget *capslock_beep_checkbutton; GtkWidget *large_print_checkbutton; GtkWidget *high_contrast_checkbutton; @@ -323,6 +325,18 @@ config_set_slow_keys (MsdA11yPreferencesDialog *dialog, gboolean enabled) } static gboolean +config_get_capslock_beep (MsdA11yPreferencesDialog *dialog, gboolean *is_writable) +{ + return config_get_bool (dialog->priv->settings_a11y, KEY_CAPSLOCK_BEEP_ENABLED, is_writable); +} + +static void +config_set_capslock_beep (MsdA11yPreferencesDialog *dialog, gboolean enabled) +{ + g_settings_set_boolean (dialog->priv->settings_a11y, KEY_CAPSLOCK_BEEP_ENABLED, enabled); +} + +static gboolean config_have_at_gsettings_condition (const char *condition) { DBusGProxy *sm_proxy; @@ -422,6 +436,13 @@ on_slow_keys_checkbutton_toggled (GtkToggleButton *button, } static void +on_capslock_beep_checkbutton_toggled (GtkToggleButton *button, + MsdA11yPreferencesDialog *dialog) +{ + config_set_capslock_beep (dialog, gtk_toggle_button_get_active (button)); +} + +static void on_high_contrast_checkbutton_toggled (GtkToggleButton *button, MsdA11yPreferencesDialog *dialog) { @@ -493,6 +514,18 @@ ui_set_slow_keys (MsdA11yPreferencesDialog *dialog, } static void +ui_set_capslock_beep (MsdA11yPreferencesDialog *dialog, + gboolean enabled) +{ + gboolean active; + + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->capslock_beep_checkbutton)); + if (active != enabled) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->capslock_beep_checkbutton), enabled); + } +} + +static void ui_set_high_contrast (MsdA11yPreferencesDialog *dialog, gboolean enabled) { @@ -569,6 +602,10 @@ key_changed_cb (GSettings *settings, gboolean enabled; enabled = g_settings_get_boolean (settings, key); ui_set_slow_keys (dialog, enabled); + } else if (g_strcmp0 (key, KEY_CAPSLOCK_BEEP_ENABLED) == 0) { + gboolean enabled; + enabled = g_settings_get_boolean (settings, key); + ui_set_capslock_beep (dialog, enabled); } else if (g_strcmp0 (key, KEY_AT_SCREEN_READER_ENABLED) == 0) { gboolean enabled; enabled = g_settings_get_boolean (settings, key); @@ -634,6 +671,19 @@ setup_dialog (MsdA11yPreferencesDialog *dialog, } widget = GTK_WIDGET (gtk_builder_get_object (builder, + "capslock_beep_checkbutton")); + dialog->priv->capslock_beep_checkbutton = widget; + g_signal_connect (widget, + "toggled", + G_CALLBACK (on_capslock_beep_checkbutton_toggled), + dialog); + enabled = config_get_capslock_beep (dialog, &is_writable); + ui_set_capslock_beep (dialog, enabled); + if (! is_writable) { + gtk_widget_set_sensitive (widget, FALSE); + } + + widget = GTK_WIDGET (gtk_builder_get_object (builder, "high_contrast_checkbutton")); dialog->priv->high_contrast_checkbutton = widget; g_signal_connect (widget, |