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

« back to all changes in this revision

Viewing changes to capplets/mouse/gnome-mouse-accessibility.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
 
/*
2
 
 * Copyright (C) 2007 Gerd Kohlberger
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation, either version 2 of the License, or
7
 
 * (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
 */
17
 
 
18
 
#include <gtk/gtk.h>
19
 
#include <glib/gi18n.h>
20
 
 
21
 
#include "capplet-util.h"
22
 
#include "gconf-property-editor.h"
23
 
 
24
 
#define MT_GCONF_HOME "/desktop/gnome/accessibility/mouse"
25
 
 
26
 
/* 5th entry in combo box */
27
 
#define DIRECTION_DISABLE 4
28
 
 
29
 
enum {
30
 
        CLICK_TYPE_SINGLE,
31
 
        CLICK_TYPE_DOUBLE,
32
 
        CLICK_TYPE_DRAG,
33
 
        CLICK_TYPE_SECONDARY,
34
 
        N_CLICK_TYPES
35
 
};
36
 
 
37
 
static void
38
 
update_mode_sensitivity (GtkBuilder *dialog, gint mode)
39
 
{
40
 
        gtk_widget_set_sensitive (WID ("box_ctw"), !mode);
41
 
        gtk_widget_set_sensitive (WID ("box_gesture"), mode);
42
 
}
43
 
 
44
 
/* check if a direction (gesture mode) is already in use */
45
 
static gboolean
46
 
verify_setting (GConfClient *client, gint value, gint type)
47
 
{
48
 
        gint i, ct[N_CLICK_TYPES];
49
 
 
50
 
        ct[CLICK_TYPE_SINGLE] =
51
 
                gconf_client_get_int (client,
52
 
                                      MT_GCONF_HOME "/dwell_gesture_single",
53
 
                                      NULL);
54
 
        ct[CLICK_TYPE_DOUBLE] =
55
 
                gconf_client_get_int (client,
56
 
                                      MT_GCONF_HOME "/dwell_gesture_double",
57
 
                                      NULL);
58
 
        ct[CLICK_TYPE_DRAG] =
59
 
                gconf_client_get_int (client,
60
 
                                      MT_GCONF_HOME "/dwell_gesture_drag",
61
 
                                      NULL);
62
 
        ct[CLICK_TYPE_SECONDARY] =
63
 
                gconf_client_get_int (client,
64
 
                                      MT_GCONF_HOME "/dwell_gesture_secondary",
65
 
                                      NULL);
66
 
 
67
 
        for (i = 0; i < N_CLICK_TYPES; ++i) {
68
 
                if (i == type)
69
 
                        continue;
70
 
                if (ct[i] == value)
71
 
                        return FALSE;
72
 
        }
73
 
 
74
 
        return TRUE;
75
 
}
76
 
 
77
 
static void
78
 
populate_gesture_combo (GtkWidget *combo)
79
 
{
80
 
        GtkListStore *model;
81
 
        GtkTreeIter iter;
82
 
        GtkCellRenderer *cr;
83
 
 
84
 
        model = gtk_list_store_new (1, G_TYPE_STRING);
85
 
 
86
 
        gtk_list_store_append (model, &iter);
87
 
        /* Translators: this is the gesture to trigger/choose the click type.
88
 
           Don't include the prefix "gesture|" in the translation. */
89
 
        gtk_list_store_set (model, &iter, 0, Q_("gesture|Move left"), -1);
90
 
 
91
 
        gtk_list_store_append (model, &iter);
92
 
        /* Translators: this is the gesture to trigger/choose the click type.
93
 
           Don't include the prefix "gesture|" in the translation. */
94
 
        gtk_list_store_set (model, &iter, 0, Q_("gesture|Move right"), -1);
95
 
 
96
 
        gtk_list_store_append (model, &iter);
97
 
        /* Translators: this is the gesture to trigger/choose the click type.
98
 
           Don't include the prefix "gesture|" in the translation. */
99
 
        gtk_list_store_set (model, &iter, 0, Q_("gesture|Move up"), -1);
100
 
 
101
 
        gtk_list_store_append (model, &iter);
102
 
        /* Translators: this is the gesture to trigger/choose the click type.
103
 
           Don't include the prefix "gesture|" in the translation. */
104
 
        gtk_list_store_set (model, &iter, 0, Q_("gesture|Move down"), -1);
105
 
 
106
 
        gtk_list_store_append (model, &iter);
107
 
        /* Translators: this is the gesture to trigger/choose the click type.
108
 
           Don't include the prefix "gesture|" in the translation. */
109
 
        gtk_list_store_set (model, &iter, 0, Q_("gesture|Disabled"), -1);
110
 
 
111
 
        gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (model));
112
 
 
113
 
        cr = gtk_cell_renderer_text_new ();
114
 
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cr, TRUE);
115
 
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cr,
116
 
                                        "text", 0,
117
 
                                        NULL);
118
 
}
119
 
 
120
 
static void
121
 
delay_enable_toggled_cb (GtkWidget *checkbox, GtkBuilder *dialog)
122
 
{
123
 
        gtk_widget_set_sensitive (WID ("delay_box"),
124
 
                                  gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)));
125
 
}
126
 
 
127
 
static void
128
 
dwell_enable_toggled_cb (GtkWidget *checkbox, GtkBuilder *dialog)
129
 
{
130
 
        gtk_widget_set_sensitive (WID ("dwell_box"),
131
 
                                  gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)));
132
 
}
133
 
 
134
 
static void
135
 
gesture_single (GtkComboBox *combo, gpointer data)
136
 
