From 0af1937d4d6ef2fac4bc50c21a250e140836b738 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Thu, 30 Dec 2021 20:09:17 -0800 Subject: [PATCH] universal-access: Inline Sound Keys dialog This can also be replaced with a simple switch in an AdwActionRow. --- .../universal-access/cc-sound-keys-dialog.c | 76 ------------------- .../universal-access/cc-sound-keys-dialog.h | 29 ------- .../universal-access/cc-sound-keys-dialog.ui | 53 ------------- panels/universal-access/cc-ua-panel.c | 22 ++---- panels/universal-access/cc-ua-panel.ui | 27 ++++--- panels/universal-access/meson.build | 2 - .../universal-access.gresource.xml | 1 - po/POTFILES.in | 1 - 8 files changed, 20 insertions(+), 191 deletions(-) delete mode 100644 panels/universal-access/cc-sound-keys-dialog.c delete mode 100644 panels/universal-access/cc-sound-keys-dialog.h delete mode 100644 panels/universal-access/cc-sound-keys-dialog.ui diff --git a/panels/universal-access/cc-sound-keys-dialog.c b/panels/universal-access/cc-sound-keys-dialog.c deleted file mode 100644 index 4cbf5835c..000000000 --- a/panels/universal-access/cc-sound-keys-dialog.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2020 Canonical Ltd. - * - * 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 2.1 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 Lesser 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 - */ - -#include "cc-sound-keys-dialog.h" - -#define KEYBOARD_SETTINGS "org.gnome.desktop.a11y.keyboard" -#define KEY_TOGGLEKEYS_ENABLED "togglekeys-enable" - -struct _CcSoundKeysDialog -{ - GtkDialog parent; - - GtkSwitch *enable_switch; - - GSettings *keyboard_settings; -}; - -G_DEFINE_TYPE (CcSoundKeysDialog, cc_sound_keys_dialog, GTK_TYPE_DIALOG); - -static void -cc_sound_keys_dialog_dispose (GObject *object) -{ - CcSoundKeysDialog *self = CC_SOUND_KEYS_DIALOG (object); - - g_clear_object (&self->keyboard_settings); - - G_OBJECT_CLASS (cc_sound_keys_dialog_parent_class)->dispose (object); -} - -static void -cc_sound_keys_dialog_class_init (CcSoundKeysDialogClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->dispose = cc_sound_keys_dialog_dispose; - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/universal-access/cc-sound-keys-dialog.ui"); - - gtk_widget_class_bind_template_child (widget_class, CcSoundKeysDialog, enable_switch); -} - -static void -cc_sound_keys_dialog_init (CcSoundKeysDialog *self) -{ - gtk_widget_init_template (GTK_WIDGET (self)); - - self->keyboard_settings = g_settings_new (KEYBOARD_SETTINGS); - - g_settings_bind (self->keyboard_settings, KEY_TOGGLEKEYS_ENABLED, - self->enable_switch, "active", - G_SETTINGS_BIND_DEFAULT); -} - -CcSoundKeysDialog * -cc_sound_keys_dialog_new (void) -{ - return g_object_new (cc_sound_keys_dialog_get_type (), - "use-header-bar", TRUE, - NULL); -} diff --git a/panels/universal-access/cc-sound-keys-dialog.h b/panels/universal-access/cc-sound-keys-dialog.h deleted file mode 100644 index 4a3297753..000000000 --- a/panels/universal-access/cc-sound-keys-dialog.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2020 Canonical Ltd. - * - * 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 2.1 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 Lesser 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 - */ - -#pragma once - -#include - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE (CcSoundKeysDialog, cc_sound_keys_dialog, CC, SOUND_KEYS_DIALOG, GtkDialog) - -CcSoundKeysDialog *cc_sound_keys_dialog_new (void); - -G_END_DECLS diff --git a/panels/universal-access/cc-sound-keys-dialog.ui b/panels/universal-access/cc-sound-keys-dialog.ui deleted file mode 100644 index 9aee82a7e..000000000 --- a/panels/universal-access/cc-sound-keys-dialog.ui +++ /dev/null @@ -1,53 +0,0 @@ - - - - - diff --git a/panels/universal-access/cc-ua-panel.c b/panels/universal-access/cc-ua-panel.c index 8a6f41d20..e052bb171 100644 --- a/panels/universal-access/cc-ua-panel.c +++ b/panels/universal-access/cc-ua-panel.c @@ -33,7 +33,6 @@ #include "cc-cursor-size-dialog.h" #include "cc-pointing-dialog.h" #include "cc-repeat-keys-dialog.h" -#include "cc-sound-keys-dialog.h" #include "cc-typing-dialog.h" #include "cc-visual-alerts-dialog.h" #include "cc-zoom-options-dialog.h" @@ -127,7 +126,7 @@ struct _CcUaPanel GtkSwitch *screen_reader_switch; AdwActionRow *screen_reader_row; GtkSwitch *show_status_switch; - GtkLabel *sound_keys_label; + GtkSwitch *sound_keys_switch; AdwActionRow *sound_keys_row; GtkLabel *visual_alerts_label; AdwActionRow *visual_alerts_row; @@ -167,10 +166,6 @@ activate_row (CcUaPanel *self, AdwActionRow *row) { run_dialog (self, GTK_DIALOG (cc_cursor_size_dialog_new ())); } - else if (row == self->sound_keys_row) - { - run_dialog (self, GTK_DIALOG (cc_sound_keys_dialog_new ())); - } else if (row == self->visual_alerts_row) { run_dialog (self, GTK_DIALOG (cc_visual_alerts_dialog_new ())); @@ -250,7 +245,7 @@ cc_ua_panel_class_init (CcUaPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcUaPanel, screen_reader_switch); gtk_widget_class_bind_template_child (widget_class, CcUaPanel, screen_reader_row); gtk_widget_class_bind_template_child (widget_class, CcUaPanel, show_status_switch); - gtk_widget_class_bind_template_child (widget_class, CcUaPanel, sound_keys_label); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, sound_keys_switch); gtk_widget_class_bind_template_child (widget_class, CcUaPanel, sound_keys_row); gtk_widget_class_bind_template_child (widget_class, CcUaPanel, visual_alerts_label); gtk_widget_class_bind_template_child (widget_class, CcUaPanel, visual_alerts_row); @@ -428,6 +423,11 @@ cc_ua_panel_init_seeing (CcUaPanel *self) self->screen_reader_switch, "active", G_SETTINGS_BIND_DEFAULT); + /* sound keys */ + + g_settings_bind (self->kb_settings, KEY_TOGGLEKEYS_ENABLED, + self->sound_keys_switch, "active", + G_SETTINGS_BIND_DEFAULT); /* cursor size */ @@ -444,14 +444,6 @@ cc_ua_panel_init_seeing (CcUaPanel *self) "label", G_SETTINGS_BIND_GET, on_off_label_mapping_get, NULL, NULL, NULL); - - /* sound keys */ - - g_settings_bind_with_mapping (self->kb_settings, KEY_TOGGLEKEYS_ENABLED, - self->sound_keys_label, "label", - G_SETTINGS_BIND_GET, - on_off_label_mapping_get, - NULL, NULL, NULL); } /* hearing/sound section */ diff --git a/panels/universal-access/cc-ua-panel.ui b/panels/universal-access/cc-ua-panel.ui index a187656c4..f64203d26 100644 --- a/panels/universal-access/cc-ua-panel.ui +++ b/panels/universal-access/cc-ua-panel.ui @@ -81,6 +81,19 @@ + + + _Sound Keys + Beep when Num Lock or Caps Lock are turned on or off. + True + sound_keys_switch + + + center + + + + C_ursor Size @@ -109,20 +122,6 @@ - - - _Sound Keys - True - True - - - - center - 1 - - - - diff --git a/panels/universal-access/meson.build b/panels/universal-access/meson.build index 7b4ce506a..17015c08b 100644 --- a/panels/universal-access/meson.build +++ b/panels/universal-access/meson.build @@ -22,7 +22,6 @@ sources = files( 'cc-cursor-size-dialog.c', 'cc-pointing-dialog.c', 'cc-repeat-keys-dialog.c', - 'cc-sound-keys-dialog.c', 'cc-typing-dialog.c', 'cc-ua-panel.c', 'cc-visual-alerts-dialog.c', @@ -40,7 +39,6 @@ resource_data = files( 'cc-cursor-size-dialog.ui', 'cc-pointing-dialog.ui', 'cc-repeat-keys-dialog.ui', - 'cc-sound-keys-dialog.ui', 'cc-typing-dialog.ui', 'cc-visual-alerts-dialog.ui', 'cc-zoom-options-dialog.ui' diff --git a/panels/universal-access/universal-access.gresource.xml b/panels/universal-access/universal-access.gresource.xml index c184f37c3..713ef3d45 100644 --- a/panels/universal-access/universal-access.gresource.xml +++ b/panels/universal-access/universal-access.gresource.xml @@ -5,7 +5,6 @@ cc-cursor-size-dialog.ui cc-pointing-dialog.ui cc-repeat-keys-dialog.ui - cc-sound-keys-dialog.ui cc-typing-dialog.ui cc-ua-panel.ui cc-visual-alerts-dialog.ui diff --git a/po/POTFILES.in b/po/POTFILES.in index 7fc818bea..e48012cbc 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -225,7 +225,6 @@ panels/universal-access/cc-cursor-blinking-dialog.ui panels/universal-access/cc-cursor-size-dialog.ui panels/universal-access/cc-pointing-dialog.ui panels/universal-access/cc-repeat-keys-dialog.ui -panels/universal-access/cc-sound-keys-dialog.ui panels/universal-access/cc-typing-dialog.ui panels/universal-access/cc-ua-panel.c panels/universal-access/cc-ua-panel.ui