a11y: Add cc-ua-hearing-page
Implement the new design[0] for Hearing panel [0] https://gitlab.gnome.org/Teams/Design/settings-mockups/-/blob/master/a11y/a11y-wires.png
This commit is contained in:
parent
dbeb41bdc9
commit
ee78ec9ef1
5 changed files with 298 additions and 0 deletions
173
panels/universal-access/cc-ua-hearing-page.c
Normal file
173
panels/universal-access/cc-ua-hearing-page.c
Normal file
|
@ -0,0 +1,173 @@
|
|||
/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
|
||||
* Copyright (C) 2010 Intel, Inc
|
||||
* Copyright 2022 Mohammed Sadiq <sadiq@sadiqpk.org>
|
||||
* Copyright 2022 Purism SPC
|
||||
*
|
||||
* Licensed under the GNU General Public License Version 2
|
||||
*
|
||||
* 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 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.
|
||||
*
|
||||
* Author(s):
|
||||
* Thomas Wood <thomas.wood@intel.com>
|
||||
* Rodrigo Moya <rodrigo@gnome.org>
|
||||
* Mohammed Sadiq <sadiq@sadiqpk.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "cc-ua-hearing-page"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gdesktop-enums.h>
|
||||
|
||||
#include "shell/cc-shell.h"
|
||||
#include "cc-ua-macros.h"
|
||||
#include "cc-list-row.h"
|
||||
#include "cc-ua-hearing-page.h"
|
||||
|
||||
struct _CcUaHearingPage
|
||||
{
|
||||
AdwPreferencesPage parent_instance;
|
||||
|
||||
CcListRow *overamplification_row;
|
||||
GtkLabel *sound_settings_label;
|
||||
|
||||
CcListRow *visual_alerts_row;
|
||||
AdwComboRow *flash_type_row;
|
||||
CcListRow *test_flash_row;
|
||||
|
||||
GSettings *sound_settings;
|
||||
GSettings *wm_settings;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (CcUaHearingPage, cc_ua_hearing_page, ADW_TYPE_PREFERENCES_PAGE)
|
||||
|
||||
static void
|
||||
ua_hearing_flash_type_changed_cb (CcUaHearingPage *self)
|
||||
{
|
||||
GDesktopVisualBellType type;
|
||||
|
||||
type = g_settings_get_enum (self->wm_settings, KEY_VISUAL_BELL_TYPE);
|
||||
adw_combo_row_set_selected (self->flash_type_row, type);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ua_hearing_sound_settings_clicked_cb (CcUaHearingPage *self)
|
||||
{
|
||||
g_autoptr(GError) error = NULL;
|
||||
CcShell *shell;
|
||||
CcPanel *panel;
|
||||
|
||||
g_assert (CC_IS_UA_HEARING_PAGE (self));
|
||||
|
||||
panel = (CcPanel *)gtk_widget_get_ancestor (GTK_WIDGET (self), CC_TYPE_PANEL);
|
||||
shell = cc_panel_get_shell (CC_PANEL (panel));
|
||||
if (!cc_shell_set_active_panel_from_id (shell, "sound", NULL, &error))
|
||||
g_warning ("Failed to activate 'sound' panel: %s", error->message);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
ua_hearing_flash_type_row_changed_cb (CcUaHearingPage *self)
|
||||
{
|
||||
guint selected_index;
|
||||
|
||||
g_assert (CC_IS_UA_HEARING_PAGE (self));
|
||||
|
||||
selected_index = adw_combo_row_get_selected (self->flash_type_row);
|
||||
g_settings_set_enum (self->wm_settings, KEY_VISUAL_BELL_TYPE, selected_index);
|
||||
}
|
||||
|
||||
static void
|
||||
ua_hearing_test_flash_clicked_cb (CcUaHearingPage *self)
|
||||
{
|
||||
GdkSurface *surface;
|
||||
GtkNative *native;
|
||||
|
||||
g_assert (CC_IS_UA_HEARING_PAGE (self));
|
||||
|
||||
native = gtk_widget_get_native (GTK_WIDGET (self));
|
||||
surface = gtk_native_get_surface (native);
|
||||
|
||||
gdk_surface_beep (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
cc_ua_hearing_page_dispose (GObject *object)
|
||||
{
|
||||
CcUaHearingPage *self = (CcUaHearingPage *)object;
|
||||
|
||||
g_clear_object (&self->sound_settings);
|
||||
g_clear_object (&self->wm_settings);
|
||||
|
||||
G_OBJECT_CLASS (cc_ua_hearing_page_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
cc_ua_hearing_page_class_init (CcUaHearingPageClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = cc_ua_hearing_page_dispose;
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class,
|
||||
"/org/gnome/control-center/"
|
||||
"universal-access/cc-ua-hearing-page.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, CcUaHearingPage, overamplification_row);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcUaHearingPage, sound_settings_label);
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, CcUaHearingPage, visual_alerts_row);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcUaHearingPage, flash_type_row);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcUaHearingPage, test_flash_row);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, ua_hearing_sound_settings_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, ua_hearing_flash_type_row_changed_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, ua_hearing_test_flash_clicked_cb);
|
||||
}
|
||||
|
||||
static void
|
||||
cc_ua_hearing_page_init (CcUaHearingPage *self)
|
||||
{
|
||||
const char *label;
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
/* '#' is a dummy target to make 'Sound' clickable */
|
||||
/* TRANSLATORS: Don't translate <a href='#'> and </a> */
|
||||
label = "System volume can be adjusted in <a href='#'>Sound</a> settings.";
|
||||
gtk_label_set_label (self->sound_settings_label, label);
|
||||
|
||||
self->sound_settings = g_settings_new (SOUND_SETTINGS);
|
||||
self->wm_settings = g_settings_new (WM_SETTINGS);
|
||||
|
||||
g_settings_bind (self->sound_settings, KEY_SOUND_OVERAMPLIFY,
|
||||
self->overamplification_row, "active",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (self->wm_settings, KEY_VISUAL_BELL,
|
||||
self->visual_alerts_row, "active",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_signal_connect_object (self->wm_settings, "changed::" KEY_VISUAL_BELL_TYPE,
|
||||
G_CALLBACK (ua_hearing_flash_type_changed_cb), self, G_CONNECT_SWAPPED);
|
||||
}
|
42
panels/universal-access/cc-ua-hearing-page.h
Normal file
42
panels/universal-access/cc-ua-hearing-page.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
|
||||
* Copyright (C) 2010 Intel, Inc
|
||||
* Copyright 2022 Mohammed Sadiq <sadiq@sadiqpk.org>
|
||||
* Copyright 2022 Purism SPC
|
||||
*
|
||||
* Licensed under the GNU General Public License Version 2
|
||||
*
|
||||
* 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 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.
|
||||
*
|
||||
* Author(s):
|
||||
* Thomas Wood <thomas.wood@intel.com>
|
||||
* Rodrigo Moya <rodrigo@gnome.org>
|
||||
* Mohammed Sadiq <sadiq@sadiqpk.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <adwaita.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CC_TYPE_UA_HEARING_PAGE (cc_ua_hearing_page_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CcUaHearingPage, cc_ua_hearing_page, CC, UA_HEARING_PAGE, AdwPreferencesPage)
|
||||
|
||||
G_END_DECLS
|
80
panels/universal-access/cc-ua-hearing-page.ui
Normal file
80
panels/universal-access/cc-ua-hearing-page.ui
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="CcUaHearingPage" parent="AdwPreferencesPage">
|
||||
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup">
|
||||
<child>
|
||||
<object class="CcListRow" id="overamplification_row">
|
||||
<property name="title" translatable="yes">_Overamplification</property>
|
||||
<property name="subtitle" translatable="yes">Allow volume to exceed 100%. This will result in quality loss.</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="show-switch">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="sound_settings_label">
|
||||
<property name="use-markup">True</property>
|
||||
<property name="margin-top">9</property>
|
||||
<property name="xalign">0.0</property>
|
||||
<property name="wrap">True</property>
|
||||
<signal name="activate-link" handler="ua_hearing_sound_settings_clicked_cb" swapped="yes"/>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup">
|
||||
<property name="title" translatable="yes">Visual Alerts</property>
|
||||
<property name="description" translatable="yes">Use a visual indication when an alert sound occurs</property>
|
||||
|
||||
<child>
|
||||
<object class="CcListRow" id="visual_alerts_row">
|
||||
<property name="title" translatable="yes">_Visual Alerts</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="show-switch">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="AdwComboRow" id="flash_type_row">
|
||||
<property name="sensitive" bind-source="visual_alerts_row" bind-property="active" bind-flags="sync-create"/>
|
||||
<property name="title" translatable="yes">_Flash Area</property>
|
||||
<property name="use-underline">True</property>
|
||||
<signal name="notify::selected" handler="ua_hearing_flash_type_row_changed_cb" swapped="yes" />
|
||||
<property name="model">
|
||||
<object class="GtkStringList">
|
||||
<items>
|
||||
<item translatable="yes">Entire Screen</item>
|
||||
<item translatable="yes">Entire Window</item>
|
||||
</items>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="AdwActionRow" id="test_flash_row">
|
||||
<property name="sensitive" bind-source="visual_alerts_row" bind-property="active" bind-flags="sync-create"/>
|
||||
<property name="title" translatable="yes">_Test Flash</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="activatable-widget">test_flash_button</property>
|
||||
<child type="suffix">
|
||||
<object class="GtkButton" id="test_flash_button">
|
||||
<property name="valign">center</property>
|
||||
<property name="label" translatable="yes">Test</property>
|
||||
<signal name="clicked" handler="ua_hearing_test_flash_clicked_cb" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</template>
|
||||
</interface>
|
|
@ -17,6 +17,7 @@ sources = files(
|
|||
'cc-repeat-keys-dialog.c',
|
||||
'cc-typing-dialog.c',
|
||||
'cc-ua-panel.c',
|
||||
'cc-ua-hearing-page.c',
|
||||
'cc-ua-seeing-page.c',
|
||||
'cc-visual-alerts-dialog.c',
|
||||
'cc-zoom-options-dialog.c'
|
||||
|
@ -34,6 +35,7 @@ resource_data = files(
|
|||
'cc-pointing-dialog.ui',
|
||||
'cc-repeat-keys-dialog.ui',
|
||||
'cc-typing-dialog.ui',
|
||||
'cc-ua-hearing-page.ui',
|
||||
'cc-ua-seeing-page.ui',
|
||||
'cc-visual-alerts-dialog.ui',
|
||||
'cc-zoom-options-dialog.ui'
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<file preprocess="xml-stripblanks">cc-repeat-keys-dialog.ui</file>
|
||||
<file preprocess="xml-stripblanks">cc-typing-dialog.ui</file>
|
||||
<file preprocess="xml-stripblanks">cc-ua-panel.ui</file>
|
||||
<file preprocess="xml-stripblanks">cc-ua-hearing-page.ui</file>
|
||||
<file preprocess="xml-stripblanks">cc-ua-seeing-page.ui</file>
|
||||
<file preprocess="xml-stripblanks">cc-visual-alerts-dialog.ui</file>
|
||||
<file preprocess="xml-stripblanks">cc-zoom-options-dialog.ui</file>
|
||||
|
|
Loading…
Add table
Reference in a new issue