1
/* -*- mode: c; style: linux -*- */
4
* Copyright (C) 2007 The GNOME Foundation
5
* Written by Denis Washington <denisw@svn.gnome.org>
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.
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.
18
* You should have received a copy of the GNU General Public License along
19
* with this program; if not, write to the Free Software Foundation, Inc.,
20
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27
#include "gnome-keyboard-properties-a11y.h"
28
#include <gconf/gconf-client.h>
29
#include "gconf-property-editor.h"
30
#include "capplet-util.h"
32
#define CONFIG_ROOT "/desktop/gnome/accessibility/keyboard"
33
#define NWID(s) GTK_WIDGET (gtk_builder_get_object (notifications_dialog, s))
35
static GtkBuilder *notifications_dialog = NULL;
38
stickykeys_enable_toggled_cb (GtkWidget *w, GtkBuilder *dialog)
40
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
42
gtk_widget_set_sensitive (WID ("stickykeys_two_key_off"), active);
43
if (notifications_dialog)
44
gtk_widget_set_sensitive (NWID ("stickykeys_notifications_box"), active);
48
slowkeys_enable_toggled_cb (GtkWidget *w, GtkBuilder *dialog)
50
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
52
gtk_widget_set_sensitive (WID ("slowkeys_delay_box"), active);
53
if (notifications_dialog)
54
gtk_widget_set_sensitive (NWID ("slowkeys_notifications_box"), active);
58
bouncekeys_enable_toggled_cb (GtkWidget *w, GtkBuilder *dialog)
60
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
62
gtk_widget_set_sensitive (WID ("bouncekeys_delay_box"), active);
63
if (notifications_dialog)
64
gtk_widget_set_sensitive (NWID ("bouncekeys_notifications_box"), active);
68
visual_bell_enable_toggled_cb (GtkWidget *w, GtkBuilder *dialog)
70
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
72
if (notifications_dialog) {
73
gtk_widget_set_sensitive (NWID ("visual_bell_titlebar"), active);
74
gtk_widget_set_sensitive (NWID ("visual_bell_fullscreen"), active);
78
static GConfEnumStringPair bell_flash_enums[] = {
85
bell_flash_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
87
GConfValue *new_value;
89
new_value = gconf_value_new (GCONF_VALUE_STRING);
90
gconf_value_set_string (new_value,
91
gconf_enum_to_string (bell_flash_enums, gconf_value_get_int (value)));
97
bell_flash_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
99
GConfValue *new_value;
103
str = (value && (value->type == GCONF_VALUE_STRING)) ? gconf_value_get_string (value) : NULL;
105
new_value = gconf_value_new (GCONF_VALUE_INT);
106
if (value->type == GCONF_VALUE_STRING) {
107
gconf_string_to_enum (bell_flash_enums,
111
gconf_value_set_int (new_value, val);
117
a11y_notifications_dialog_response_cb (GtkWidget *w, gint response)
119
if (response == GTK_RESPONSE_HELP) {
123
gtk_widget_destroy (w);
127
notifications_button_clicked_cb (GtkWidget *button, GtkBuilder *dialog)
131
notifications_dialog = gtk_builder_new ();
132
gtk_builder_add_from_file (notifications_dialog, GNOMECC_UI_DIR
133
"/gnome-keyboard-properties-a11y-notifications.ui",
136
stickykeys_enable_toggled_cb (WID ("stickykeys_enable"), dialog);
137
slowkeys_enable_toggled_cb (WID ("slowkeys_enable"), dialog);
138
bouncekeys_enable_toggled_cb (WID ("bouncekeys_enable"), dialog);
140
w = NWID ("feature_state_change_beep");
141
gconf_peditor_new_boolean (NULL,
142
CONFIG_ROOT "/feature_state_change_beep",
145
w = NWID ("togglekeys_enable");
146
gconf_peditor_new_boolean (NULL,
147
CONFIG_ROOT "/togglekeys_enable",
150
w = NWID ("stickykeys_modifier_beep");
151
gconf_peditor_new_boolean (NULL,
152
CONFIG_ROOT "/stickykeys_modifier_beep",
155
w = NWID ("slowkeys_beep_press");
156
gconf_peditor_new_boolean (NULL,
157
CONFIG_ROOT "/slowkeys_beep_press",
160
w = NWID ("slowkeys_beep_accept");
161
gconf_peditor_new_boolean (NULL,
162
CONFIG_ROOT "/slowkeys_beep_accept",
165
w = NWID ("slowkeys_beep_reject");
166
gconf_peditor_new_boolean (NULL,
167
CONFIG_ROOT "/slowkeys_beep_reject",
170
w = NWID ("bouncekeys_beep_reject");
171
gconf_peditor_new_boolean (NULL,
172
CONFIG_ROOT "/bouncekeys_beep_reject",
175
w = NWID ("visual_bell_enable");
176
gconf_peditor_new_boolean (NULL,
177
"/apps/metacity/general/visual_bell",
179
g_signal_connect (w, "toggled",
180
G_CALLBACK (visual_bell_enable_toggled_cb), dialog);
181
visual_bell_enable_toggled_cb (w, dialog);
183
gconf_peditor_new_select_radio (NULL,
184
"/apps/metacity/general/visual_bell_type",
185
gtk_radio_button_get_group (GTK_RADIO_BUTTON (NWID ("visual_bell_titlebar"))),
186
"conv-to-widget-cb", bell_flash_to_widget,
187
"conv-from-widget-cb", bell_flash_from_widget,
190
w = NWID ("a11y_notifications_dialog");
191
gtk_window_set_transient_for (GTK_WINDOW (w),
192
GTK_WINDOW (WID ("keyboard_dialog")));
193
g_signal_connect (w, "response",
194
G_CALLBACK (a11y_notifications_dialog_response_cb), NULL);
196
gtk_dialog_run (GTK_DIALOG (w));
198
g_object_unref (notifications_dialog);
199
notifications_dialog = NULL;
203
mousekeys_enable_toggled_cb (GtkWidget *w, GtkBuilder *dialog)
205
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
206
gtk_widget_set_sensitive (WID ("mousekeys_table"), active);
210
mousekeys_accel_time_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
212
GtkAdjustment *adjustment;
214
GConfValue *new_value;
216
adjustment = GTK_ADJUSTMENT (gconf_property_editor_get_ui_control (peditor));
217
g_object_get (adjustment,
218
"upper", &range_upper,
221
new_value = gconf_value_new (GCONF_VALUE_INT);
222
gconf_value_set_int (new_value, MAX (0, ((int) range_upper) - gconf_value_get_int (value)));
228
mousekeys_accel_time_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
230
GtkAdjustment *adjustment;
231
gdouble range_value, range_upper;
232
GConfValue *new_value;
234
adjustment = GTK_ADJUSTMENT (gconf_property_editor_get_ui_control (peditor));
235
g_object_get (adjustment,
236
"value", &range_value,
237
"upper", &range_upper,
240
new_value = gconf_value_new (GCONF_VALUE_INT);
241
gconf_value_set_int (new_value, (int) range_upper - range_value);
247
setup_a11y_tabs (GtkBuilder *dialog, GConfChangeSet *changeset)
252
client = gconf_client_get_default ();
253
gconf_client_add_dir (client, CONFIG_ROOT, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
254
g_object_unref (client);
256
/* Accessibility tab */
258
w = WID ("master_enable");
259
gconf_peditor_new_boolean (changeset,
260
CONFIG_ROOT "/enable",
263
w = WID ("stickykeys_enable");
264
gconf_peditor_new_boolean (changeset,
265
CONFIG_ROOT "/stickykeys_enable",
267
g_signal_connect (w, "toggled",
268
G_CALLBACK (stickykeys_enable_toggled_cb), dialog);
269
stickykeys_enable_toggled_cb (w, dialog);
271
w = WID ("stickykeys_two_key_off");
272
gconf_peditor_new_boolean (changeset,
273
CONFIG_ROOT "/stickykeys_two_key_off",
276
w = WID ("slowkeys_enable");
277
gconf_peditor_new_boolean (changeset,
278
CONFIG_ROOT "/slowkeys_enable",
280
g_signal_connect (w, "toggled",
281
G_CALLBACK (slowkeys_enable_toggled_cb), dialog);
282
slowkeys_enable_toggled_cb (w, dialog);
284
w = WID ("bouncekeys_enable");
285
gconf_peditor_new_boolean (changeset,
286
CONFIG_ROOT "/bouncekeys_enable",
288
g_signal_connect (w, "toggled",
289
G_CALLBACK (bouncekeys_enable_toggled_cb), dialog);
290
bouncekeys_enable_toggled_cb (w, dialog);
292
gconf_peditor_new_numeric_range (changeset,
293
CONFIG_ROOT "/slowkeys_delay",
294
WID ("slowkeys_delay_slide"), NULL);
295
gconf_peditor_new_numeric_range (changeset,
296
CONFIG_ROOT "/bouncekeys_delay",
297
WID ("bouncekeys_delay_slide"), NULL);
299
w = WID ("notifications_button");
300
g_signal_connect (w, "clicked",
301
G_CALLBACK (notifications_button_clicked_cb), dialog);
305
w = WID ("mousekeys_enable");
306
gconf_peditor_new_boolean (changeset,
307
CONFIG_ROOT "/mousekeys_enable",
309
g_signal_connect (w, "toggled",
310
G_CALLBACK (mousekeys_enable_toggled_cb), dialog);
311
mousekeys_enable_toggled_cb (w, dialog);
313
gconf_peditor_new_numeric_range (changeset,
314
CONFIG_ROOT "/mousekeys_accel_time",
315
WID ("mousekeys_accel_time_slide"),
316
"conv-to-widget-cb", mousekeys_accel_time_to_widget,
317
"conv-from-widget-cb", mousekeys_accel_time_from_widget,
319
gconf_peditor_new_numeric_range (changeset,
320
CONFIG_ROOT "/mousekeys_max_speed",
321
WID ("mousekeys_max_speed_slide"), NULL);
322
gconf_peditor_new_numeric_range (changeset,
323
CONFIG_ROOT "/mousekeys_init_delay",
324
WID ("mousekeys_init_delay_slide"), NULL);