~kroq-gar78/ubuntu/precise/gnome-control-center/fix-885947

« back to all changes in this revision

Viewing changes to capplets/keyboard/gnome-keyboard-properties-a11y.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-05-17 10:47:27 UTC
  • mfrom: (0.1.11 experimental) (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517104727-lqel6m8vhfw5jby1
Tags: 1:3.0.1.1-1ubuntu1
* Rebase on Debian, remaining Ubuntu changes:
* debian/control:
  - Build-Depend on hardening-wrapper, dpkg-dev and dh-autoreconf
  - Add dependency on ubuntu-system-service
  - Remove dependency on gnome-icon-theme-symbolic
  - Move dependency on apg, gnome-icon-theme-symbolic and accountsservice to
    be a Recommends: until we get them in main
* debian/rules:
  - Use autoreconf
  - Add binary-post-install rule for gnome-control-center-data
  - Run dh-autoreconf
* debian/gnome-control-center.dirs:
* debian/gnome-control-center.links:
  - Add a link to the control center shell for indicators
* debian/patches/00_disable-nm.patch:
  - Temporary patch to disable building with NetworkManager until we get
    the new one in the archive
* debian/patches/01_git_remove_gettext_calls.patch:
  - Remove calls to AM_GNU_GETTEXT, IT_PROG_INTLTOOL should be enough
* debian/patches/01_git_kill_warning.patch:
  - Kill warning
* debian/patches/50_ubuntu_systemwide_prefs.patch:
  - Ubuntu specific proxy preferences
* debian/patches/51_ubuntu_system_keyboard.patch:
  - Implement the global keyboard spec at https://wiki.ubuntu.com/DefaultKeyboardSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c; style: linux -*- */
2
 
 
3
 
/*
4
 
 * Copyright (C) 2007 The GNOME Foundation
5
 
 * Written by Denis Washington <denisw@svn.gnome.org>
6
 
 * All Rights Reserved
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 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.
21
 
 */
22
 
 
23
 
#ifdef HAVE_CONFIG_H
24
 
#  include <config.h>
25
 
#endif
26
 
 
27
 
#include "gnome-keyboard-properties-a11y.h"
28
 
#include <gconf/gconf-client.h>
29
 
#include "gconf-property-editor.h"
30
 
#include "capplet-util.h"
31
 
 
32
 
#define CONFIG_ROOT "/desktop/gnome/accessibility/keyboard"
33
 
#define NWID(s) GTK_WIDGET (gtk_builder_get_object (notifications_dialog, s))
34
 
 
35
 
static GtkBuilder *notifications_dialog = NULL;
36
 
 
37
 
static void
38
 
stickykeys_enable_toggled_cb (GtkWidget *w, GtkBuilder *dialog)
39
 
{
40
 
        gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
41
 
 
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);
45
 
}
46
 
 
47
 
static void
48
 
slowkeys_enable_toggled_cb (GtkWidget *w, GtkBuilder *dialog)
49
 
{
50
 
        gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
51
 
 
52
 
        gtk_widget_set_sensitive (WID ("slowkeys_delay_box"), active);
53
 
        if (notifications_dialog)
54
 
                gtk_widget_set_sensitive (NWID ("slowkeys_notifications_box"), active);
55
 
}
56
 
 
57
 
static void
58
 
bouncekeys_enable_toggled_cb (GtkWidget *w, GtkBuilder *dialog)
59
 
{
60
 
        gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
61
 
 
62
 
        gtk_widget_set_sensitive (WID ("bouncekeys_delay_box"), active);
63
 
        if (notifications_dialog)
64
 
                gtk_widget_set_sensitive (NWID ("bouncekeys_notifications_box"), active);
65
 
}
66
 
 
67
 
static void
68
 
visual_bell_enable_toggled_cb (GtkWidget *w, GtkBuilder *dialog)
69
 
{
70
 
        gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
71
 
 
72
 
        if (notifications_dialog) {
73
 
                gtk_widget_set_sensitive (NWID ("visual_bell_titlebar"), active);
74
 
                gtk_widget_set_sensitive (NWID ("visual_bell_fullscreen"), active);
75
 
        }
76
 
}
77
 
 
78
 
static GConfEnumStringPair bell_flash_enums[] = {
79
 
        { 0, "frame_flash" },
80
 
        { 1, "fullscreen" },
81
 
        { -1, NULL }
82
 
};
83
 
 
84
 
static GConfValue *
85
 