{
137
 
        if (!verify_setting (data, gtk_combo_box_get_active (combo), CLICK_TYPE_SINGLE))
138
 
                gtk_combo_box_set_active (combo, DIRECTION_DISABLE);
139
 
}
140
 
 
141
 
static void
142
 
gesture_double (GtkComboBox *combo, gpointer data)
143
 
{
144
 
        if (!verify_setting (data, gtk_combo_box_get_active (combo), CLICK_TYPE_DOUBLE))
145
 
                gtk_combo_box_set_active (combo, DIRECTION_DISABLE);
146
 
}
147
 
 
148
 
static void
149
 
gesture_drag (GtkComboBox *combo, gpointer data)
150
 
{
151
 
        if (!verify_setting (data, gtk_combo_box_get_active (combo), CLICK_TYPE_DRAG))
152
 
                gtk_combo_box_set_active (combo, DIRECTION_DISABLE);
153
 
}
154
 
 
155
 
static void
156
 
gesture_secondary (GtkComboBox *combo, gpointer data)
157
 
{
158
 
        if (!verify_setting (data, gtk_combo_box_get_active (combo), CLICK_TYPE_SECONDARY))
159
 
                gtk_combo_box_set_active (combo, DIRECTION_DISABLE);
160
 
}
161
 
 
162
 
static void
163
 
gconf_value_changed (GConfClient *client,
164
 
                     const gchar *key,
165
 
                     GConfValue  *value,
166
 
                     gpointer     dialog)
167
 
{
168
 
        if (g_str_equal (key, MT_GCONF_HOME "/dwell_mode"))
169
 
                update_mode_sensitivity (dialog, gconf_value_get_int (value));
170
 
}
171
 
 
172
 
void
173
 
setup_accessibility (GtkBuilder *dialog, GConfClient *client)
174
 
{
175
 
        gconf_client_add_dir (client, MT_GCONF_HOME,
176
 
                              GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
177
 
        g_signal_connect (client, "value_changed",
178
 
                          G_CALLBACK (gconf_value_changed), dialog);
179
 
 
180
 
        gconf_peditor_new_boolean (NULL, MT_GCONF_HOME "/dwell_enable",
181
 
                                   WID ("dwell_enable"), NULL);
182
 
        gconf_peditor_new_boolean (NULL, MT_GCONF_HOME "/delay_enable",
183
 
                                   WID ("delay_enable"), NULL);
184
 
        gconf_peditor_new_boolean (NULL, MT_GCONF_HOME "/dwell_show_ctw",
185
 
                                   WID ("dwell_show_ctw"), NULL);
186
 
 
187
 
        gconf_peditor_new_numeric_range (NULL, MT_GCONF_HOME "/delay_time",
188
 
                                         WID ("delay_time"), NULL);
189
 
        gconf_peditor_new_numeric_range (NULL, MT_GCONF_HOME "/dwell_time",
190
 
                                         WID ("dwell_time"), NULL);
191
 
        gconf_peditor_new_numeric_range (NULL, MT_GCONF_HOME "/threshold",
192
 
                                         WID ("threshold"), NULL);
193
 
 
194
 
        gconf_peditor_new_select_radio (NULL, MT_GCONF_HOME "/dwell_mode",
195
 
                                        gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("dwell_mode_ctw"))),
196
 
                                                                                      NULL);
197
 
        update_mode_sensitivity (dialog,
198
 
                                 gconf_client_get_int (client,
199
 
                                                       MT_GCONF_HOME "/dwell_mode",
200
 
                                                       NULL));
201
 
 
202
 
        populate_gesture_combo (WID ("dwell_gest_single"));
203
 
        gconf_peditor_new_combo_box (NULL, MT_GCONF_HOME "/dwell_gesture_single",
204
 
                                     WID ("dwell_gest_single"), NULL);
205
 
        g_signal_connect (WID ("dwell_gest_single"), "changed",
206
 
                          G_CALLBACK (gesture_single), client);
207
 
 
208
 
        populate_gesture_combo (WID ("dwell_gest_double"));
209
 
        gconf_peditor_new_combo_box (NULL, MT_GCONF_HOME "/dwell_gesture_double",
210
 
                                     WID ("dwell_gest_double"), NULL);
211
 
        g_signal_connect (WID ("dwell_gest_double"), "changed",
212
 
                          G_CALLBACK (gesture_double), client);
213
 
 
214
 
        populate_gesture_combo (WID ("dwell_gest_drag"));
215
 
        gconf_peditor_new_combo_box (NULL, MT_GCONF_HOME "/dwell_gesture_drag",
216
 
                                     WID ("dwell_gest_drag"), NULL);
217
 
        g_signal_connect (WID ("dwell_gest_drag"), "changed",
218
 
                          G_CALLBACK (gesture_drag), client);
219
 
 
220
 
        populate_gesture_combo (WID ("dwell_gest_secondary"));
221
 
        gconf_peditor_new_combo_box (NULL, MT_GCONF_HOME "/dwell_gesture_secondary",
222
 
                                     WID ("dwell_gest_secondary"), NULL);
223
 
        g_signal_connect (WID ("dwell_gest_secondary"), "changed",
224
 
                          G_CALLBACK (gesture_secondary), client);
225
 
 
226
 
        g_signal_connect (WID ("delay_enable"), "toggled",
227
 
                          G_CALLBACK (delay_enable_toggled_cb), dialog);
228
 
        delay_enable_toggled_cb (WID ("delay_enable"), dialog);
229
 
        g_signal_connect (WID ("dwell_enable"), "toggled",
230
 
                          G_CALLBACK (dwell_enable_toggled_cb), dialog);
231
 
        dwell_enable_toggled_cb (WID ("dwell_enable"), dialog);
232
 
}