Line |
Branch |
Exec |
Source |
1 |
|
|
/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
2 |
|
|
* |
3 |
|
|
* Copyright (C) 2010 Intel, Inc |
4 |
|
|
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com> |
5 |
|
|
* Copyright 2022 Mohammed Sadiq <sadiq@sadiqpk.org> |
6 |
|
|
* Copyright 2022 Purism SPC |
7 |
|
|
* |
8 |
|
|
* This program is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License as published by |
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
11 |
|
|
* (at your option) any later version. |
12 |
|
|
* |
13 |
|
|
* This program is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU General Public License for more details. |
17 |
|
|
* |
18 |
|
|
* You should have received a copy of the GNU General Public License |
19 |
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
20 |
|
|
* |
21 |
|
|
* Author(s): |
22 |
|
|
* Thomas Wood <thomas.wood@intel.com> |
23 |
|
|
* Rodrigo Moya <rodrigo@gnome.org> |
24 |
|
|
* Mohammed Sadiq <sadiq@sadiqpk.org> |
25 |
|
|
* |
26 |
|
|
* SPDX-License-Identifier: GPL-2.0-or-later |
27 |
|
|
*/ |
28 |
|
|
|
29 |
|
|
#include <config.h> |
30 |
|
|
|
31 |
|
|
#include <math.h> |
32 |
|
|
#include <glib/gi18n-lib.h> |
33 |
|
|
#include <gdesktop-enums.h> |
34 |
|
|
|
35 |
|
|
#include "cc-list-row.h" |
36 |
|
|
#include "cc-ua-macros.h" |
37 |
|
|
#include "cc-ua-panel.h" |
38 |
|
|
#include "cc-ua-hearing-page.h" |
39 |
|
|
#include "cc-ua-mouse-page.h" |
40 |
|
|
#include "cc-ua-seeing-page.h" |
41 |
|
|
#include "cc-ua-typing-page.h" |
42 |
|
|
#include "cc-ua-zoom-page.h" |
43 |
|
|
#include "cc-ua-resources.h" |
44 |
|
|
|
45 |
|
|
struct _CcUaPanel |
46 |
|
|
{ |
47 |
|
|
CcPanel parent_instance; |
48 |
|
|
|
49 |
|
|
AdwNavigationView *main_nav_view; |
50 |
|
|
AdwSwitchRow *show_ua_menu_row; |
51 |
|
|
CcListRow *seeing_row; |
52 |
|
|
CcListRow *hearing_row; |
53 |
|
|
CcListRow *typing_row; |
54 |
|
|
CcListRow *mouse_row; |
55 |
|
|
CcListRow *zoom_row; |
56 |
|
|
|
57 |
|
|
GSettings *a11y_settings; |
58 |
|
|
}; |
59 |
|
|
|
60 |
|
✗ |
CC_PANEL_REGISTER (CcUaPanel, cc_ua_panel) |
61 |
|
|
|
62 |
|
|
static void |
63 |
|
✗ |
cc_ua_panel_dispose (GObject *object) |
64 |
|
|
{ |
65 |
|
✗ |
CcUaPanel *self = CC_UA_PANEL (object); |
66 |
|
|
|
67 |
|
✗ |
g_clear_object (&self->a11y_settings); |
68 |
|
|
|
69 |
|
✗ |
G_OBJECT_CLASS (cc_ua_panel_parent_class)->dispose (object); |
70 |
|
✗ |
} |
71 |
|
|
|
72 |
|
|
static const char * |
73 |
|
✗ |
cc_ua_panel_get_help_uri (CcPanel *panel) |
74 |
|
|
{ |
75 |
|
✗ |
return "help:gnome-help/a11y"; |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
static void |
79 |
|
✗ |
cc_ua_panel_class_init (CcUaPanelClass *klass) |
80 |
|
|
{ |
81 |
|
✗ |
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); |
82 |
|
✗ |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
83 |
|
✗ |
CcPanelClass *panel_class = CC_PANEL_CLASS (klass); |
84 |
|
|
|
85 |
|
✗ |
panel_class->get_help_uri = cc_ua_panel_get_help_uri; |
86 |
|
|
|
87 |
|
✗ |
object_class->dispose = cc_ua_panel_dispose; |
88 |
|
|
|
89 |
|
✗ |
g_type_ensure (CC_TYPE_LIST_ROW); |
90 |
|
|
|
91 |
|
✗ |
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/universal-access/cc-ua-panel.ui"); |
92 |
|
|
|
93 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcUaPanel, main_nav_view); |
94 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcUaPanel, show_ua_menu_row); |
95 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcUaPanel, seeing_row); |
96 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcUaPanel, hearing_row); |
97 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcUaPanel, typing_row); |
98 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcUaPanel, mouse_row); |
99 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcUaPanel, zoom_row); |
100 |
|
|
|
101 |
|
✗ |
g_type_ensure (CC_TYPE_UA_SEEING_PAGE); |
102 |
|
✗ |
g_type_ensure (CC_TYPE_UA_HEARING_PAGE); |
103 |
|
✗ |
g_type_ensure (CC_TYPE_UA_TYPING_PAGE); |
104 |
|
✗ |
g_type_ensure (CC_TYPE_UA_MOUSE_PAGE); |
105 |
|
✗ |
g_type_ensure (CC_TYPE_UA_ZOOM_PAGE); |
106 |
|
✗ |
} |
107 |
|
|
|
108 |
|
|
static void |
109 |
|
✗ |
on_subpage_set (CcUaPanel *self) |
110 |
|
|
{ |
111 |
|
|
AdwNavigationPage *subpage; |
112 |
|
✗ |
g_autofree gchar *tag = NULL; |
113 |
|
|
|
114 |
|
✗ |
g_object_get (self, "subpage", &tag, NULL); |
115 |
|
✗ |
if (!tag) |
116 |
|
✗ |
return; |
117 |
|
|
|
118 |
|
✗ |
subpage = adw_navigation_view_find_page (self->main_nav_view, tag); |
119 |
|
✗ |
if (subpage) |
120 |
|
✗ |
adw_navigation_view_push (self->main_nav_view, subpage); |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
static void |
124 |
|
✗ |
cc_ua_panel_init (CcUaPanel *self) |
125 |
|
|
{ |
126 |
|
✗ |
g_resources_register (cc_universal_access_get_resource ()); |
127 |
|
✗ |
gtk_icon_theme_add_resource_path (gtk_icon_theme_get_for_display (gdk_display_get_default ()), |
128 |
|
|
"/org/gnome/control-center/universal-access/icons"); |
129 |
|
|
|
130 |
|
✗ |
gtk_widget_init_template (GTK_WIDGET (self)); |
131 |
|
|
|
132 |
|
✗ |
self->a11y_settings = g_settings_new (A11Y_SETTINGS); |
133 |
|
✗ |
g_settings_bind (self->a11y_settings, KEY_ALWAYS_SHOW_STATUS, |
134 |
|
✗ |
self->show_ua_menu_row, "active", |
135 |
|
|
G_SETTINGS_BIND_DEFAULT); |
136 |
|
|
|
137 |
|
✗ |
g_signal_connect_object (self, "notify::subpage", G_CALLBACK (on_subpage_set), self, G_CONNECT_SWAPPED); |
138 |
|
✗ |
} |
139 |
|
|
|