diff options
Diffstat (limited to 'panels/universal-access')
34 files changed, 4342 insertions, 0 deletions
diff --git a/panels/universal-access/cc-cursor-blinking-dialog.c b/panels/universal-access/cc-cursor-blinking-dialog.c new file mode 100644 index 0000000..1cb9e91 --- /dev/null +++ b/panels/universal-access/cc-cursor-blinking-dialog.c @@ -0,0 +1,83 @@ +/* + * 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-cursor-blinking-dialog.h" + +#define INTERFACE_SETTINGS "org.gnome.desktop.interface" +#define KEY_CURSOR_BLINKING "cursor-blink" +#define KEY_CURSOR_BLINKING_TIME "cursor-blink-time" + +struct _CcCursorBlinkingDialog +{ + GtkDialog parent; + + GtkScale *blink_time_scale; + GtkSwitch *enable_switch; + + GSettings *interface_settings; +}; + +G_DEFINE_TYPE (CcCursorBlinkingDialog, cc_cursor_blinking_dialog, GTK_TYPE_DIALOG); + +static void +cc_cursor_blinking_dialog_dispose (GObject *object) +{ + CcCursorBlinkingDialog *self = CC_CURSOR_BLINKING_DIALOG (object); + + g_clear_object (&self->interface_settings); + + G_OBJECT_CLASS (cc_cursor_blinking_dialog_parent_class)->dispose (object); +} + +static void +cc_cursor_blinking_dialog_class_init (CcCursorBlinkingDialogClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->dispose = cc_cursor_blinking_dialog_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/universal-access/cc-cursor-blinking-dialog.ui"); + + gtk_widget_class_bind_template_child (widget_class, CcCursorBlinkingDialog, blink_time_scale); + gtk_widget_class_bind_template_child (widget_class, CcCursorBlinkingDialog, enable_switch); +} + +static void +cc_cursor_blinking_dialog_init (CcCursorBlinkingDialog *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); + + self->interface_settings = g_settings_new (INTERFACE_SETTINGS); + + g_settings_bind (self->interface_settings, KEY_CURSOR_BLINKING, + self->enable_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (self->interface_settings, KEY_CURSOR_BLINKING_TIME, + gtk_range_get_adjustment (GTK_RANGE (self->blink_time_scale)), "value", + G_SETTINGS_BIND_DEFAULT); +} + +CcCursorBlinkingDialog * +cc_cursor_blinking_dialog_new (void) +{ + return g_object_new (cc_cursor_blinking_dialog_get_type (), + "use-header-bar", TRUE, + NULL); +} diff --git a/panels/universal-access/cc-cursor-blinking-dialog.h b/panels/universal-access/cc-cursor-blinking-dialog.h new file mode 100644 index 0000000..46d5a05 --- /dev/null +++ b/panels/universal-access/cc-cursor-blinking-dialog.h @@ -0,0 +1,29 @@ +/* + * 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 <gtk/gtk.h> + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE (CcCursorBlinkingDialog, cc_cursor_blinking_dialog, CC, CURSOR_BLINKING_DIALOG, GtkDialog) + +CcCursorBlinkingDialog *cc_cursor_blinking_dialog_new (void); + +G_END_DECLS diff --git a/panels/universal-access/cc-cursor-blinking-dialog.ui b/panels/universal-access/cc-cursor-blinking-dialog.ui new file mode 100644 index 0000000..e31e612 --- /dev/null +++ b/panels/universal-access/cc-cursor-blinking-dialog.ui @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <template class="CcCursorBlinkingDialog" parent="GtkDialog"> + <property name="title" translatable="yes">Cursor Blinking</property> + <property name="resizable">False</property> + <property name="modal">True</property> + <property name="use_header_bar">1</property> + <child internal-child="headerbar"> + <object class="GtkHeaderBar"> + <child> + <object class="GtkSwitch" id="enable_switch"> + <property name="valign">center</property> + <accessibility> + <property name="label" translatable="yes">Enable</property> + </accessibility> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="margin_start">12</property> + <property name="margin_end">12</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Cursor blinks in text fields.</property> + <property name="margin_start">12</property> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <property name="margin_bottom">12</property> + </object> + </child> + <child> + <object class="GtkGrid"> + <property name="valign">start</property> + <property name="margin_start">12</property> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <property name="margin_bottom">12</property> + <property name="orientation">vertical</property> + <property name="row_spacing">18</property> + <property name="column_spacing">24</property> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Speed</property> + <property name="mnemonic_widget">blink_time_scale</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkScale" id="blink_time_scale"> + <property name="hexpand">True</property> + <property name="adjustment">blink_time_adjustment</property> + <property name="draw_value">False</property> + <property name="width-request">400</property> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + <accessibility> + <property name="label" translatable="yes">Cursor blinking speed</property> + </accessibility> + </object> + </child> + </object> + </child> + </object> + </child> + </template> + <object class="GtkAdjustment" id="blink_time_adjustment"> + <property name="lower">100</property> + <property name="upper">2500</property> + <property name="value">1000</property> + <property name="step_increment">200</property> + <property name="page_increment">200</property> + </object> +</interface> diff --git a/panels/universal-access/cc-cursor-size-dialog.c b/panels/universal-access/cc-cursor-size-dialog.c new file mode 100644 index 0000000..cfd8378 --- /dev/null +++ b/panels/universal-access/cc-cursor-size-dialog.c @@ -0,0 +1,121 @@ +/* + * 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-cursor-size-dialog.h" + +#define INTERFACE_SETTINGS "org.gnome.desktop.interface" +#define KEY_MOUSE_CURSOR_SIZE "cursor-size" + +struct _CcCursorSizeDialog +{ + GtkDialog parent; + + GtkGrid *size_grid; + + GSettings *interface_settings; +}; + +G_DEFINE_TYPE (CcCursorSizeDialog, cc_cursor_size_dialog, GTK_TYPE_DIALOG); + +static void +cursor_size_toggled (CcCursorSizeDialog *self, GtkWidget *button) +{ + guint cursor_size; + + if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) + return; + + cursor_size = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button), "cursor-size")); + g_settings_set_int (self->interface_settings, KEY_MOUSE_CURSOR_SIZE, cursor_size); + g_debug ("Setting cursor size to %d", cursor_size); +} + +static void +cc_cursor_size_dialog_dispose (GObject *object) +{ + CcCursorSizeDialog *self = CC_CURSOR_SIZE_DIALOG (object); + + g_clear_object (&self->interface_settings); + + G_OBJECT_CLASS (cc_cursor_size_dialog_parent_class)->dispose (object); +} + +static void +cc_cursor_size_dialog_class_init (CcCursorSizeDialogClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->dispose = cc_cursor_size_dialog_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/universal-access/cc-cursor-size-dialog.ui"); + + gtk_widget_class_bind_template_child (widget_class, CcCursorSizeDialog, size_grid); +} + +static void +cc_cursor_size_dialog_init (CcCursorSizeDialog *self) +{ + guint cursor_sizes[] = { 24, 32, 48, 64, 96 }; + guint current_cursor_size, i; + GtkSizeGroup *size_group; + GtkWidget *last_radio_button = NULL; + + gtk_widget_init_template (GTK_WIDGET (self)); + + self->interface_settings = g_settings_new (INTERFACE_SETTINGS); + + current_cursor_size = g_settings_get_int (self->interface_settings, + KEY_MOUSE_CURSOR_SIZE); + size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH); + + for (i = 0; i < G_N_ELEMENTS(cursor_sizes); i++) + { + GtkWidget *image, *button; + g_autofree gchar *cursor_image_name = NULL; + + cursor_image_name = g_strdup_printf ("/org/gnome/control-center/universal-access/left_ptr_%dpx.png", cursor_sizes[i]); + image = gtk_image_new_from_resource (cursor_image_name); + gtk_image_set_pixel_size (GTK_IMAGE (image), cursor_sizes[i]); + gtk_widget_set_halign (image, GTK_ALIGN_CENTER); + gtk_widget_set_valign (image, GTK_ALIGN_CENTER); + + button = gtk_toggle_button_new (); + gtk_toggle_button_set_group (GTK_TOGGLE_BUTTON (button), GTK_TOGGLE_BUTTON (last_radio_button)); + last_radio_button = button; + g_object_set_data (G_OBJECT (button), "cursor-size", GUINT_TO_POINTER (cursor_sizes[i])); + + gtk_button_set_child (GTK_BUTTON (button), image); + gtk_grid_attach (GTK_GRID (self->size_grid), button, i, 0, 1, 1); + gtk_size_group_add_widget (size_group, button); + + g_signal_connect_object (button, "toggled", + G_CALLBACK (cursor_size_toggled), self, G_CONNECT_SWAPPED); + + if (current_cursor_size == cursor_sizes[i]) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); + } +} + +CcCursorSizeDialog * +cc_cursor_size_dialog_new (void) +{ + return g_object_new (cc_cursor_size_dialog_get_type (), + "use-header-bar", TRUE, + NULL); +} diff --git a/panels/universal-access/cc-cursor-size-dialog.h b/panels/universal-access/cc-cursor-size-dialog.h new file mode 100644 index 0000000..29d2b1e --- /dev/null +++ b/panels/universal-access/cc-cursor-size-dialog.h @@ -0,0 +1,29 @@ +/* + * 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 <gtk/gtk.h> + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE (CcCursorSizeDialog, cc_cursor_size_dialog, CC, CURSOR_SIZE_DIALOG, GtkDialog) + +CcCursorSizeDialog *cc_cursor_size_dialog_new (void); + +G_END_DECLS diff --git a/panels/universal-access/cc-cursor-size-dialog.ui b/panels/universal-access/cc-cursor-size-dialog.ui new file mode 100644 index 0000000..37f10a3 --- /dev/null +++ b/panels/universal-access/cc-cursor-size-dialog.ui @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <template class="CcCursorSizeDialog" parent="GtkDialog"> + <property name="title" translatable="yes">Cursor Size</property> + <property name="resizable">False</property> + <property name="modal">True</property> + <child> + <object class="GtkBox"> + <property name="margin_start">12</property> + <property name="margin_end">12</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="orientation">vertical</property> + <property name="spacing">8</property> + <child> + <object class="GtkLabel"> + <property name="margin_start">12</property> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <property name="margin_bottom">6</property> + <property name="label" translatable="yes">Cursor size can be combined with zoom to make it easier to see the cursor.</property> + <property name="wrap">True</property> + <property name="max_width_chars">45</property> + <property name="xalign">0</property> + </object> + </child> + <child> + <object class="GtkGrid" id="size_grid"> + <property name="hexpand">True</property> + <property name="halign">center</property> + <style> + <class name="linked"/> + </style> + </object> + </child> + </object> + </child> + </template> +</interface> diff --git a/panels/universal-access/cc-pointing-dialog.c b/panels/universal-access/cc-pointing-dialog.c new file mode 100644 index 0000000..145867b --- /dev/null +++ b/panels/universal-access/cc-pointing-dialog.c @@ -0,0 +1,123 @@ +/* + * 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-pointing-dialog.h" + +#define MOUSE_SETTINGS "org.gnome.desktop.a11y.mouse" +#define KEY_SECONDARY_CLICK_ENABLED "secondary-click-enabled" +#define KEY_SECONDARY_CLICK_TIME "secondary-click-time" +#define KEY_DWELL_CLICK_ENABLED "dwell-click-enabled" +#define KEY_DWELL_TIME "dwell-time" +#define KEY_DWELL_THRESHOLD "dwell-threshold" + +#define KEY_DOUBLE_CLICK_DELAY "double-click" + +struct _CcPointingDialog +{ + GtkDialog parent; + + GtkBox *dwell_delay_box; + GtkScale *dwell_delay_scale; + GtkBox *dwell_threshold_box; + GtkScale *dwell_threshold_scale; + GtkSwitch *hover_click_switch; + GtkBox *secondary_click_delay_box; + GtkScale *secondary_click_delay_scale; + GtkSwitch *secondary_click_switch; + + GSettings *mouse_settings; +}; + +G_DEFINE_TYPE (CcPointingDialog, cc_pointing_dialog, GTK_TYPE_DIALOG); + +static void +cc_pointing_dialog_dispose (GObject *object) +{ + CcPointingDialog *self = CC_POINTING_DIALOG (object); + + g_clear_object (&self->mouse_settings); + + G_OBJECT_CLASS (cc_pointing_dialog_parent_class)->dispose (object); +} + +static void +cc_pointing_dialog_class_init (CcPointingDialogClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->dispose = cc_pointing_dialog_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/universal-access/cc-pointing-dialog.ui"); + + gtk_widget_class_bind_template_child (widget_class, CcPointingDialog, dwell_delay_box); + gtk_widget_class_bind_template_child (widget_class, CcPointingDialog, dwell_delay_scale); + gtk_widget_class_bind_template_child (widget_class, CcPointingDialog, dwell_threshold_box); + gtk_widget_class_bind_template_child (widget_class, CcPointingDialog, dwell_threshold_scale); + gtk_widget_class_bind_template_child (widget_class, CcPointingDialog, hover_click_switch); + gtk_widget_class_bind_template_child (widget_class, CcPointingDialog, secondary_click_delay_box); + gtk_widget_class_bind_template_child (widget_class, CcPointingDialog, secondary_click_delay_scale); + gtk_widget_class_bind_template_child (widget_class, CcPointingDialog, secondary_click_switch); +} + +static void +cc_pointing_dialog_init (CcPointingDialog *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); + + self->mouse_settings = g_settings_new (MOUSE_SETTINGS); + + /* simulated secondary click */ + g_settings_bind (self->mouse_settings, KEY_SECONDARY_CLICK_ENABLED, + self->secondary_click_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (self->mouse_settings, KEY_SECONDARY_CLICK_TIME, + gtk_range_get_adjustment (GTK_RANGE (self->secondary_click_delay_scale)), "value", + G_SETTINGS_BIND_DEFAULT); + g_object_bind_property (self->secondary_click_switch, "active", + self->secondary_click_delay_box, "sensitive", + G_BINDING_SYNC_CREATE); + + /* dwell click */ + g_settings_bind (self->mouse_settings, KEY_DWELL_CLICK_ENABLED, + self->hover_click_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (self->mouse_settings, KEY_DWELL_TIME, + gtk_range_get_adjustment (GTK_RANGE (self->dwell_delay_scale)), "value", + G_SETTINGS_BIND_DEFAULT); + g_object_bind_property (self->hover_click_switch, "active", + self->dwell_delay_box, "sensitive", + G_BINDING_SYNC_CREATE); + + g_settings_bind (self->mouse_settings, KEY_DWELL_THRESHOLD, + gtk_range_get_adjustment (GTK_RANGE (self->dwell_threshold_scale)), "value", + G_SETTINGS_BIND_DEFAULT); + g_object_bind_property (self->hover_click_switch, "active", + self->dwell_threshold_box, "sensitive", + G_BINDING_SYNC_CREATE); +} + +CcPointingDialog * +cc_pointing_dialog_new (void) +{ + return g_object_new (cc_pointing_dialog_get_type (), + "use-header-bar", TRUE, + NULL); +} diff --git a/panels/universal-access/cc-pointing-dialog.h b/panels/universal-access/cc-pointing-dialog.h new file mode 100644 index 0000000..c2754aa --- /dev/null +++ b/panels/universal-access/cc-pointing-dialog.h @@ -0,0 +1,29 @@ +/* + * 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 <gtk/gtk.h> + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE (CcPointingDialog, cc_pointing_dialog, CC, POINTING_DIALOG, GtkDialog) + +CcPointingDialog *cc_pointing_dialog_new (void); + +G_END_DECLS diff --git a/panels/universal-access/cc-pointing-dialog.ui b/panels/universal-access/cc-pointing-dialog.ui new file mode 100644 index 0000000..e35fade --- /dev/null +++ b/panels/universal-access/cc-pointing-dialog.ui @@ -0,0 +1,306 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <template class="CcPointingDialog" parent="GtkDialog"> + <property name="title" translatable="yes">Click Assist</property> + <property name="resizable">False</property> + <property name="modal">True</property> + <property name="use_header_bar">1</property> + <child> + <object class="GtkBox"> + <property name="margin_start">12</property> + <property name="margin_end">12</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkGrid"> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <property name="margin_bottom">12</property> + <property name="row_spacing">18</property> + <property name="column_spacing">24</property> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Simulated Secondary Click</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">secondary_click_switch</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel" id="secondary_click_description"> + <property name="xalign">0</property> + <property name="label" translatable="yes">Trigger a secondary click by holding down the primary button</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="margin_start">10</property> + <property name="margin_end">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="secondary_click_delay_box"> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="secondary_click_delay_label"> + <property name="xalign">0</property> + <property name="label" translatable="yes">A_cceptance delay:</property> + <property name="use_underline">True</property> + <property name="justify">center</property> + <property name="mnemonic_widget">secondary_click_delay_scale</property> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="xalign">1</property> + <property name="label" translatable="yes" context="secondary click">Short</property> + <attributes> + <attribute name="scale" value="0.83"/> + </attributes> + </object> + </child> + <child> + <object class="GtkScale" id="secondary_click_delay_scale"> + <property name="adjustment">click_delay_adjustment</property> + <property name="draw_value">False</property> + <property name="hexpand">True</property> + <accessibility> + <property name="label" translatable="yes">Secondary click delay</property> + </accessibility> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" context="secondary click delay">Long</property> + <attributes> + <attribute name="scale" value="0.83"/> + </attributes> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Hover Click</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">hover_click_switch</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel" id="hover_click_description"> + <property name="xalign">0</property> + <property name="label" translatable="yes">Trigger a click when the pointer hovers</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="margin_start">10</property> + <property name="margin_end">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="dwell_delay_box"> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="dwell_delay_label"> + <property name="xalign">0</property> + <property name="label" translatable="yes">D_elay:</property> + <property name="use_underline">True</property> + <property name="justify">center</property> + <property name="mnemonic_widget">dwell_delay_scale</property> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="xalign">1</property> + <property name="label" translatable="yes" context="dwell click delay">Short</property> + <property name="justify">center</property> + <attributes> + <attribute name="scale" value="0.83"/> + </attributes> + </object> + </child> + <child> + <object class="GtkScale" id="dwell_delay_scale"> + <property name="adjustment">dwell_time_adjustment</property> + <property name="draw_value">False</property> + <property name="value_pos">right</property> + <property name="hexpand">True</property> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" context="dwell click delay">Long</property> + <property name="justify">center</property> + <attributes> + <attribute name="scale" value="0.83"/> + </attributes> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox" id="dwell_threshold_box"> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="dwell_threshold_label"> + <property name="xalign">0</property> + <property name="label" translatable="yes">Motion _threshold:</property> + <property name="use_underline">True</property> + <property name="justify">center</property> + <property name="mnemonic_widget">dwell_threshold_scale</property> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="xalign">1</property> + <property name="label" translatable="yes" context="dwell click threshold">Small</property> + <property name="justify">center</property> + <attributes> + <attribute name="scale" value="0.83"/> + </attributes> + </object> + </child> + <child> + <object class="GtkScale" id="dwell_threshold_scale"> + <property name="adjustment">dwell_threshold_adjustment</property> + <property name="digits">0</property> + <property name="draw_value">False</property> + <property name="hexpand">True</property> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" context="dwell click threshold">Large</property> + <property name="justify">center</property> + <attributes> + <attribute name="scale" value="0.83"/> + </attributes> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkSwitch" id="secondary_click_switch"> + <property name="halign">end</property> + <property name="valign">start</property> + <property name="hexpand">True</property> + <accessibility> + <relation name="described-by">secondary_click_description</relation> + </accessibility> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> + </object> + </child> + <child> + <object class="GtkSwitch" id="hover_click_switch"> + <property name="halign">end</property> + <property name="valign">start</property> + <property name="hexpand">True</property> + <accessibility> + <relation name="described-by">hover_click_description</relation> + </accessibility> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + </object> + </child> + </object> + </child> + </object> + </child> + </template> + <object class="GtkSizeGroup"> + <widgets> + <widget name="secondary_click_delay_label"/> + <widget name="dwell_delay_label"/> + <widget name="dwell_threshold_label"/> + </widgets> + </object> + <object class="GtkAdjustment" id="click_delay_adjustment"> + <property name="lower">0.5</property> + <property name="upper">3</property> + <property name="value">1.2</property> + <property name="step_increment">0.1</property> + <property name="page_increment">0.1</property> + </object> + <object class="GtkAdjustment" id="dwell_threshold_adjustment"> + <property name="upper">30</property> + <property name="value">15</property> + <property name="step_increment">1</property> + <property name="page_increment">1</property> + </object> + <object class="GtkAdjustment" id="dwell_time_adjustment"> + <property name="lower">0.2</property> + <property name="upper">3</property> + <property name="value">1.2</property> + <property name="step_increment">0.1</property> + <property name="page_increment">0.1</property> + </object> +</interface> diff --git a/panels/universal-access/cc-repeat-keys-dialog.c b/panels/universal-access/cc-repeat-keys-dialog.c new file mode 100644 index 0000000..4a65399 --- /dev/null +++ b/panels/universal-access/cc-repeat-keys-dialog.c @@ -0,0 +1,108 @@ +/* + * 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-repeat-keys-dialog.h" + +#define KEYBOARD_SETTINGS "org.gnome.desktop.peripherals.keyboard" +#define KEY_REPEAT_KEYS "repeat" +#define KEY_DELAY "delay" +#define KEY_REPEAT_INTERVAL "repeat-interval" + +struct _CcRepeatKeysDialog +{ + GtkDialog parent; + + GtkSwitch *enable_switch; + GtkGrid *delay_grid; + GtkScale *delay_scale; + GtkGrid *speed_grid; + GtkScale *speed_scale; + + GSettings *keyboard_settings; +}; + +G_DEFINE_TYPE (CcRepeatKeysDialog, cc_repeat_keys_dialog, GTK_TYPE_DIALOG); + +static void +on_repeat_keys_toggled (CcRepeatKeysDialog *self) +{ + gboolean on; + + on = g_settings_get_boolean (self->keyboard_settings, KEY_REPEAT_KEYS); + + gtk_widget_set_sensitive (GTK_WIDGET (self->delay_grid), on); + gtk_widget_set_sensitive (GTK_WIDGET (self->speed_grid), on); +} + +static void +cc_repeat_keys_dialog_dispose (GObject *object) +{ + CcRepeatKeysDialog *self = CC_REPEAT_KEYS_DIALOG (object); + + g_clear_object (&self->keyboard_settings); + + G_OBJECT_CLASS (cc_repeat_keys_dialog_parent_class)->dispose (object); +} + +static void +cc_repeat_keys_dialog_class_init (CcRepeatKeysDialogClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->dispose = cc_repeat_keys_dialog_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/universal-access/cc-repeat-keys-dialog.ui"); + + gtk_widget_class_bind_template_child (widget_class, CcRepeatKeysDialog, enable_switch); + gtk_widget_class_bind_template_child (widget_class, CcRepeatKeysDialog, delay_grid); + gtk_widget_class_bind_template_child (widget_class, CcRepeatKeysDialog, delay_scale); + gtk_widget_class_bind_template_child (widget_class, CcRepeatKeysDialog, speed_grid); + gtk_widget_class_bind_template_child (widget_class, CcRepeatKeysDialog, speed_scale); +} + +static void +cc_repeat_keys_dialog_init (CcRepeatKeysDialog *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); + + self->keyboard_settings = g_settings_new (KEYBOARD_SETTINGS); + + g_signal_connect_object (self->keyboard_settings, "changed", + G_CALLBACK (on_repeat_keys_toggled), self, G_CONNECT_SWAPPED); + on_repeat_keys_toggled (self); + + g_settings_bind (self->keyboard_settings, KEY_REPEAT_KEYS, + self->enable_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (self->keyboard_settings, KEY_DELAY, + gtk_range_get_adjustment (GTK_RANGE (self->delay_scale)), "value", + G_SETTINGS_BIND_DEFAULT); + g_settings_bind (self->keyboard_settings, KEY_REPEAT_INTERVAL, + gtk_range_get_adjustment (GTK_RANGE (self->speed_scale)), "value", + G_SETTINGS_BIND_DEFAULT); +} + +CcRepeatKeysDialog * +cc_repeat_keys_dialog_new (void) +{ + return g_object_new (cc_repeat_keys_dialog_get_type (), + "use-header-bar", TRUE, + NULL); +} diff --git a/panels/universal-access/cc-repeat-keys-dialog.h b/panels/universal-access/cc-repeat-keys-dialog.h new file mode 100644 index 0000000..ebc1a76 --- /dev/null +++ b/panels/universal-access/cc-repeat-keys-dialog.h @@ -0,0 +1,29 @@ +/* + * 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 <gtk/gtk.h> + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE (CcRepeatKeysDialog, cc_repeat_keys_dialog, CC, REPEAT_KEYS_DIALOG, GtkDialog) + +CcRepeatKeysDialog *cc_repeat_keys_dialog_new (void); + +G_END_DECLS diff --git a/panels/universal-access/cc-repeat-keys-dialog.ui b/panels/universal-access/cc-repeat-keys-dialog.ui new file mode 100644 index 0000000..78fa550 --- /dev/null +++ b/panels/universal-access/cc-repeat-keys-dialog.ui @@ -0,0 +1,179 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <template class="CcRepeatKeysDialog" parent="GtkDialog"> + <property name="title" translatable="yes">Repeat Keys</property> + <property name="resizable">False</property> + <property name="modal">True</property> + <property name="use_header_bar">1</property> + <child internal-child="headerbar"> + <object class="GtkHeaderBar"> + <child> + <object class="GtkSwitch" id="enable_switch"> + <property name="valign">center</property> + <accessibility> + <property name="label" translatable="yes">Enable</property> + </accessibility> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="margin_start">12</property> + <property name="margin_end">12</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Key presses repeat when key is held down.</property> + <property name="margin_start">12</property> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <property name="margin_bottom">12</property> + </object> + </child> + <child> + <object class="GtkGrid" id="delay_grid"> + <property name="valign">start</property> + <property name="margin_start">12</property> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <property name="margin_bottom">12</property> + <property name="orientation">vertical</property> + <property name="row_spacing">18</property> + <property name="column_spacing">24</property> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel" id="delay_label"> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Delay</property> + <property name="mnemonic_widget">delay_scale</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkScale" id="delay_scale"> + <property name="hexpand">True</property> + <property name="adjustment">repeat_delay_adjustment</property> + <property name="draw_value">False</property> + <property name="has_origin">False</property> + <property name="width-request">400</property> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + <accessibility> + <property name="label" translatable="yes">Repeat keys delay</property> + </accessibility> + </object> + </child> + </object> + </child> + <child> + <object class="GtkGrid" id="speed_grid"> + <property name="valign">start</property> + <property name="margin_start">12</property> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <property name="margin_bottom">12</property> + <property name="orientation">vertical</property> + <property name="row_spacing">18</property> + <property name="column_spacing">24</property> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel" id="speed_label"> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Speed</property> + <property name="mnemonic_widget">speed_scale</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkScale" id="speed_scale"> + <property name="hexpand">True</property> + <property name="adjustment">repeat_speed_adjustment</property> + <property name="draw_value">False</property> + <property name="has_origin">False</property> + <property name="inverted">True</property> + <property name="width-request">200</property> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + <accessibility> + <property name="label" translatable="yes">Repeat keys speed</property> + </accessibility> + </object> + </child> + </object> + </child> + </object> + </child> + </template> + <object class="GtkAdjustment" id="repeat_delay_adjustment"> + <property name="lower">100</property> + <property name="upper">2000</property> + <property name="value">500</property> + <property name="step_increment">10</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="repeat_speed_adjustment"> + <property name="lower">0.5</property> + <property name="upper">110</property> + <property name="value">33.3</property> + <property name="step_increment">1</property> + <property name="page_increment">1</property> + </object> + <object class="GtkSizeGroup"> + <widgets> + <widget name="delay_label"/> + <widget name="speed_label"/> + </widgets> + </object> + <object class="GtkSizeGroup"> + <widgets> + <widget name="delay_scale"/> + <widget name="speed_scale"/> + </widgets> + </object> +</interface> diff --git a/panels/universal-access/cc-typing-dialog.c b/panels/universal-access/cc-typing-dialog.c new file mode 100644 index 0000000..35004d4 --- /dev/null +++ b/panels/universal-access/cc-typing-dialog.c @@ -0,0 +1,185 @@ +/* + * 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-typing-dialog.h" + +#define KEYBOARD_SETTINGS "org.gnome.desktop.a11y.keyboard" +#define KEY_KEYBOARD_TOGGLE "enable" +#define KEY_STICKYKEYS_ENABLED "stickykeys-enable" +#define KEY_STICKYKEYS_TWO_KEY_OFF "stickykeys-two-key-off" +#define KEY_STICKYKEYS_MODIFIER_BEEP "stickykeys-modifier-beep" +#define KEY_SLOWKEYS_ENABLED "slowkeys-enable" +#define KEY_SLOWKEYS_DELAY "slowkeys-delay" +#define KEY_SLOWKEYS_BEEP_PRESS "slowkeys-beep-press" +#define KEY_SLOWKEYS_BEEP_ACCEPT "slowkeys-beep-accept" +#define KEY_SLOWKEYS_BEEP_REJECT "slowkeys-beep-reject" +#define KEY_BOUNCEKEYS_ENABLED "bouncekeys-enable" +#define KEY_BOUNCEKEYS_DELAY "bouncekeys-delay" +#define KEY_BOUNCEKEYS_BEEP_REJECT "bouncekeys-beep-reject" + +struct _CcTypingDialog +{ + GtkDialog parent; + + GtkCheckButton *bouncekeys_beep_rejected_check; + GtkBox *bouncekeys_delay_box; + GtkScale *bouncekeys_delay_scale; + GtkSwitch *bouncekeys_switch; + GtkSwitch *keyboard_toggle_switch; + GtkCheckButton *slowkeys_beep_accepted_check; + GtkCheckButton *slowkeys_beep_pressed_check; + GtkCheckButton *slowkeys_beep_rejected_check; + GtkBox *slowkeys_delay_box; + GtkScale *slowkeys_delay_scale; + GtkSwitch *slowkeys_switch; + GtkCheckButton *stickykeys_beep_modifier_check; + GtkCheckButton *stickykeys_disable_two_keys_check; + GtkSwitch *stickykeys_switch; + + GSettings *keyboard_settings; +}; + +G_DEFINE_TYPE (CcTypingDialog, cc_typing_dialog, GTK_TYPE_DIALOG); + +static void +cc_typing_dialog_dispose (GObject *object) +{ + CcTypingDialog *self = CC_TYPING_DIALOG (object); + + g_clear_object (&self->keyboard_settings); + + G_OBJECT_CLASS (cc_typing_dialog_parent_class)->dispose (object); +} + +static void +cc_typing_dialog_class_init (CcTypingDialogClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->dispose = cc_typing_dialog_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/universal-access/cc-typing-dialog.ui"); + + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, bouncekeys_beep_rejected_check); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, bouncekeys_delay_box); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, bouncekeys_delay_scale); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, bouncekeys_switch); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, keyboard_toggle_switch); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, slowkeys_beep_accepted_check); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, slowkeys_beep_pressed_check); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, slowkeys_beep_rejected_check); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, slowkeys_delay_box); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, slowkeys_delay_scale); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, slowkeys_switch); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, stickykeys_beep_modifier_check); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, stickykeys_disable_two_keys_check); + gtk_widget_class_bind_template_child (widget_class, CcTypingDialog, stickykeys_switch); +} + +static void +cc_typing_dialog_init (CcTypingDialog *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); + + self->keyboard_settings = g_settings_new (KEYBOARD_SETTINGS); + + /* enable shortcuts */ + g_settings_bind (self->keyboard_settings, KEY_KEYBOARD_TOGGLE, + self->keyboard_toggle_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + /* sticky keys */ + g_settings_bind (self->keyboard_settings, KEY_STICKYKEYS_ENABLED, + self->stickykeys_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (self->keyboard_settings, KEY_STICKYKEYS_TWO_KEY_OFF, + self->stickykeys_disable_two_keys_check, "active", + G_SETTINGS_BIND_NO_SENSITIVITY); + g_object_bind_property (self->stickykeys_switch, "active", + self->stickykeys_disable_two_keys_check, "sensitive", + G_BINDING_SYNC_CREATE); + + g_settings_bind (self->keyboard_settings, KEY_STICKYKEYS_MODIFIER_BEEP, + self->stickykeys_beep_modifier_check, "active", + G_SETTINGS_BIND_NO_SENSITIVITY); + g_object_bind_property (self->stickykeys_switch, "active", + self->stickykeys_beep_modifier_check, "sensitive", + G_BINDING_SYNC_CREATE); + + /* slow keys */ + g_settings_bind (self->keyboard_settings, KEY_SLOWKEYS_ENABLED, + self->slowkeys_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (self->keyboard_settings, KEY_SLOWKEYS_DELAY, + gtk_range_get_adjustment (GTK_RANGE (self->slowkeys_delay_scale)), "value", + G_SETTINGS_BIND_DEFAULT); + g_object_bind_property (self->slowkeys_switch, "active", + self->slowkeys_delay_box, "sensitive", + G_BINDING_SYNC_CREATE); + + g_settings_bind (self->keyboard_settings, KEY_SLOWKEYS_BEEP_PRESS, + self->slowkeys_beep_pressed_check, "active", + G_SETTINGS_BIND_DEFAULT); + g_object_bind_property (self->slowkeys_switch, "active", + self->slowkeys_beep_pressed_check, "sensitive", + G_BINDING_SYNC_CREATE); + + g_settings_bind (self->keyboard_settings, KEY_SLOWKEYS_BEEP_ACCEPT, + self->slowkeys_beep_accepted_check, "active", + G_SETTINGS_BIND_DEFAULT); + g_object_bind_property (self->slowkeys_switch, "active", + self->slowkeys_beep_accepted_check, "sensitive", + G_BINDING_SYNC_CREATE); + + g_settings_bind (self->keyboard_settings, KEY_SLOWKEYS_BEEP_REJECT, + self->slowkeys_beep_rejected_check, "active", + G_SETTINGS_BIND_DEFAULT); + g_object_bind_property (self->slowkeys_switch, "active", + self->slowkeys_beep_rejected_check, "sensitive", + G_BINDING_SYNC_CREATE); + + /* bounce keys */ + g_settings_bind (self->keyboard_settings, KEY_BOUNCEKEYS_ENABLED, + self->bouncekeys_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (self->keyboard_settings, KEY_BOUNCEKEYS_DELAY, + gtk_range_get_adjustment (GTK_RANGE (self->bouncekeys_delay_scale)), "value", + G_SETTINGS_BIND_DEFAULT); + g_object_bind_property (self->bouncekeys_switch, "active", + self->bouncekeys_delay_box, "sensitive", + G_BINDING_SYNC_CREATE); + + g_settings_bind (self->keyboard_settings, KEY_BOUNCEKEYS_BEEP_REJECT, + self->bouncekeys_beep_rejected_check, "active", + G_SETTINGS_BIND_NO_SENSITIVITY); + g_object_bind_property (self->bouncekeys_switch, "active", + self->bouncekeys_beep_rejected_check, "sensitive", + G_BINDING_SYNC_CREATE); +} + +CcTypingDialog * +cc_typing_dialog_new (void) +{ + return g_object_new (cc_typing_dialog_get_type (), + "use-header-bar", TRUE, + NULL); +} diff --git a/panels/universal-access/cc-typing-dialog.h b/panels/universal-access/cc-typing-dialog.h new file mode 100644 index 0000000..dfe0498 --- /dev/null +++ b/panels/universal-access/cc-typing-dialog.h @@ -0,0 +1,29 @@ +/* + * 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 <gtk/gtk.h> + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE (CcTypingDialog, cc_typing_dialog, CC, TYPING_DIALOG, GtkDialog) + +CcTypingDialog *cc_typing_dialog_new (void); + +G_END_DECLS diff --git a/panels/universal-access/cc-typing-dialog.ui b/panels/universal-access/cc-typing-dialog.ui new file mode 100644 index 0000000..cf1ee25 --- /dev/null +++ b/panels/universal-access/cc-typing-dialog.ui @@ -0,0 +1,381 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <template class="CcTypingDialog" parent="GtkDialog"> + <property name="title" translatable="yes">Typing Assist</property> + <property name="resizable">False</property> + <property name="modal">True</property> + <property name="use_header_bar">1</property> + <child> + <object class="GtkBox"> + <property name="margin_start">12</property> + <property name="margin_end">12</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkGrid"> + <property name="valign">start</property> + <property name="margin_start">12</property> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <property name="margin_bottom">12</property> + <property name="orientation">vertical</property> + <property name="row_spacing">18</property> + <property name="column_spacing">24</property> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Sticky Keys</property> + <property name="mnemonic_widget">stickykeys_switch</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel" id="sticky_keys_description"> + <property name="xalign">0</property> + <property name="label" translatable="yes">Treats a sequence of modifier keys as a key combination</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="margin_start">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkCheckButton" id="stickykeys_disable_two_keys_check"> + <property name="label" translatable="yes">_Disable if two keys are pressed together</property> + <property name="sensitive">False</property> + <property name="valign">start</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkCheckButton" id="stickykeys_beep_modifier_check"> + <property name="label" translatable="yes">Beep when a _modifier key is pressed</property> + <property name="sensitive">False</property> + <property name="valign">start</property> + <property name="use_underline">True</property> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <layout> + <property name="column">0</property> + <property name="row">2</property> + </layout> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="use_underline">True</property> + <property name="label" translatable="yes">S_low Keys</property> + <property name="mnemonic_widget">slowkeys_switch</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel" id="slow_keys_description"> + <property name="xalign">0</property> + <property name="label" translatable="yes">Puts a delay between when a key is pressed and when it is accepted</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="margin_start">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="slowkeys_delay_box"> + <property name="sensitive">True</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">A_cceptance delay:</property> + <property name="use_underline">True</property> + <property name="justify">center</property> + <property name="mnemonic_widget">slowkeys_delay_scale</property> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="xalign">1</property> + <property name="label" translatable="yes" context="slow keys delay">Short</property> + <attributes> + <attribute name="scale" value="0.83"/> + </attributes> + </object> + </child> + <child> + <object class="GtkScale" id="slowkeys_delay_scale"> + <property name="adjustment">slowkeys_delay_adjustment</property> + <property name="draw_value">False</property> + <property name="hexpand">True</property> + <accessibility> + <property name="label" translatable="yes">Slow keys typing delay</property> + </accessibility> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" context="slow keys delay">Long</property> + <attributes> + <attribute name="scale" value="0.83"/> + </attributes> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkCheckButton" id="slowkeys_beep_pressed_check"> + <property name="label" translatable="yes">Beep when a key is pr_essed</property> + <property name="active">True</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkCheckButton" id="slowkeys_beep_accepted_check"> + <property name="label" translatable="yes">Beep when a key is _accepted</property> + <property name="use_underline">True</property> + <property name="active">True</property> + </object> + </child> + <child> + <object class="GtkCheckButton" id="slowkeys_beep_rejected_check"> + <property name="label" translatable="yes">Beep when a key is _rejected</property> + <property name="use_underline">True</property> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <layout> + <property name="column">0</property> + <property name="row">3</property> + </layout> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Bounce Keys</property> + <property name="mnemonic_widget">bouncekeys_switch</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel" id="bounce_keys_description"> + <property name="xalign">0</property> + <property name="label" translatable="yes">Ignores fast duplicate keypresses</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="valign">start</property> + <property name="margin_start">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="bouncekeys_delay_box"> + <property name="sensitive">True</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">A_cceptance delay:</property> + <property name="use_underline">True</property> + <property name="justify">center</property> + <property name="mnemonic_widget">bouncekeys_delay_scale</property> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="xalign">1</property> + <property name="label" translatable="yes" context="bounce keys delay">Short</property> + <attributes> + <attribute name="scale" value="0.83"/> + </attributes> + </object> + </child> + <child> + <object class="GtkScale" id="bouncekeys_delay_scale"> + <property name="adjustment">bouncekeys_delay_adjustment</property> + <property name="draw_value">False</property> + <property name="hexpand">True</property> + <accessibility> + <property name="label" translatable="yes">Bounce keys typing delay</property> + </accessibility> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" context="bounce keys delay">Long</property> + <attributes> + <attribute name="scale" value="0.83"/> + </attributes> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkCheckButton" id="bouncekeys_beep_rejected_check"> + <property name="label" translatable="yes">Beep when a key is _rejected</property> + <property name="sensitive">False</property> + <property name="use_underline">True</property> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkSwitch" id="stickykeys_switch"> + <property name="halign">end</property> + <property name="valign">start</property> + <property name="hexpand">True</property> + <accessibility> + <relation name="described-by">sticky_keys_description</relation> + </accessibility> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + </object> + </child> + <child> + <object class="GtkSwitch" id="slowkeys_switch"> + <property name="halign">end</property> + <property name="valign">start</property> + <property name="hexpand">True</property> + <accessibility> + <relation name="described-by">slow_keys_description</relation> + </accessibility> + <layout> + <property name="column">1</property> + <property name="row">2</property> + </layout> + </object> + </child> + <child> + <object class="GtkSwitch" id="bouncekeys_switch"> + <property name="halign">end</property> + <property name="valign">start</property> + <property name="hexpand">True</property> + <accessibility> + <relation name="described-by">bounce_keys_description</relation> + </accessibility> + <layout> + <property name="column">1</property> + <property name="row">3</property> + </layout> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> + <child> + <object class="GtkLabel"> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Enable by Keyboard</property> + <property name="mnemonic_widget">keyboard_toggle_switch</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel" id="keyboard_toggle_description"> + <property name="xalign">0</property> + <property name="label" translatable="yes">Turn accessibility features on and off using the keyboard</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkSwitch" id="keyboard_toggle_switch"> + <property name="halign">end</property> + <property name="valign">start</property> + <property name="hexpand">True</property> + <accessibility> + <relation name="described-by">keyboard_toggle_description</relation> + </accessibility> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> + </object> + </child> + </object> + </child> + </object> + </child> + </template> + <object class="GtkAdjustment" id="bouncekeys_delay_adjustment"> + <property name="upper">900</property> + <property name="value">0.5</property> + <property name="step_increment">10</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="slowkeys_delay_adjustment"> + <property name="upper">500</property> + <property name="value">0.5</property> + <property name="step_increment">10</property> + <property name="page_increment">10</property> + </object> +</interface> diff --git a/panels/universal-access/cc-ua-panel.c b/panels/universal-access/cc-ua-panel.c new file mode 100644 index 0000000..75cf893 --- /dev/null +++ b/panels/universal-access/cc-ua-panel.c @@ -0,0 +1,574 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2010 Intel, Inc + * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com> + * + * 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, see <http://www.gnu.org/licenses/>. + * + * Authors: Thomas Wood <thomas.wood@intel.com> + * Rodrigo Moya <rodrigo@gnome.org> + * + */ + +#include <config.h> + +#include <math.h> +#include <glib/gi18n-lib.h> +#include <gdesktop-enums.h> + +#include "cc-ua-panel.h" +#include "cc-ua-resources.h" +#include "cc-cursor-blinking-dialog.h" +#include "cc-cursor-size-dialog.h" +#include "cc-pointing-dialog.h" +#include "cc-repeat-keys-dialog.h" +#include "cc-typing-dialog.h" +#include "cc-visual-alerts-dialog.h" +#include "cc-zoom-options-dialog.h" + +#define DPI_FACTOR_LARGE 1.25 +#define DPI_FACTOR_NORMAL 1.0 +#define HIGH_CONTRAST_THEME "HighContrast" + +/* shell settings */ +#define A11Y_SETTINGS "org.gnome.desktop.a11y" +#define KEY_ALWAYS_SHOW_STATUS "always-show-universal-access-status" + +/* a11y interface settings */ +#define A11Y_INTERFACE_SETTINGS "org.gnome.desktop.a11y.interface" +#define KEY_HIGH_CONTRAST "high-contrast" + +/* interface settings */ +#define INTERFACE_SETTINGS "org.gnome.desktop.interface" +#define KEY_TEXT_SCALING_FACTOR "text-scaling-factor" +#define KEY_GTK_THEME "gtk-theme" +#define KEY_ICON_THEME "icon-theme" +#define KEY_CURSOR_BLINKING "cursor-blink" +#define KEY_CURSOR_BLINKING_TIME "cursor-blink-time" +#define KEY_MOUSE_CURSOR_SIZE "cursor-size" +#define KEY_LOCATE_POINTER "locate-pointer" +#define KEY_ENABLE_ANIMATIONS "enable-animations" + +/* application settings */ +#define APPLICATION_SETTINGS "org.gnome.desktop.a11y.applications" +#define KEY_SCREEN_KEYBOARD_ENABLED "screen-keyboard-enabled" +#define KEY_SCREEN_MAGNIFIER_ENABLED "screen-magnifier-enabled" +#define KEY_SCREEN_READER_ENABLED "screen-reader-enabled" + +/* wm settings */ +#define WM_SETTINGS "org.gnome.desktop.wm.preferences" +#define KEY_VISUAL_BELL_ENABLED "visual-bell" + +/* keyboard settings */ +#define KEYBOARD_SETTINGS "org.gnome.desktop.a11y.keyboard" +#define KEY_KEYBOARD_TOGGLE "enable" +#define KEY_STICKYKEYS_ENABLED "stickykeys-enable" +#define KEY_STICKYKEYS_TWO_KEY_OFF "stickykeys-two-key-off" +#define KEY_STICKYKEYS_MODIFIER_BEEP "stickykeys-modifier-beep" +#define KEY_SLOWKEYS_ENABLED "slowkeys-enable" +#define KEY_SLOWKEYS_DELAY "slowkeys-delay" +#define KEY_SLOWKEYS_BEEP_PRESS "slowkeys-beep-press" +#define KEY_SLOWKEYS_BEEP_ACCEPT "slowkeys-beep-accept" +#define KEY_SLOWKEYS_BEEP_REJECT "slowkeys-beep-reject" +#define KEY_BOUNCEKEYS_ENABLED "bouncekeys-enable" +#define KEY_BOUNCEKEYS_DELAY "bouncekeys-delay" +#define KEY_BOUNCEKEYS_BEEP_REJECT "bouncekeys-beep-reject" +#define KEY_MOUSEKEYS_ENABLED "mousekeys-enable" +#define KEY_TOGGLEKEYS_ENABLED "togglekeys-enable" + +/* keyboard desktop settings */ +#define KEYBOARD_DESKTOP_SETTINGS "org.gnome.desktop.peripherals.keyboard" +#define KEY_REPEAT_KEYS "repeat" + +/* mouse settings */ +#define MOUSE_SETTINGS "org.gnome.desktop.a11y.mouse" +#define KEY_SECONDARY_CLICK_ENABLED "secondary-click-enabled" +#define KEY_SECONDARY_CLICK_TIME "secondary-click-time" +#define KEY_DWELL_CLICK_ENABLED "dwell-click-enabled" +#define KEY_DWELL_TIME "dwell-time" +#define KEY_DWELL_THRESHOLD "dwell-threshold" + +#define MOUSE_PERIPHERAL_SETTINGS "org.gnome.desktop.peripherals.mouse" +#define KEY_DOUBLE_CLICK_DELAY "double-click" + +struct _CcUaPanel +{ + CcPanel parent_instance; + + GtkLabel *accessx_label; + AdwActionRow *accessx_row; + GtkLabel *click_assist_label; + AdwActionRow *click_assist_row; + GtkLabel *cursor_blinking_label; + AdwActionRow *cursor_blinking_row; + GtkLabel *cursor_size_label; + AdwActionRow *cursor_size_row; + GtkScale *double_click_delay_scale; + GtkSwitch *enable_animations_switch; + GtkSwitch *highcontrast_enable_switch; + GtkSwitch *large_text_enable_switch; + GtkSwitch *locate_pointer_enable_switch; + GtkSwitch *mouse_keys_enable_switch; + GtkLabel *repeat_keys_label; + AdwActionRow *repeat_keys_row; + GtkSwitch *screen_keyboard_enable_switch; + GtkSwitch *screen_reader_switch; + AdwActionRow *screen_reader_row; + GtkSwitch *show_status_switch; + GtkSwitch *sound_keys_switch; + AdwActionRow *sound_keys_row; + GtkLabel *visual_alerts_label; + AdwActionRow *visual_alerts_row; + GtkLabel *zoom_label; + AdwActionRow *zoom_row; + + GSettings *wm_settings; + GSettings *a11y_settings; + GSettings *a11y_interface_settings; + GSettings *interface_settings; + GSettings *kb_settings; + GSettings *mouse_settings; + GSettings *kb_desktop_settings; + GSettings *application_settings; + GSettings *gds_mouse_settings; +}; + +CC_PANEL_REGISTER (CcUaPanel, cc_ua_panel) + +static void +run_dialog (CcUaPanel *self, GtkDialog *dialog) +{ + GtkNative *native = gtk_widget_get_native (GTK_WIDGET (self)); + + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (native)); + gtk_window_present (GTK_WINDOW (dialog)); +} + +static void +activate_row (CcUaPanel *self, AdwActionRow *row) +{ + if (row == self->zoom_row) + { + run_dialog (self, GTK_DIALOG (cc_zoom_options_dialog_new ())); + } + else if (row == self->cursor_size_row) + { + run_dialog (self, GTK_DIALOG (cc_cursor_size_dialog_new ())); + } + else if (row == self->visual_alerts_row) + { + run_dialog (self, GTK_DIALOG (cc_visual_alerts_dialog_new ())); + } + else if (row == self->repeat_keys_row) + { + run_dialog (self, GTK_DIALOG (cc_repeat_keys_dialog_new ())); + } + else if (row == self->cursor_blinking_row) + { + run_dialog (self, GTK_DIALOG (cc_cursor_blinking_dialog_new ())); + } + else if (row == self->accessx_row) + { + run_dialog (self, GTK_DIALOG (cc_typing_dialog_new ())); + } + else if (row == self->click_assist_row) + { + run_dialog (self, GTK_DIALOG (cc_pointing_dialog_new ())); + } +} + +static void +cc_ua_panel_dispose (GObject *object) +{ + CcUaPanel *self = CC_UA_PANEL (object); + + g_clear_object (&self->wm_settings); + g_clear_object (&self->a11y_settings); + g_clear_object (&self->a11y_interface_settings); + g_clear_object (&self->interface_settings); + g_clear_object (&self->kb_settings); + g_clear_object (&self->mouse_settings); + g_clear_object (&self->kb_desktop_settings); + g_clear_object (&self->application_settings); + g_clear_object (&self->gds_mouse_settings); + + G_OBJECT_CLASS (cc_ua_panel_parent_class)->dispose (object); +} + +static const char * +cc_ua_panel_get_help_uri (CcPanel *panel) +{ + return "help:gnome-help/a11y"; +} + +static void +cc_ua_panel_class_init (CcUaPanelClass *klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + CcPanelClass *panel_class = CC_PANEL_CLASS (klass); + + panel_class->get_help_uri = cc_ua_panel_get_help_uri; + + object_class->dispose = cc_ua_panel_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/universal-access/cc-ua-panel.ui"); + + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, accessx_label); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, accessx_row); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, click_assist_label); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, click_assist_row); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, cursor_blinking_label); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, cursor_blinking_row); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, cursor_size_label); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, cursor_size_row); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, double_click_delay_scale); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, enable_animations_switch); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, highcontrast_enable_switch); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, large_text_enable_switch); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, locate_pointer_enable_switch); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, mouse_keys_enable_switch); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, repeat_keys_label); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, repeat_keys_row); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, screen_keyboard_enable_switch); + 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_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); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, zoom_label); + gtk_widget_class_bind_template_child (widget_class, CcUaPanel, zoom_row); + gtk_widget_class_bind_template_callback (widget_class, activate_row); +} + +/* seeing section */ + +static gboolean +is_large_factor (gdouble factor) +{ + return (factor > DPI_FACTOR_NORMAL); +} + +static gboolean +get_large_text_mapping (GValue *value, + GVariant *variant, + gpointer user_data) +{ + gdouble factor; + + factor = g_variant_get_double (variant); + g_value_set_boolean (value, is_large_factor (factor)); + + return TRUE; +} + +static GVariant * +set_large_text_mapping (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) +{ + gboolean large; + GSettings *settings = user_data; + GVariant *ret = NULL; + + large = g_value_get_boolean (value); + if (large) + ret = g_variant_new_double (DPI_FACTOR_LARGE); + else + g_settings_reset (settings, KEY_TEXT_SCALING_FACTOR); + + return ret; +} + +static gboolean +get_contrast_mapping (GValue *value, + GVariant *variant, + gpointer user_data) +{ + gboolean hc; + + hc = g_variant_get_boolean (variant); + g_value_set_boolean (value, hc); + + return TRUE; +} + +static GVariant * +set_contrast_mapping (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) +{ + gboolean hc; + CcUaPanel *self = user_data; + + hc = g_value_get_boolean (value); + if (hc) + { + g_settings_set_string (self->interface_settings, KEY_GTK_THEME, HIGH_CONTRAST_THEME); + } + else + { + g_settings_reset (self->interface_settings, KEY_GTK_THEME); + g_settings_reset (self->interface_settings, KEY_ICON_THEME); + } + + return g_variant_new_boolean (hc); +} + +static gboolean +on_off_label_mapping_get (GValue *value, + GVariant *variant, + gpointer user_data) +{ + g_value_set_string (value, g_variant_get_boolean (variant) ? _("On") : _("Off")); + + return TRUE; +} + +static gboolean +cursor_size_label_mapping_get (GValue *value, + GVariant *variant, + gpointer user_data) +{ + char *label; + int cursor_size; + + cursor_size = g_variant_get_int32 (variant); + + switch (cursor_size) + { + case 24: + /* translators: the labels will read: + * Cursor Size: Default */ + label = g_strdup (C_("cursor size", "Default")); + break; + case 32: + label = g_strdup (C_("cursor size", "Medium")); + break; + case 48: + label = g_strdup (C_("cursor size", "Large")); + break; + case 64: + label = g_strdup (C_("cursor size", "Larger")); + break; + case 96: + label = g_strdup (C_("cursor size", "Largest")); + break; + default: + label = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, + "%d pixel", + "%d pixels", + cursor_size), + cursor_size); + break; + } + + g_value_take_string (value, label); + + return TRUE; +} + +static void +cc_ua_panel_init_status (CcUaPanel *self) +{ + g_settings_bind (self->a11y_settings, KEY_ALWAYS_SHOW_STATUS, + self->show_status_switch, "active", + G_SETTINGS_BIND_DEFAULT); +} + +static void +cc_ua_panel_init_seeing (CcUaPanel *self) +{ + g_settings_bind_with_mapping (self->a11y_interface_settings, KEY_HIGH_CONTRAST, + self->highcontrast_enable_switch, + "active", G_SETTINGS_BIND_DEFAULT, + get_contrast_mapping, + set_contrast_mapping, + self, + NULL); + + /* enable animation */ + g_settings_bind (self->interface_settings, KEY_ENABLE_ANIMATIONS, + self->enable_animations_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + + /* large text */ + + g_settings_bind_with_mapping (self->interface_settings, KEY_TEXT_SCALING_FACTOR, + self->large_text_enable_switch, + "active", G_SETTINGS_BIND_DEFAULT, + get_large_text_mapping, + set_large_text_mapping, + self->interface_settings, + NULL); + + /* screen reader */ + + g_settings_bind (self->application_settings, "screen-reader-enabled", + 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 */ + + g_settings_bind_with_mapping (self->interface_settings, KEY_MOUSE_CURSOR_SIZE, // FIXME + self->cursor_size_label, + "label", G_SETTINGS_BIND_GET, + cursor_size_label_mapping_get, + NULL, NULL, NULL); + + /* zoom */ + + g_settings_bind_with_mapping (self->application_settings, "screen-magnifier-enabled", + self->zoom_label, + "label", G_SETTINGS_BIND_GET, + on_off_label_mapping_get, + NULL, NULL, NULL); +} + +/* hearing/sound section */ + +static void +cc_ua_panel_init_hearing (CcUaPanel *self) +{ + g_settings_bind_with_mapping (self->wm_settings, KEY_VISUAL_BELL_ENABLED, + self->visual_alerts_label, + "label", G_SETTINGS_BIND_GET, + on_off_label_mapping_get, + NULL, NULL, NULL); +} + +/* typing/keyboard section */ +static void +on_repeat_keys_toggled (CcUaPanel *self) +{ + gboolean on; + + on = g_settings_get_boolean (self->kb_desktop_settings, KEY_REPEAT_KEYS); + + gtk_label_set_text (self->repeat_keys_label, on ? _("On") : _("Off")); +} + +static void +on_cursor_blinking_toggled (CcUaPanel *self) +{ + gboolean on; + + on = g_settings_get_boolean (self->interface_settings, KEY_CURSOR_BLINKING); + + gtk_label_set_text (self->cursor_blinking_label, on ? _("On") : _("Off")); +} + +static void +update_accessx_label (CcUaPanel *self) +{ + gboolean on; + + on = g_settings_get_boolean (self->kb_settings, KEY_STICKYKEYS_ENABLED) || + g_settings_get_boolean (self->kb_settings, KEY_SLOWKEYS_ENABLED) || + g_settings_get_boolean (self->kb_settings, KEY_BOUNCEKEYS_ENABLED); + + gtk_label_set_text (self->accessx_label, on ? _("On") : _("Off")); +} + +static void +cc_ua_panel_init_keyboard (CcUaPanel *self) +{ + /* on-screen keyboard */ + g_settings_bind (self->application_settings, KEY_SCREEN_KEYBOARD_ENABLED, + self->screen_keyboard_enable_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + /* Repeat keys */ + g_signal_connect_object (self->kb_desktop_settings, "changed", + G_CALLBACK (on_repeat_keys_toggled), self, G_CONNECT_SWAPPED); + on_repeat_keys_toggled (self); + + /* Cursor Blinking */ + g_signal_connect_object (self->interface_settings, "changed", + G_CALLBACK (on_cursor_blinking_toggled), self, G_CONNECT_SWAPPED); + on_cursor_blinking_toggled (self); + + /* accessx */ + g_signal_connect_object (self->kb_settings, "changed", + G_CALLBACK (update_accessx_label), self, G_CONNECT_SWAPPED); + update_accessx_label (self); +} + +/* mouse/pointing & clicking section */ +static void +update_click_assist_label (CcUaPanel *self) +{ + gboolean on; + + on = g_settings_get_boolean (self->mouse_settings, KEY_SECONDARY_CLICK_ENABLED) || + g_settings_get_boolean (self->mouse_settings, KEY_DWELL_CLICK_ENABLED); + + gtk_label_set_text (self->click_assist_label, on ? _("On") : _("Off")); +} + + +static void +cc_ua_panel_init_mouse (CcUaPanel *self) +{ + g_settings_bind (self->kb_settings, KEY_MOUSEKEYS_ENABLED, + self->mouse_keys_enable_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (self->interface_settings, KEY_LOCATE_POINTER, + self->locate_pointer_enable_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_signal_connect_object (self->mouse_settings, "changed", + G_CALLBACK (update_click_assist_label), self, G_CONNECT_SWAPPED); + update_click_assist_label (self); + + g_settings_bind (self->gds_mouse_settings, "double-click", + gtk_range_get_adjustment (GTK_RANGE (self->double_click_delay_scale)), "value", + G_SETTINGS_BIND_DEFAULT); + + gtk_scale_add_mark (GTK_SCALE (self->double_click_delay_scale), 400, GTK_POS_BOTTOM, NULL); +} + +static void +cc_ua_panel_init (CcUaPanel *self) +{ + g_resources_register (cc_universal_access_get_resource ()); + + gtk_widget_init_template (GTK_WIDGET (self)); + + self->interface_settings = g_settings_new (INTERFACE_SETTINGS); + self->a11y_interface_settings = g_settings_new (A11Y_INTERFACE_SETTINGS); + self->a11y_settings = g_settings_new (A11Y_SETTINGS); + self->wm_settings = g_settings_new (WM_SETTINGS); + self->kb_settings = g_settings_new (KEYBOARD_SETTINGS); + self->kb_desktop_settings = g_settings_new (KEYBOARD_DESKTOP_SETTINGS); + self->mouse_settings = g_settings_new (MOUSE_SETTINGS); + self->gds_mouse_settings = g_settings_new (MOUSE_PERIPHERAL_SETTINGS); + self->application_settings = g_settings_new (APPLICATION_SETTINGS); + + cc_ua_panel_init_status (self); + cc_ua_panel_init_seeing (self); + cc_ua_panel_init_hearing (self); + cc_ua_panel_init_keyboard (self); + cc_ua_panel_init_mouse (self); +} diff --git a/panels/universal-access/cc-ua-panel.h b/panels/universal-access/cc-ua-panel.h new file mode 100644 index 0000000..6d925fa --- /dev/null +++ b/panels/universal-access/cc-ua-panel.h @@ -0,0 +1,31 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2010 Intel, Inc + * + * 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, see <http://www.gnu.org/licenses/>. + * + * Author: Thomas Wood <thomas.wood@intel.com> + * + */ + +#pragma once + +#include <shell/cc-panel.h> + +G_BEGIN_DECLS + +#define CC_TYPE_UA_PANEL (cc_ua_panel_get_type ()) +G_DECLARE_FINAL_TYPE (CcUaPanel, cc_ua_panel, CC, UA_PANEL, CcPanel) + +G_END_DECLS diff --git a/panels/universal-access/cc-ua-panel.ui b/panels/universal-access/cc-ua-panel.ui new file mode 100644 index 0000000..fb01d98 --- /dev/null +++ b/panels/universal-access/cc-ua-panel.ui @@ -0,0 +1,308 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <object class="GtkAdjustment" id="double_click_delay_adjustment"> + <property name="lower">100</property> + <property name="upper">1000</property> + <property name="value">400</property> + <property name="step_increment">100</property> + <property name="page_increment">100</property> + </object> + <template class="CcUaPanel" parent="CcPanel"> + <child type="content"> + <object class="AdwPreferencesPage"> + <child> + <object class="AdwPreferencesGroup"> + <child> + <object class="AdwActionRow"> + <property name="title" translatable="yes">_Always Show Accessibility Menu</property> + <property name="use-underline">True</property> + <property name="activatable-widget">show_status_switch</property> + <child type="suffix"> + <object class="GtkSwitch" id="show_status_switch"> + <property name="valign">center</property> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="AdwPreferencesGroup"> + <property name="title" translatable="yes">Seeing</property> + <child> + <object class="AdwActionRow" id="highcontrast_row"> + <property name="title" translatable="yes">_High Contrast</property> + <property name="use-underline">True</property> + <property name="activatable-widget">highcontrast_enable_switch</property> + <child type="suffix"> + <object class="GtkSwitch" id="highcontrast_enable_switch"> + <property name="valign">center</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow"> + <property name="title" translatable="yes">_Large Text</property> + <property name="use-underline">True</property> + <property name="activatable-widget">large_text_enable_switch</property> + <child type="suffix"> + <object class="GtkSwitch" id="large_text_enable_switch"> + <property name="valign">center</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow"> + <property name="title" translatable="yes">Enable A_nimations</property> + <property name="use-underline">True</property> + <property name="activatable-widget">enable_animations_switch</property> + <child type="suffix"> + <object class="GtkSwitch" id="enable_animations_switch"> + <property name="valign">center</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow" id="screen_reader_row"> + <property name="title" translatable="yes">Screen _Reader</property> + <property name="subtitle" translatable="yes">The screen reader reads displayed text as you move the focus.</property> + <property name="use-underline">True</property> + <property name="activatable-widget">screen_reader_switch</property> + <child type="suffix"> + <object class="GtkSwitch" id="screen_reader_switch"> + <property name="valign">center</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow" id="sound_keys_row"> + <property name="title" translatable="yes">_Sound Keys</property> + <property name="subtitle" translatable="yes">Beep when Num Lock or Caps Lock are turned on or off.</property> + <property name="use-underline">True</property> + <property name="activatable-widget">sound_keys_switch</property> + <child type="suffix"> + <object class="GtkSwitch" id="sound_keys_switch"> + <property name="valign">center</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow" id="cursor_size_row"> + <property name="title" translatable="yes">C_ursor Size</property> + <property name="use-underline">True</property> + <property name="activatable">True</property> + <signal name="activated" handler="activate_row" swapped="yes"/> + <child type="suffix"> + <object class="GtkLabel" id="cursor_size_label"> + <property name="valign">center</property> + <property name="xalign">1</property> + </object> + </child> + <child type="suffix"> + <object class="GtkImage"> + <property name="valign">center</property> + <property name="icon-name">go-next-symbolic</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow" id="zoom_row"> + <property name="title" translatable="yes">_Zoom</property> + <property name="use-underline">True</property> + <property name="activatable">True</property> + <signal name="activated" handler="activate_row" swapped="yes"/> + <child type="suffix"> + <object class="GtkLabel" id="zoom_label"> + <property name="valign">center</property> + <property name="xalign">1</property> + </object> + </child> + <child type="suffix"> + <object class="GtkImage"> + <property name="valign">center</property> + <property name="icon-name">go-next-symbolic</property> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="AdwPreferencesGroup"> + <property name="title" translatable="yes">Hearing</property> + <child> + <object class="AdwActionRow" id="visual_alerts_row"> + <property name="title" translatable="yes">_Visual Alerts</property> + <property name="use-underline">True</property> + <property name="activatable">True</property> + <signal name="activated" handler="activate_row" swapped="yes"/> + <child type="suffix"> + <object class="GtkLabel" id="visual_alerts_label"> + <property name="valign">center</property> + <property name="xalign">1</property> + </object> + </child> + <child type="suffix"> + <object class="GtkImage"> + <property name="valign">center</property> + <property name="icon-name">go-next-symbolic</property> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="AdwPreferencesGroup"> + <property name="title" translatable="yes">Typing</property> + <child> + <object class="AdwActionRow"> + <property name="title" translatable="yes">Screen _Keyboard</property> + <property name="use-underline">True</property> + <property name="activatable-widget">screen_keyboard_enable_switch</property> + <child type="suffix"> + <object class="GtkSwitch" id="screen_keyboard_enable_switch"> + <property name="valign">center</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow" id="repeat_keys_row"> + <property name="title" translatable="yes">R_epeat Keys</property> + <property name="use-underline">True</property> + <property name="activatable">True</property> + <signal name="activated" handler="activate_row" swapped="yes"/> + <child type="suffix"> + <object class="GtkLabel" id="repeat_keys_label"> + <property name="valign">center</property> + <property name="xalign">1</property> + </object> + </child> + <child type="suffix"> + <object class="GtkImage"> + <property name="valign">center</property> + <property name="icon-name">go-next-symbolic</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow" id="cursor_blinking_row"> + <property name="title" translatable="yes">Cursor _Blinking</property> + <property name="use-underline">True</property> + <property name="activatable">True</property> + <signal name="activated" handler="activate_row" swapped="yes"/> + <child type="suffix"> + <object class="GtkLabel" id="cursor_blinking_label"> + <property name="valign">center</property> + <property name="xalign">1</property> + </object> + </child> + <child type="suffix"> + <object class="GtkImage"> + <property name="valign">center</property> + <property name="icon-name">go-next-symbolic</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow" id="accessx_row"> + <property name="title" translatable="yes">_Typing Assist (AccessX)</property> + <property name="use-underline">True</property> + <property name="activatable">True</property> + <signal name="activated" handler="activate_row" swapped="yes"/> + <child type="suffix"> + <object class="GtkLabel" id="accessx_label"> + <property name="valign">center</property> + <property name="xalign">1</property> + </object> + </child> + <child type="suffix"> + <object class="GtkImage"> + <property name="valign">center</property> + <property name="icon-name">go-next-symbolic</property> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="AdwPreferencesGroup"> + <property name="title" translatable="yes">Pointing &amp; Clicking</property> + <child> + <object class="AdwActionRow"> + <property name="title" translatable="yes">_Mouse Keys</property> + <property name="use-underline">True</property> + <property name="activatable-widget">mouse_keys_enable_switch</property> + <child type="suffix"> + <object class="GtkSwitch" id="mouse_keys_enable_switch"> + <property name="valign">center</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow"> + <property name="title" translatable="yes">_Locate Pointer</property> + <property name="use-underline">True</property> + <property name="activatable-widget">locate_pointer_enable_switch</property> + <child type="suffix"> + <object class="GtkSwitch" id="locate_pointer_enable_switch"> + <property name="valign">center</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow" id="click_assist_row"> + <property name="title" translatable="yes">_Click Assist</property> + <property name="use-underline">True</property> + <property name="activatable">True</property> + <signal name="activated" handler="activate_row" swapped="yes"/> + <child type="suffix"> + <object class="GtkLabel" id="click_assist_label"> + <property name="valign">center</property> + <property name="xalign">1</property> + </object> + </child> + <child type="suffix"> + <object class="GtkImage"> + <property name="valign">center</property> + <property name="icon-name">go-next-symbolic</property> + </object> + </child> + </object> + </child> + <child> + <object class="AdwActionRow" id="double_click_delay_row"> + <property name="title" translatable="yes">_Double-Click Delay</property> + <property name="use-underline">True</property> + <signal name="activated" handler="activate_row" swapped="yes"/> + <child> + <object class="GtkScale" id="double_click_delay_scale"> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="adjustment">double_click_delay_adjustment</property> + <property name="draw_value">False</property> + <accessibility> + <property name="label" translatable="yes">Double-Click Delay</property> + </accessibility> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + </template> +</interface> diff --git a/panels/universal-access/cc-visual-alerts-dialog.c b/panels/universal-access/cc-visual-alerts-dialog.c new file mode 100644 index 0000000..398753d --- /dev/null +++ b/panels/universal-access/cc-visual-alerts-dialog.c @@ -0,0 +1,144 @@ +/* + * 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 <gdesktop-enums.h> + +#include "cc-visual-alerts-dialog.h" + +#define WM_SETTINGS "org.gnome.desktop.wm.preferences" +#define KEY_VISUAL_BELL_ENABLED "visual-bell" +#define KEY_VISUAL_BELL_TYPE "visual-bell-type" + +struct _CcVisualAlertsDialog +{ + GtkDialog parent; + + GtkSwitch *enable_switch; + GtkCheckButton *screen_radio; + GtkButton *test_button; + GtkCheckButton *window_radio; + + GSettings *wm_settings; +}; + +G_DEFINE_TYPE (CcVisualAlertsDialog, cc_visual_alerts_dialog, GTK_TYPE_DIALOG); + +static void +visual_bell_type_notify_cb (CcVisualAlertsDialog *self) +{ + GtkCheckButton *widget; + GDesktopVisualBellType type; + + type = g_settings_get_enum (self->wm_settings, KEY_VISUAL_BELL_TYPE); + + if (type == G_DESKTOP_VISUAL_BELL_FRAME_FLASH) + widget = self->window_radio; + else + widget = self->screen_radio; + + gtk_check_button_set_active (widget, TRUE); +} + +static void +visual_bell_type_toggle_cb (CcVisualAlertsDialog *self) +{ + gboolean frame_flash; + GDesktopVisualBellType type; + + frame_flash = gtk_check_button_get_active (GTK_CHECK_BUTTON (self->window_radio)); + + if (frame_flash) + type = G_DESKTOP_VISUAL_BELL_FRAME_FLASH; + else + type = G_DESKTOP_VISUAL_BELL_FULLSCREEN_FLASH; + g_settings_set_enum (self->wm_settings, KEY_VISUAL_BELL_TYPE, type); +} + +static void +test_flash (CcVisualAlertsDialog *self) +{ + GtkNative *native = gtk_widget_get_native (GTK_WIDGET (self)); + GdkSurface *surface = gtk_native_get_surface (native); + + gdk_surface_beep (surface); +} + +static void +cc_visual_alerts_dialog_dispose (GObject *object) +{ + CcVisualAlertsDialog *self = CC_VISUAL_ALERTS_DIALOG (object); + + g_clear_object (&self->wm_settings); + + G_OBJECT_CLASS (cc_visual_alerts_dialog_parent_class)->dispose (object); +} + +static void +cc_visual_alerts_dialog_class_init (CcVisualAlertsDialogClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->dispose = cc_visual_alerts_dialog_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/universal-access/cc-visual-alerts-dialog.ui"); + + gtk_widget_class_bind_template_child (widget_class, CcVisualAlertsDialog, enable_switch); + gtk_widget_class_bind_template_child (widget_class, CcVisualAlertsDialog, screen_radio); + gtk_widget_class_bind_template_child (widget_class, CcVisualAlertsDialog, test_button); + gtk_widget_class_bind_template_child (widget_class, CcVisualAlertsDialog, window_radio); +} + +static void +cc_visual_alerts_dialog_init (CcVisualAlertsDialog *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); + + self->wm_settings = g_settings_new (WM_SETTINGS); + + /* set the initial visual bell values */ + visual_bell_type_notify_cb (self); + + /* and listen */ + g_settings_bind (self->wm_settings, KEY_VISUAL_BELL_ENABLED, + self->enable_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_object_bind_property (self->enable_switch, "active", + self->window_radio, "sensitive", + G_BINDING_SYNC_CREATE); + + g_object_bind_property (self->enable_switch, "active", + self->screen_radio, "sensitive", + G_BINDING_SYNC_CREATE); + g_signal_connect_object (self->wm_settings, "changed::" KEY_VISUAL_BELL_TYPE, + G_CALLBACK (visual_bell_type_notify_cb), self, G_CONNECT_SWAPPED); + g_signal_connect_object (self->window_radio, + "toggled", G_CALLBACK (visual_bell_type_toggle_cb), self, G_CONNECT_SWAPPED); + + g_signal_connect_object (self->test_button, + "clicked", G_CALLBACK (test_flash), self, G_CONNECT_SWAPPED); +} + +CcVisualAlertsDialog * +cc_visual_alerts_dialog_new (void) +{ + return g_object_new (cc_visual_alerts_dialog_get_type (), + "use-header-bar", TRUE, + NULL); +} diff --git a/panels/universal-access/cc-visual-alerts-dialog.h b/panels/universal-access/cc-visual-alerts-dialog.h new file mode 100644 index 0000000..49add84 --- /dev/null +++ b/panels/universal-access/cc-visual-alerts-dialog.h @@ -0,0 +1,29 @@ +/* + * 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 <gtk/gtk.h> + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE (CcVisualAlertsDialog, cc_visual_alerts_dialog, CC, VISUAL_ALERTS_DIALOG, GtkDialog) + +CcVisualAlertsDialog *cc_visual_alerts_dialog_new (void); + +G_END_DECLS diff --git a/panels/universal-access/cc-visual-alerts-dialog.ui b/panels/universal-access/cc-visual-alerts-dialog.ui new file mode 100644 index 0000000..a162190 --- /dev/null +++ b/panels/universal-access/cc-visual-alerts-dialog.ui @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <template class="CcVisualAlertsDialog" parent="GtkDialog"> + <property name="title" translatable="yes">Visual Alerts</property> + <property name="resizable">False</property> + <property name="modal">True</property> + <property name="use_header_bar">1</property> + <child internal-child="headerbar"> + <object class="GtkHeaderBar"> + <property name="show_title_buttons">True</property> + <child> + <object class="GtkButton" id="test_button"> + <property name="label" translatable="yes">_Test flash</property> + <property name="use_underline">True</property> + <property name="valign">center</property> + <style> + <class name="text-button"/> + </style> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="margin_start">12</property> + <property name="margin_end">12</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child> + <object class="GtkLabel"> + <property name="margin_start">12</property> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Use a visual indication when an alert sound occurs.</property> + <property name="wrap">True</property> + </object> + </child> + <child> + <object class="GtkGrid"> + <property name="margin_start">12</property> + <property name="margin_end">6</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="row_spacing">12</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="hexpand">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Visual Alerts</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">enable_switch</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> + </object> + </child> + <child> + <object class="GtkSwitch" id="enable_switch"> + <property name="halign">end</property> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> + </object> + </child> + <child> + <object class="GtkCheckButton" id="screen_radio"> + <property name="label" translatable="yes">Flash the entire _screen</property> + <property name="group">window_radio</property> + <property name="use_underline">True</property> + <layout> + <property name="column">0</property> + <property name="row">2</property> + <property name="column-span">2</property> + </layout> + </object> + </child> + <child> + <object class="GtkCheckButton" id="window_radio"> + <property name="label" translatable="yes">Flash the entire _window</property> + <property name="active">True</property> + <property name="use_underline">True</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + <property name="column-span">2</property> + </layout> + </object> + </child> + </object> + </child> + </object> + </child> + </template> +</interface> diff --git a/panels/universal-access/cc-zoom-options-dialog.c b/panels/universal-access/cc-zoom-options-dialog.c new file mode 100644 index 0000000..1f06aa8 --- /dev/null +++ b/panels/universal-access/cc-zoom-options-dialog.c @@ -0,0 +1,553 @@ +/* + * Copyright 2011 Inclusive Design Research Centre, OCAD University. + * + * 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 + * + * Author: Joseph Scheuhammer <clown@alum.mit.edu> + */ + +#include "cc-zoom-options-dialog.h" +#include <gdk/gdk.h> +#include <glib/gi18n.h> +#include <string.h> + +#define POSITION_MODEL_VALUE_COLUMN 2 +#define FONT_SCALE 1.25 + +struct _CcZoomOptionsDialog +{ + GtkDialog parent; + + GSettings *settings; + GSettings *application_settings; + + GtkWidget *screen_position_combobox; + GtkWidget *follow_mouse_radio; + GtkWidget *screen_part_radio; + GtkWidget *centered_radio; + GtkWidget *push_radio; + GtkWidget *proportional_radio; + GtkWidget *extend_beyond_checkbox; + GtkWidget *brightness_slider; + GtkWidget *contrast_slider; + GtkWidget *crosshair_picker_color_button; + GtkWidget *magnifier_factor_spin; + GtkWidget *seeing_zoom_switch; + GtkWidget *crosshair_thickness_scale; + GtkWidget *grayscale_slider; + GtkWidget *crosshair_clip_checkbox; + GtkWidget *crosshair_length_slider; + GtkWidget *crosshair_enabled_switcher; + GtkWidget *inverse_enabled_switch; +}; + +G_DEFINE_TYPE (CcZoomOptionsDialog, cc_zoom_options_dialog, GTK_TYPE_DIALOG); + +static gchar *brightness_keys[] = { + "brightness-red", + "brightness-green", + "brightness-blue", + NULL +}; + +static gchar *contrast_keys[] = { + "contrast-red", + "contrast-green", + "contrast-blue", + NULL +}; + +static void set_enable_screen_part_ui (CcZoomOptionsDialog *self); +static void scale_label (GtkWidget *check, PangoAttrList *attrs); +static void xhairs_length_add_marks (CcZoomOptionsDialog *self, GtkScale *scale); +static void effects_slider_set_value (GtkRange *slider, GSettings *settings); +static void brightness_slider_notify_cb (CcZoomOptionsDialog *self, const gchar *key); +static void contrast_slider_notify_cb (CcZoomOptionsDialog *self, const gchar *key); +static void effects_slider_changed (CcZoomOptionsDialog *self, GtkRange *slider); + +static void +mouse_tracking_radio_toggled_cb (CcZoomOptionsDialog *self, GtkWidget *widget) +{ + if (!gtk_check_button_get_active (GTK_CHECK_BUTTON (widget))) + return; + + if (widget == self->centered_radio) + g_settings_set_string (self->settings, "mouse-tracking", "centered"); + else if (widget == self->proportional_radio) + g_settings_set_string (self->settings, "mouse-tracking", "proportional"); + else if (widget == self->push_radio) + g_settings_set_string (self->settings, "mouse-tracking", "push"); +} + +static void +mouse_tracking_notify_cb (CcZoomOptionsDialog *self) +{ + g_autofree gchar *tracking = NULL; + + tracking = g_settings_get_string (self->settings, "mouse-tracking"); + if (g_strcmp0 (tracking, "centered") == 0) + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->centered_radio), TRUE); + else if (g_strcmp0 (tracking, "proportional") == 0) + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->proportional_radio), TRUE); + else + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->push_radio), TRUE); +} + +static void +init_screen_part_section (CcZoomOptionsDialog *self, PangoAttrList *pango_attrs) +{ + gboolean lens_mode; + + /* Scale the labels of the toggles */ + scale_label (self->follow_mouse_radio, pango_attrs); + scale_label (self->screen_part_radio, pango_attrs); + scale_label (self->centered_radio, pango_attrs); + scale_label (self->push_radio, pango_attrs); + scale_label (self->proportional_radio, pango_attrs); + scale_label (self->extend_beyond_checkbox, pango_attrs); + + lens_mode = g_settings_get_boolean (self->settings, "lens-mode"); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->follow_mouse_radio), lens_mode); + gtk_check_button_set_active (GTK_CHECK_BUTTON (self->screen_part_radio), !lens_mode); + + set_enable_screen_part_ui (self); + + g_settings_bind (self->settings, "lens-mode", + self->follow_mouse_radio, "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (self->settings, "scroll-at-edges", + self->extend_beyond_checkbox, "active", + G_SETTINGS_BIND_DEFAULT); + + g_signal_connect_object (G_OBJECT (self->screen_part_radio), "toggled", + G_CALLBACK (set_enable_screen_part_ui), self, G_CONNECT_SWAPPED); + + mouse_tracking_notify_cb (self); + g_signal_connect_object (G_OBJECT (self->settings), "changed::mouse-tracking", + G_CALLBACK (mouse_tracking_notify_cb), self, G_CONNECT_SWAPPED); +} + +static void +set_enable_screen_part_ui (CcZoomOptionsDialog *self) +{ + gboolean screen_part; + + /* If the "screen part" radio is not checked, then the "follow mouse" radio + * is checked (== lens mode). Set mouse tracking back to the default. + */ + screen_part = gtk_check_button_get_active (GTK_CHECK_BUTTON (self->screen_part_radio)); + if (!screen_part) + { + g_settings_set_string (self->settings, + "mouse-tracking", "proportional"); + } + + gtk_widget_set_sensitive (self->centered_radio, screen_part); + gtk_widget_set_sensitive (self->push_radio, screen_part); + gtk_widget_set_sensitive (self->proportional_radio, screen_part); + gtk_widget_set_sensitive (self->extend_beyond_checkbox, screen_part); +} + +static void +scale_label (GtkWidget *check, PangoAttrList *attrs) +{ + GtkWidget *label; + + label = gtk_widget_get_first_child (check); + label = gtk_widget_get_next_sibling (label); + gtk_label_set_attributes (GTK_LABEL (label), attrs); +} + +static void +screen_position_combo_changed_cb (CcZoomOptionsDialog *self) +{ + g_autofree gchar *combo_value = NULL; + GtkTreeIter iter; + + gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->screen_position_combobox), &iter); + + gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (self->screen_position_combobox)), &iter, + POSITION_MODEL_VALUE_COLUMN, &combo_value, + -1); + + if (g_strcmp0 (combo_value, "")) + { + g_settings_set_string (self->settings, "screen-position", combo_value); + } +} + +static void +screen_position_notify_cb (CcZoomOptionsDialog *self, + const gchar *key) +{ + g_autofree gchar *position = NULL; + GtkTreeIter iter; + GtkTreeModel *model; + GtkComboBox *combobox; + gboolean valid; + + position = g_settings_get_string (self->settings, key); + combobox = GTK_COMBO_BOX (self->screen_position_combobox); + model = gtk_combo_box_get_model (combobox); + + /* Find the matching screen position value in the combobox model. If nothing + * matches, leave the combobox as is. + */ + valid = gtk_tree_model_get_iter_first (model, &iter); + while (valid) + { + g_autofree gchar *combo_value = NULL; + + gtk_tree_model_get (model, &iter, + POSITION_MODEL_VALUE_COLUMN, &combo_value, + -1); + if (!g_strcmp0 (combo_value, position)) + { + g_signal_handlers_block_by_func (combobox, screen_position_combo_changed_cb, self); + gtk_combo_box_set_active_iter (combobox, &iter); + g_signal_handlers_unblock_by_func (combobox, screen_position_combo_changed_cb, self); + break; + } + + valid = gtk_tree_model_iter_next (model, &iter); + } +} + +static void +init_xhairs_color_opacity (GtkColorButton *color_button, GSettings *settings) +{ + g_autofree gchar *color_setting = NULL; + GdkRGBA rgba; + + color_setting = g_settings_get_string (settings, "cross-hairs-color"); + gdk_rgba_parse (&rgba, color_setting); + + rgba.alpha = g_settings_get_double (settings, "cross-hairs-opacity"); + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (color_button), &rgba); +} + +static void +xhairs_color_notify_cb (CcZoomOptionsDialog *self) +{ + init_xhairs_color_opacity (GTK_COLOR_BUTTON (self->crosshair_picker_color_button), self->settings); +} + +static void +xhairs_opacity_notify_cb (CcZoomOptionsDialog *self, gchar *key) +{ + GdkRGBA rgba; + gdouble opacity; + + opacity = g_settings_get_double (self->settings, key); + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self->crosshair_picker_color_button), &rgba); + rgba.alpha = opacity * 65535; + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self->crosshair_picker_color_button), &rgba); +} + +#define TO_HEX(x) (int) ((gdouble) x * 255.0) +static void +xhairs_color_opacity_changed (CcZoomOptionsDialog *self) +{ + GdkRGBA rgba; + g_autofree gchar *color_string = NULL; + + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self->crosshair_picker_color_button), &rgba); + color_string = g_strdup_printf ("#%02x%02x%02x", + TO_HEX(rgba.red), + TO_HEX(rgba.green), + TO_HEX(rgba.blue)); + + g_settings_set_string (self->settings, "cross-hairs-color", color_string); + + g_settings_set_double (self->settings, "cross-hairs-opacity", rgba.alpha); +} + +static void xhairs_length_add_marks (CcZoomOptionsDialog *self, GtkScale *scale) +{ + GtkAdjustment *scale_model; + GdkRectangle rect; + GdkMonitor *monitor; + GdkDisplay *display; + GdkSurface *surface; + GtkWindow *transient_for; + gint length, quarter_length; + + /* Get maximum dimension of the monitor */ + transient_for = gtk_window_get_transient_for (GTK_WINDOW (self)); + display = gtk_widget_get_display (GTK_WIDGET (transient_for)); + surface = gtk_native_get_surface (GTK_NATIVE (transient_for)); + monitor = gdk_display_get_monitor_at_surface (display, surface); + gdk_monitor_get_geometry (monitor, &rect); + + length = MAX (rect.width, rect.height); + scale_model = gtk_range_get_adjustment (GTK_RANGE (scale)); + + if (length < gtk_adjustment_get_upper (scale_model)) + gtk_adjustment_set_upper (scale_model, length); + + /* The crosshair is made up of four lines in pairs (top, bottom) and + (left, right). Stipulating: "quarter of the screen" means that the + length of one hair is 25% of the screen. */ + quarter_length = length / 4; + + gtk_scale_add_mark (scale, 0, GTK_POS_BOTTOM, C_("Distance", "Short")); + gtk_scale_add_mark (scale, quarter_length, GTK_POS_BOTTOM, C_("Distance", "¼ Screen")); + gtk_scale_add_mark (scale, quarter_length * 2 , GTK_POS_BOTTOM, C_("Distance", "½ Screen")); + gtk_scale_add_mark (scale, quarter_length * 3, GTK_POS_BOTTOM, C_("Distance", "¾ Screen")); + gtk_scale_add_mark (scale, length, GTK_POS_BOTTOM, C_("Distance", "Long")); +} + +static void +init_effects_slider (GtkRange *slider, + CcZoomOptionsDialog *self, + gchar **keys, + GCallback notify_cb) +{ + gchar **key; + + g_object_set_data (G_OBJECT (slider), "settings-keys", keys); + effects_slider_set_value (slider, self->settings); + + for (key = keys; *key; key++) + { + g_autofree gchar *signal = g_strdup_printf ("changed::%s", *key); + g_signal_connect_object (G_OBJECT (self->settings), signal, notify_cb, self, G_CONNECT_SWAPPED); + } + g_signal_connect_object (G_OBJECT (slider), "value-changed", + G_CALLBACK (effects_slider_changed), + self, G_CONNECT_SWAPPED); + gtk_scale_add_mark (GTK_SCALE (slider), 0, GTK_POS_BOTTOM, NULL); +} + +static void +effects_slider_set_value (GtkRange *slider, GSettings *settings) +{ + gchar **keys; + gdouble red, green, blue; + gdouble value; + + keys = g_object_get_data (G_OBJECT (slider), "settings-keys"); + + red = g_settings_get_double (settings, keys[0]); + green = g_settings_get_double (settings, keys[1]); + blue = g_settings_get_double (settings, keys[2]); + + if (red == green && green == blue) + value = red; + else + /* use NTSC conversion weights for reasonable average */ + value = 0.299 * red + 0.587 * green + 0.114 * blue; + + gtk_range_set_value (slider, value); +} + +static void +brightness_slider_notify_cb (CcZoomOptionsDialog *self, + const gchar *key) +{ + GtkRange *slider = GTK_RANGE (self->brightness_slider); + + g_signal_handlers_block_by_func (slider, effects_slider_changed, self); + effects_slider_set_value (slider, self->settings); + g_signal_handlers_unblock_by_func (slider, effects_slider_changed, self); +} + +static void +contrast_slider_notify_cb (CcZoomOptionsDialog *self, + const gchar *key) +{ + GtkRange *slider = GTK_RANGE (self->contrast_slider); + + g_signal_handlers_block_by_func (slider, effects_slider_changed, self); + effects_slider_set_value (slider, self->settings); + g_signal_handlers_unblock_by_func (slider, effects_slider_changed, self); +} + +static void +effects_slider_changed (CcZoomOptionsDialog *self, GtkRange *slider) +{ + gchar **keys, **key; + gdouble value; + + keys = g_object_get_data (G_OBJECT (slider), "settings-keys"); + value = gtk_range_get_value (slider); + + for (key = keys; *key; key++) + { + g_settings_set_double (self->settings, *key, value); + } +} + +static void +cc_zoom_options_dialog_constructed (GObject *object) +{ + PangoAttribute *attr; + PangoAttrList *pango_attrs; + CcZoomOptionsDialog *self; + + self = CC_ZOOM_OPTIONS_DIALOG (object); + + G_OBJECT_CLASS (cc_zoom_options_dialog_parent_class)->constructed (object); + + pango_attrs = pango_attr_list_new (); + attr = pango_attr_scale_new (FONT_SCALE); + pango_attr_list_insert (pango_attrs, attr); + + /* Zoom switch */ + g_settings_bind (self->application_settings, "screen-magnifier-enabled", + self->seeing_zoom_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + /* Magnification factor */ + g_settings_bind (self->settings, "mag-factor", + gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (self->magnifier_factor_spin)), + "value", G_SETTINGS_BIND_DEFAULT); + + /* Screen position combo */ + screen_position_notify_cb (self, "screen-position"); + g_signal_connect_object (self->settings, "changed::screen-position", + G_CALLBACK (screen_position_notify_cb), self, G_CONNECT_SWAPPED); + g_signal_connect_object (self->screen_position_combobox, "changed", + G_CALLBACK (screen_position_combo_changed_cb), self, G_CONNECT_SWAPPED); + + /* Screen part section */ + init_screen_part_section (self, pango_attrs); + + /* Cross hairs: show/hide ... */ + g_settings_bind (self->settings, "show-cross-hairs", + self->crosshair_enabled_switcher, "active", + G_SETTINGS_BIND_DEFAULT); + + /* ... Cross hairs: color and opacity */ + init_xhairs_color_opacity (GTK_COLOR_BUTTON (self->crosshair_picker_color_button), self->settings); + g_signal_connect_object (self->settings, "changed::cross-hairs-color", + G_CALLBACK (xhairs_color_notify_cb), self, G_CONNECT_SWAPPED); + g_signal_connect_object (self->settings, "changed::cross-hairs-opacity", + G_CALLBACK (xhairs_opacity_notify_cb), self, G_CONNECT_SWAPPED); + g_signal_connect_object (self->crosshair_picker_color_button, "color-set", + G_CALLBACK (xhairs_color_opacity_changed), + self, G_CONNECT_SWAPPED); + + /* ... Cross hairs: thickness ... */ + g_settings_bind (self->settings, "cross-hairs-thickness", + gtk_range_get_adjustment (GTK_RANGE (self->crosshair_thickness_scale)), "value", + G_SETTINGS_BIND_DEFAULT); + + /* ... Cross hairs: clip ... */ + scale_label (self->crosshair_clip_checkbox, pango_attrs); + g_settings_bind (self->settings, "cross-hairs-clip", + self->crosshair_clip_checkbox, "active", + G_SETTINGS_BIND_INVERT_BOOLEAN); + + /* ... Cross hairs: length ... */ + g_settings_bind (self->settings, "cross-hairs-length", + gtk_range_get_adjustment (GTK_RANGE (self->crosshair_length_slider)), "value", + G_SETTINGS_BIND_DEFAULT); + + /* ... Color effects ... */ + g_settings_bind (self->settings, "invert-lightness", self->inverse_enabled_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + init_effects_slider (GTK_RANGE (self->brightness_slider), + self, + brightness_keys, + G_CALLBACK (brightness_slider_notify_cb)); + + init_effects_slider (GTK_RANGE (self->contrast_slider), + self, + contrast_keys, + G_CALLBACK (contrast_slider_notify_cb)); + + g_settings_bind (self->settings, "color-saturation", + gtk_range_get_adjustment (GTK_RANGE (self->grayscale_slider)), "value", + G_SETTINGS_BIND_DEFAULT); + gtk_scale_add_mark (GTK_SCALE(self->grayscale_slider), 1.0, GTK_POS_BOTTOM, NULL); + + pango_attr_list_unref (pango_attrs); +} + +static void +cc_zoom_options_dialog_realize (GtkWidget *widget) +{ + CcZoomOptionsDialog *self = CC_ZOOM_OPTIONS_DIALOG (widget); + + GTK_WIDGET_CLASS (cc_zoom_options_dialog_parent_class)->realize (widget); + + xhairs_length_add_marks (self, GTK_SCALE (self->crosshair_length_slider)); +} + +static void +cc_zoom_options_dialog_finalize (GObject *object) +{ + CcZoomOptionsDialog *self = CC_ZOOM_OPTIONS_DIALOG (object); + + g_clear_object (&self->settings); + g_clear_object (&self->application_settings); + + G_OBJECT_CLASS (cc_zoom_options_dialog_parent_class)->finalize (object); +} + +static void +cc_zoom_options_dialog_class_init (CcZoomOptionsDialogClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->finalize = cc_zoom_options_dialog_finalize; + object_class->constructed = cc_zoom_options_dialog_constructed; + + widget_class->realize = cc_zoom_options_dialog_realize; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/universal-access/cc-zoom-options-dialog.ui"); + + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, brightness_slider); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, centered_radio); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, contrast_slider); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, crosshair_clip_checkbox); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, crosshair_enabled_switcher); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, crosshair_length_slider); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, crosshair_picker_color_button); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, crosshair_thickness_scale); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, extend_beyond_checkbox); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, follow_mouse_radio); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, grayscale_slider); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, inverse_enabled_switch); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, magnifier_factor_spin); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, proportional_radio); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, push_radio); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, screen_part_radio); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, screen_position_combobox); + gtk_widget_class_bind_template_child (widget_class, CcZoomOptionsDialog, seeing_zoom_switch); + + gtk_widget_class_bind_template_callback (widget_class, mouse_tracking_radio_toggled_cb); +} + +static void +cc_zoom_options_dialog_init (CcZoomOptionsDialog *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); + + self->settings = g_settings_new ("org.gnome.desktop.a11y.magnifier"); + self->application_settings = g_settings_new ("org.gnome.desktop.a11y.applications"); +} + +CcZoomOptionsDialog * +cc_zoom_options_dialog_new (void) +{ + return g_object_new (cc_zoom_options_dialog_get_type (), + "use-header-bar", TRUE, + NULL); +} diff --git a/panels/universal-access/cc-zoom-options-dialog.h b/panels/universal-access/cc-zoom-options-dialog.h new file mode 100644 index 0000000..de15aa8 --- /dev/null +++ b/panels/universal-access/cc-zoom-options-dialog.h @@ -0,0 +1,31 @@ +/* + * Copyright 2011 Inclusive Design Research Centre, OCAD University. + * + * 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 + * + * Author: Joseph Scheuhammer <clown@alum.mit.edu> + */ + +#pragma once + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE (CcZoomOptionsDialog, cc_zoom_options_dialog, CC, ZOOM_OPTIONS_DIALOG, GtkDialog) + +CcZoomOptionsDialog *cc_zoom_options_dialog_new (void); + +G_END_DECLS diff --git a/panels/universal-access/cc-zoom-options-dialog.ui b/panels/universal-access/cc-zoom-options-dialog.ui new file mode 100644 index 0000000..e212b85 --- /dev/null +++ b/panels/universal-access/cc-zoom-options-dialog.ui @@ -0,0 +1,686 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <object class="GtkAdjustment" id="brightness_adjustment"> + <property name="lower">-0.75</property> + <property name="upper">0.75</property> + <property name="step_increment">0.10000000000000001</property> + <property name="page_increment">0.10000000000000001</property> + </object> + <object class="GtkAdjustment" id="contrast_adjustment"> + <property name="lower">-0.75</property> + <property name="upper">0.75</property> + <property name="step_increment">0.10000000000000001</property> + <property name="page_increment">0.10000000000000001</property> + </object> + <object class="GtkAdjustment" id="grayscale_adjustment"> + <property name="upper">1</property> + <property name="value">1</property> + <property name="step_increment">0.10000000000000001</property> + <property name="page_increment">0.20000000000000001</property> + </object> + <object class="GtkAdjustment" id="magnifier_factor_adjustment"> + <property name="lower">1</property> + <property name="upper">20</property> + <property name="value">2</property> + <property name="step_increment">0.25</property> + <property name="page_increment">1</property> + </object> + <object class="GtkListStore" id="screen_position_model"> + <columns> + <!-- column-name positions --> + <column type="gchararray"/> + <!-- column-name text_scale --> + <column type="gfloat"/> + <!-- column-name setting_value --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">Full Screen</col> + <col id="1">1.25</col> + <col id="2">full-screen</col> + </row> + <row> + <col id="0" translatable="yes">Top Half</col> + <col id="1">1.25</col> + <col id="2">top-half</col> + </row> + <row> + <col id="0" translatable="yes">Bottom Half</col> + <col id="1">1.25</col> + <col id="2">bottom-half</col> + </row> + <row> + <col id="0" translatable="yes">Left Half</col> + <col id="1">1.25</col> + <col id="2">left-half</col> + </row> + <row> + <col id="0" translatable="yes">Right Half</col> + <col id="1">1.25</col> + <col id="2">right-half</col> + </row> + </data> + </object> + <template class="CcZoomOptionsDialog" parent="GtkDialog"> + <property name="modal">True</property> + <property name="title" translatable="yes">Zoom Options</property> + <property name="resizable">False</property> + <property name="hide-on-close">True</property> + <child> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <property name="spacing">3</property> + <child> + <object class="GtkBox"> + <property name="margin_start">6</property> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <child> + <object class="GtkLabel"> + <property name="label" translatable="yes">_Zoom</property> + <property name="hexpand">True</property> + <property name="xalign">0</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">seeing_zoom_switch</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkSwitch" id="seeing_zoom_switch" /> + </child> + </object> + </child> + <child> + <object class="GtkNotebook"> + <property name="margin_start">6</property> + <property name="margin_end">6</property> + <property name="margin_top">6</property> + <property name="margin_bottom">6</property> + <child> + <object class="GtkBox"> + <property name="margin_start">18</property> + <property name="margin_end">18</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="spacing">12</property> + <property name="orientation">vertical</property> + + <!-- Magnification --> + <child> + <object class="GtkBox"> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Magnification:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">magnifier_factor_spin</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkSpinButton" id="magnifier_factor_spin"> + <property name="halign">start</property> + <property name="adjustment">magnifier_factor_adjustment</property> + <property name="digits">2</property> + <property name="hexpand">True</property> + <property name="margin-start">21</property> + </object> + </child> + </object> + </child> + + <child> + <object class="GtkBox"> + <property name="spacing">6</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="label" translatable="yes">Magnifier Position:</property> + <property name="xalign">0.0</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="margin-top">6</property> + <property name="margin-start">24</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkGrid"> + <child> + <object class="GtkCheckButton" id="follow_mouse_radio"> + <property name="label" translatable="yes">_Follow mouse cursor</property> + <property name="active">True</property> + <property name="use_underline">True</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> + </object> + </child> + <child> + <object class="GtkCheckButton" id="screen_part_radio"> + <property name="label" translatable="yes">_Screen part:</property> + <property name="group">follow_mouse_radio</property> + <property name="use_underline">True</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + </object> + </child> + <child> + <object class="GtkComboBox" id="screen_position_combobox"> + <property name="model">screen_position_model</property> + <property name="active">0</property> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + <child> + <object class="GtkCellRendererText"/> + <attributes> + <attribute name="scale">1</attribute> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="margin-start">18</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkCheckButton" id="extend_beyond_checkbox"> + <property name="label" translatable="yes">Magnifier _extends outside of screen</property> + <property name="use_underline">True</property> + <property name="margin-start">2</property> + </object> + </child> + <child> + <object class="GtkCheckButton" id="centered_radio"> + <property name="label" translatable="yes">_Keep magnifier cursor centered</property> + <property name="active">True</property> + <property name="use_underline">True</property> + <signal name="toggled" handler="mouse_tracking_radio_toggled_cb" object="CcZoomOptionsDialog" swapped="yes"/> + </object> + </child> + <child> + <object class="GtkCheckButton" id="push_radio"> + <property name="label" translatable="yes">Magnifier cursor _pushes contents around</property> + <property name="group">centered_radio</property> + <property name="use_underline">True</property> + <signal name="toggled" handler="mouse_tracking_radio_toggled_cb" object="CcZoomOptionsDialog" swapped="yes"/> + </object> + </child> + <child> + <object class="GtkCheckButton" id="proportional_radio"> + <property name="label" translatable="yes">Magnifier cursor moves with _contents</property> + <property name="group">centered_radio</property> + <property name="use_underline">True</property> + <signal name="toggled" handler="mouse_tracking_radio_toggled_cb" object="CcZoomOptionsDialog" swapped="yes"/> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + <child type="tab"> + <object class="GtkLabel"> + <property name="label" translatable="yes">Magnifier</property> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="margin_start">18</property> + <property name="margin_end">24</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="spacing">12</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox"> + <property name="spacing">6</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox"> + <property name="spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="label" translatable="yes">_Crosshairs:</property> + <property name="use_markup">True</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">crosshair_enabled_switcher</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkSwitch" id="crosshair_enabled_switcher"> + <property name="valign">center</property> + </object> + </child> + <child> + <object class="GtkCheckButton" id="crosshair_clip_checkbox"> + <property name="label" translatable="yes">_Overlaps mouse cursor</property> + <property name="halign">start</property> + <property name="margin_start">100</property> + <property name="hexpand">True</property> + <property name="use_underline">True</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="margin-top">8</property> + <property name="margin-start">16</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkGrid"> + <property name="column_spacing">12</property> + <property name="row_spacing">16</property> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Thickness:</property> + <property name="justify">center</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">crosshair_thickness_scale</property> + <property name="width_chars">12</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">3</property> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> + <child> + <object class="GtkLabel"> + <property name="xalign">1</property> + <property name="label" translatable="yes" context="universal access, thickness">Thin</property> + <property name="justify">center</property> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkScale" id="crosshair_thickness_scale"> + <property name="adjustment">crosshair_thickness_adjustment</property> + <property name="hexpand">True</property> + <property name="draw_value">False</property> + <property name="value_pos">right</property> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" context="universal access, thickness">Thick</property> + <property name="justify">center</property> + <property name="margin-start">8</property> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Length:</property> + <property name="justify">center</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">crosshair_length_slider</property> + <property name="width_chars">12</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">3</property> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + <child> + <object class="GtkScale" id="crosshair_length_slider"> + <property name="adjustment">crosshair_length_adjustment</property> + <property name="hexpand">True</property> + <property name="draw_value">False</property> + <property name="value_pos">right</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" comments="The color of the accessibility crosshair">Co_lor:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">crosshair_picker_color_button</property> + <layout> + <property name="column">0</property> + <property name="row">2</property> + </layout> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkColorButton" id="crosshair_picker_color_button"> + <property name="valign">start</property> + <property name="halign">start</property> + <layout> + <property name="column">1</property> + <property name="row">2</property> + </layout> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + <child type="tab"> + <object class="GtkLabel"> + <property name="label" translatable="yes">Crosshairs</property> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="margin_start">18</property> + <property name="margin_end">24</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="spacing">12</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox"> + <property name="spacing">6</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="label" translatable="yes">Color Effects:</property> + <property name="xalign">0</property> + <property name="use_markup">True</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="margin-top">8</property> + <property name="margin-start">16</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkGrid"> + <property name="row_spacing">16</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">_White on black:</property> + <property name="justify">right</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">inverse_enabled_switch</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Brightness:</property> + <property name="justify">right</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">brightness_slider</property> + <property name="width_chars">12</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Contrast:</property> + <property name="justify">right</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">contrast_slider</property> + <layout> + <property name="column">0</property> + <property name="row">2</property> + </layout> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" context="universal access, contrast" comments="The contrast scale goes from Color to None (grayscale)">Co_lor</property> + <property name="justify">right</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">grayscale_slider</property> + <layout> + <property name="column">0</property> + <property name="row">3</property> + </layout> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">3</property> + <layout> + <property name="column">1</property> + <property name="row">3</property> + </layout> + <child> + <object class="GtkLabel"> + <property name="xalign">1</property> + <property name="label" translatable="yes" context="universal access, color">None</property> + <property name="justify">center</property> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkScale" id="grayscale_slider"> + <property name="adjustment">grayscale_adjustment</property> + <property name="hexpand">True</property> + <property name="draw_value">False</property> + <property name="value_pos">right</property> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" context="universal access, color">Full</property> + <property name="justify">center</property> + <property name="margin-start">8</property> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">12</property> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> + <child> + <object class="GtkSwitch" id="inverse_enabled_switch" /> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">3</property> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + <child> + <object class="GtkLabel"> + <property name="xalign">1</property> + <property name="label" translatable="yes" context="universal access, brightness">Low</property> + <property name="justify">center</property> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkScale" id="brightness_slider"> + <property name="adjustment">brightness_adjustment</property> + <property name="hexpand">True</property> + <property name="draw_value">False</property> + <property name="value_pos">left</property> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" context="universal access, brightness">High</property> + <property name="justify">center</property> + <property name="margin-start">8</property> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + </object> + </child> + <child> + <object class="GtkBox"> + <property name="spacing">3</property> + <layout> + <property name="column">1</property> + <property name="row">2</property> + </layout> + <child> + <object class="GtkLabel"> + <property name="xalign">1</property> + <property name="label" translatable="yes" context="universal access, contrast">Low</property> + <property name="justify">center</property> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + <child> + <object class="GtkScale" id="contrast_slider"> + <property name="adjustment">contrast_adjustment</property> + <property name="hexpand">True</property> + <property name="draw_value">False</property> + <property name="value_pos">left</property> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="label" translatable="yes" context="universal access, contrast">High</property> + <property name="justify">center</property> + <property name="margin-start">8</property> + <attributes> + <attribute name="scale" value="1.25"/> + </attributes> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + <child type="tab"> + <object class="GtkLabel"> + <property name="label" translatable="yes">Color Effects</property> + </object> + </child> + </object> + </child> + </object> + </child> + </template> + <object class="GtkAdjustment" id="crosshair_thickness_adjustment"> + <property name="lower">1</property> + <property name="upper">100</property> + <property name="value">8</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="crosshair_length_adjustment"> + <property name="lower">20</property> + <property name="upper">4096</property> + <property name="value">4096</property> + <property name="step_increment">1</property> + <property name="page_increment">100</property> + </object> +</interface> diff --git a/panels/universal-access/gnome-universal-access-panel.desktop.in.in b/panels/universal-access/gnome-universal-access-panel.desktop.in.in new file mode 100644 index 0000000..ef770fe --- /dev/null +++ b/panels/universal-access/gnome-universal-access-panel.desktop.in.in @@ -0,0 +1,18 @@ +[Desktop Entry] +Name=Accessibility +Comment=Make it easier to see, hear, type, point and click +Exec=gnome-control-center universal-access +# Translators: Do NOT translate or transliterate this text (this is an icon file name)! +Icon=org.gnome.Settings-accessibility +Terminal=false +Type=Application +NoDisplay=true +StartupNotify=true +Categories=GNOME;GTK;Settings;X-GNOME-Settings-Panel;X-GNOME-DetailsSettings; +OnlyShowIn=GNOME;Unity; +X-GNOME-Bugzilla-Bugzilla=GNOME +X-GNOME-Bugzilla-Product=gnome-control-center +X-GNOME-Bugzilla-Component=Universal Access +X-GNOME-Bugzilla-Version=@VERSION@ +# Translators: Search terms to find the Accessibility panel. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon! +Keywords=Keyboard;Mouse;a11y;Accessibility;Universal Access;Contrast;Cursor;Sound;Zoom;Screen;Reader;big;high;large;text;font;size;AccessX;Sticky;Keys;Slow;Bounce;Mouse;Double;click;Delay;Speed;Assist;Repeat;Blink;visual;hearing;audio;typing;animations; diff --git a/panels/universal-access/icons/meson.build b/panels/universal-access/icons/meson.build new file mode 100644 index 0000000..68f02a9 --- /dev/null +++ b/panels/universal-access/icons/meson.build @@ -0,0 +1,4 @@ +install_data( + 'scalable/org.gnome.Settings-accessibility-symbolic.svg', + install_dir: join_paths(control_center_icondir, 'hicolor', 'scalable', 'apps') +) diff --git a/panels/universal-access/icons/scalable/org.gnome.Settings-accessibility-symbolic.svg b/panels/universal-access/icons/scalable/org.gnome.Settings-accessibility-symbolic.svg new file mode 100644 index 0000000..b7efb64 --- /dev/null +++ b/panels/universal-access/icons/scalable/org.gnome.Settings-accessibility-symbolic.svg @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg"> + <g fill="#2e3436"> + <path d="m 8.015625 0 c 1.105469 0 2 0.894531 2 2 s -0.894531 2 -2 2 c -1.101563 0 -2 -0.894531 -2 -2 s 0.898437 -2 2 -2 z m 0 0"/> + <path d="m 2 7 h 3 v 9 h 2 v -4 c 0 -0.550781 0.449219 -1 1 -1 s 1 0.449219 1 1 v 4 h 2 v -9 h 3 v -2 h -12 z m 0 0"/> + </g> +</svg> diff --git a/panels/universal-access/left_ptr_24px.png b/panels/universal-access/left_ptr_24px.png Binary files differnew file mode 100644 index 0000000..46f7760 --- /dev/null +++ b/panels/universal-access/left_ptr_24px.png diff --git a/panels/universal-access/left_ptr_32px.png b/panels/universal-access/left_ptr_32px.png Binary files differnew file mode 100644 index 0000000..5d9ba96 --- /dev/null +++ b/panels/universal-access/left_ptr_32px.png diff --git a/panels/universal-access/left_ptr_48px.png b/panels/universal-access/left_ptr_48px.png Binary files differnew file mode 100644 index 0000000..51b1dc2 --- /dev/null +++ b/panels/universal-access/left_ptr_48px.png diff --git a/panels/universal-access/left_ptr_64px.png b/panels/universal-access/left_ptr_64px.png Binary files differnew file mode 100644 index 0000000..4cf77a4 --- /dev/null +++ b/panels/universal-access/left_ptr_64px.png diff --git a/panels/universal-access/left_ptr_96px.png b/panels/universal-access/left_ptr_96px.png Binary files differnew file mode 100644 index 0000000..5897a7c --- /dev/null +++ b/panels/universal-access/left_ptr_96px.png diff --git a/panels/universal-access/meson.build b/panels/universal-access/meson.build new file mode 100644 index 0000000..b86b8c3 --- /dev/null +++ b/panels/universal-access/meson.build @@ -0,0 +1,64 @@ +panels_list += cappletname +desktop = 'gnome-@0@-panel.desktop'.format(cappletname) + +desktop_in = configure_file( + input: desktop + '.in.in', + output: desktop + '.in', + configuration: desktop_conf +) + +i18n.merge_file( + type: 'desktop', + input: desktop_in, + output: desktop, + po_dir: po_dir, + install: true, + install_dir: control_center_desktopdir +) + +sources = files( + 'cc-cursor-blinking-dialog.c', + 'cc-cursor-size-dialog.c', + 'cc-pointing-dialog.c', + 'cc-repeat-keys-dialog.c', + 'cc-typing-dialog.c', + 'cc-ua-panel.c', + 'cc-visual-alerts-dialog.c', + 'cc-zoom-options-dialog.c' +) + +resource_data = files( + 'cc-ua-panel.ui', + 'left_ptr_24px.png', + 'left_ptr_32px.png', + 'left_ptr_48px.png', + 'left_ptr_64px.png', + 'left_ptr_96px.png', + 'cc-cursor-blinking-dialog.ui', + 'cc-cursor-size-dialog.ui', + 'cc-pointing-dialog.ui', + 'cc-repeat-keys-dialog.ui', + 'cc-typing-dialog.ui', + 'cc-visual-alerts-dialog.ui', + 'cc-zoom-options-dialog.ui' +) + +sources += gnome.compile_resources( + 'cc-ua-resources', + cappletname + '.gresource.xml', + c_name: 'cc_' + cappletname.underscorify(), + dependencies: resource_data, + export: true +) + +deps = common_deps + [m_dep] + +panels_libs += static_library( + cappletname, + sources: sources, + include_directories: [ top_inc, common_inc ], + dependencies: deps, + c_args: cflags +) + +subdir('icons') diff --git a/panels/universal-access/universal-access.gresource.xml b/panels/universal-access/universal-access.gresource.xml new file mode 100644 index 0000000..713ef3d --- /dev/null +++ b/panels/universal-access/universal-access.gresource.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/gnome/control-center/universal-access"> + <file preprocess="xml-stripblanks">cc-cursor-blinking-dialog.ui</file> + <file preprocess="xml-stripblanks">cc-cursor-size-dialog.ui</file> + <file preprocess="xml-stripblanks">cc-pointing-dialog.ui</file> + <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-visual-alerts-dialog.ui</file> + <file preprocess="xml-stripblanks">cc-zoom-options-dialog.ui</file> + <file>left_ptr_24px.png</file> + <file>left_ptr_32px.png</file> + <file>left_ptr_48px.png</file> + <file>left_ptr_64px.png</file> + <file>left_ptr_96px.png</file> + </gresource> +</gresources> |