bell_flash_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
86
 
{
87
 
        GConfValue *new_value;
88
 
 
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)));
92
 
 
93
 
        return new_value;
94
 
}
95
 
 
96
 
static GConfValue *
97
 
bell_flash_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
98
 
{
99
 
        GConfValue *new_value;
100
 
        const gchar *str;
101
 
        gint val = 2;
102
 
 
103
 
        str = (value && (value->type == GCONF_VALUE_STRING)) ? gconf_value_get_string (value) : NULL;
104
 
 
105
 
        new_value = gconf_value_new (GCONF_VALUE_INT);
106
 
        if (value->type == GCONF_VALUE_STRING) {
107
 
                gconf_string_to_enum (bell_flash_enums,
108
 
                                      str,
109
 
                                      &val);
110
 
        }
111
 
        gconf_value_set_int (new_value, val);
112
 
 
113
 
        return new_value;
114
 
}
115
 
 
116
 
static void
117
 
a11y_notifications_dialog_response_cb (GtkWidget *w, gint response)
118
 
{
119
 
        if (response == GTK_RESPONSE_HELP) {
120
 
 
121
 
        }
122
 
        else {
123
 
                gtk_widget_destroy (w);
124
 
        }
125
 
}
126
 
static void
127
 
notifications_button_clicked_cb (GtkWidget *button, GtkBuilder *dialog)
128
 
{
129
 
        GtkWidget *w;
130
 
    
131
 
    notifications_dialog = gtk_builder_new ();
132
 
    gtk_builder_add_from_file (notifications_dialog, GNOMECC_UI_DIR
133
 
                               "/gnome-keyboard-properties-a11y-notifications.ui",
134
 
                               NULL);
135
 
 
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);
139
 
 
140
 
        w = NWID ("feature_state_change_beep");
141
 
        gconf_peditor_new_boolean (NULL,
142
 
                                  CONFIG_ROOT "/feature_state_change_beep",
143
 
                                  w, NULL);
144
 
 
145
 
        w = NWID ("togglekeys_enable");
146
 
        gconf_peditor_new_boolean (NULL,
147
 
                                  CONFIG_ROOT "/togglekeys_enable",
148
 
                                  w, NULL);
149
 
 
150
 
        w = NWID ("stickykeys_modifier_beep");
151
 
        gconf_peditor_new_boolean (NULL,
152
 
                                  CONFIG_ROOT "/stickykeys_modifier_beep",
153
 
                                  w, NULL);
154
 
 
155
 
        w = NWID ("slowkeys_beep_press");
156
 
        gconf_peditor_new_boolean (NULL,
157
 
                                  CONFIG_ROOT "/slowkeys_beep_press",
158
 
                                  w, NULL);
159
 
 
160
 
        w = NWID ("slowkeys_beep_accept");
161
 
        gconf_peditor_new_boolean (NULL,
162
 
                                  CONFIG_ROOT "/slowkeys_beep_accept",
163
 
                                  w, NULL);
164
 
 
165
 
        w = NWID ("slowkeys_beep_reject");
166
 
        gconf_peditor_new_boolean (NULL,
167
 
                                  CONFIG_ROOT "/slowkeys_beep_reject",
168
 
                                  w, NULL);
169
 
 
170
 
        w = NWID ("bouncekeys_beep_reject");
171
 
        gconf_peditor_new_boolean (NULL,
172
 
                                  CONFIG_ROOT "/bouncekeys_beep_reject",
173
 
                                  w, NULL);
174
 
 
175
 
        w = NWID ("visual_bell_enable");
176
 
        gconf_peditor_new_boolean (NULL, 
177
 
                                   "/apps/metacity/general/visual_bell",
178
 
                                   w, NULL);
179
 
        g_signal_connect (w, "toggled",
180
 
                          G_CALLBACK (visual_bell_enable_toggled_cb), dialog);
181
 
        visual_bell_enable_toggled_cb (w, dialog);
182
 
 
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,
188
 
                                        NULL);
189
 
 
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);
195
 
 
196
 
        gtk_dialog_run (GTK_DIALOG (w));
197
 
 
198
 
        g_object_unref (notifications_dialog);
199
 
        notifications_dialog = NULL;
200
 
}
201
 
 
202
 
static void
203
 
mousekeys_enable_toggled_cb (GtkWidget *w, GtkBuilder *dialog)
204
 
{
205
 
        gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
206
 
        gtk_widget_set_sensitive (WID ("mousekeys_table"), active);
207
 
}
208
 
 
209
 
static GConfValue *
210
 
mousekeys_accel_time_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
211
 
{
212
 
        GtkAdjustment *adjustment;
213
 
        gdouble range_upper;
214
 
        GConfValue *new_value;
215
 
 
216
 
        adjustment = GTK_ADJUSTMENT (gconf_property_editor_get_ui_control (peditor));
217
 
        g_object_get (adjustment,
218
 
                      "upper", &range_upper,
219
 
                      NULL);
220
 
 
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)));
223
 
 
224
 
        return new_value;
225
 
}
226
 
 
227
 
static GConfValue *
228
 
mousekeys_accel_time_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
229
 
{
230
 
        GtkAdjustment *adjustment;
231
 
        gdouble range_value, range_upper;
232
 
        GConfValue *new_value;
233
 
 
234
 
        adjustment = GTK_ADJUSTMENT (gconf_property_editor_get_ui_control (peditor));
235
 
        g_object_get (adjustment,
236
 
                      "value", &range_value,
237
 
                      "upper", &range_upper,
238
 
                      NULL);
239
 
 
240
 
        new_value = gconf_value_new (GCONF_VALUE_INT);
241
 
        gconf_value_set_int (new_value, (int) range_upper - range_value);
242
 
 
243
 
        return new_value;
244
 
}
245
 
 
246
 
void
247
 
setup_a11y_tabs (GtkBuilder *dialog, GConfChangeSet *changeset)
248
 
{
249
 
        GConfClient *client;
250
 
        GtkWidget *w;
251
 
 
252
 
        client = gconf_client_get_default ();
253
 
        gconf_client_add_dir (client, CONFIG_ROOT, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
254
 
        g_object_unref (client);
255
 
 
256
 
        /* Accessibility tab */
257
 
 
258
 
        w = WID ("master_enable");
259
 
        gconf_peditor_new_boolean (changeset,
260
 
                                   CONFIG_ROOT "/enable",
261
 
                                   w, NULL);
262
 
 
263
 
        w = WID ("stickykeys_enable");
264
 
        gconf_peditor_new_boolean (changeset,
265
 
                                   CONFIG_ROOT "/stickykeys_enable",
266
 
                                   w, NULL);
267
 
        g_signal_connect (w, "toggled",
268
 
                          G_CALLBACK (stickykeys_enable_toggled_cb), dialog);
269
 
        stickykeys_enable_toggled_cb (w, dialog);
270
 
 
271
 
        w = WID ("stickykeys_two_key_off");
272
 
        gconf_peditor_new_boolean (changeset,
273
 
                                   CONFIG_ROOT "/stickykeys_two_key_off",
274
 
                                   w, NULL);
275
 
 
276
 
        w = WID ("slowkeys_enable");
277
 
        gconf_peditor_new_boolean (changeset,
278
 
                                   CONFIG_ROOT "/slowkeys_enable",
279
 
                                   w, NULL);
280
 
        g_signal_connect (w, "toggled",
281
 
                          G_CALLBACK (slowkeys_enable_toggled_cb), dialog);
282
 
        slowkeys_enable_toggled_cb (w, dialog);
283
 
 
284
 
        w = WID ("bouncekeys_enable");
285
 
        gconf_peditor_new_boolean (changeset,
286
 
                                   CONFIG_ROOT "/bouncekeys_enable",
287
 
                                   w, NULL);
288
 
        g_signal_connect (w, "toggled",
289
 
                          G_CALLBACK (bouncekeys_enable_toggled_cb), dialog);
290
 
        bouncekeys_enable_toggled_cb (w, dialog);
291
 
 
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);
298
 
 
299
 
        w = WID ("notifications_button");
300
 
        g_signal_connect (w, "clicked",
301
 
                          G_CALLBACK (notifications_button_clicked_cb), dialog);
302
 
 
303
 
        /* Mouse Keys tab */
304
 
 
305
 
        w = WID ("mousekeys_enable");
306
 
        gconf_peditor_new_boolean (changeset,
307
 
                                   CONFIG_ROOT "/mousekeys_enable",
308
 
                                   w, NULL);
309
 
        g_signal_connect (w, "toggled",
310
 
                          G_CALLBACK (mousekeys_enable_toggled_cb), dialog);
311
 
        mousekeys_enable_toggled_cb (w, dialog);
312
 
 
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,
318
 
                                         NULL);
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);
325
 
}