2
* Copyright (C) 2007 Gerd Kohlberger
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.
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.
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/>.
19
#include <glib/gi18n.h>
21
#include "capplet-util.h"
22
#include "gconf-property-editor.h"
24
#define MT_GCONF_HOME "/desktop/gnome/accessibility/mouse"
26
/* 5th entry in combo box */
27
#define DIRECTION_DISABLE 4
38
update_mode_sensitivity (GtkBuilder *dialog, gint mode)
40
gtk_widget_set_sensitive (WID ("box_ctw"), !mode);
41
gtk_widget_set_sensitive (WID ("box_gesture"), mode);
44
/* check if a direction (gesture mode) is already in use */
46
verify_setting (GConfClient *client, gint value, gint type)
48
gint i, ct[N_CLICK_TYPES];
50
ct[CLICK_TYPE_SINGLE] =
51
gconf_client_get_int (client,
52
MT_GCONF_HOME "/dwell_gesture_single",
54
ct[CLICK_TYPE_DOUBLE] =
55
gconf_client_get_int (client,
56
MT_GCONF_HOME "/dwell_gesture_double",
59
gconf_client_get_int (client,
60
MT_GCONF_HOME "/dwell_gesture_drag",
62
ct[CLICK_TYPE_SECONDARY] =
63
gconf_client_get_int (client,
64
MT_GCONF_HOME "/dwell_gesture_secondary",
67
for (i = 0; i < N_CLICK_TYPES; ++i) {
78
populate_gesture_combo (GtkWidget *combo)
84
model = gtk_list_store_new (1, G_TYPE_STRING);
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);
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);
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);
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);
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);
111
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (model));
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,
121
delay_enable_toggled_cb (GtkWidget *checkbox, GtkBuilder *dialog)
123
gtk_widget_set_sensitive (WID ("delay_box"),
124
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)));
128
dwell_enable_toggled_cb (GtkWidget *checkbox, GtkBuilder *dialog)
130
gtk_widget_set_sensitive (WID ("dwell_box"),
131
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)));
135
gesture_single (GtkComboBox *combo, gpointer data)
137
if (!verify_setting (data, gtk_combo_box_get_active (combo), CLICK_TYPE_SINGLE))
138
gtk_combo_box_set_active (combo, DIRECTION_DISABLE);
142
gesture_double (GtkComboBox *combo, gpointer data)
144
if (!verify_setting (data, gtk_combo_box_get_active (combo), CLICK_TYPE_DOUBLE))
145
gtk_combo_box_set_active (combo, DIRECTION_DISABLE);
149
gesture_drag (GtkComboBox *combo, gpointer data)
151
if (!verify_setting (data, gtk_combo_box_get_active (combo), CLICK_TYPE_DRAG))
152
gtk_combo_box_set_active (combo, DIRECTION_DISABLE);
156
gesture_secondary (GtkComboBox *combo, gpointer data)
158
if (!verify_setting (data, gtk_combo_box_get_active (combo), CLICK_TYPE_SECONDARY))
159
gtk_combo_box_set_active (combo, DIRECTION_DISABLE);
163
gconf_value_changed (GConfClient *client,
168
if (g_str_equal (key, MT_GCONF_HOME "/dwell_mode"))
169
update_mode_sensitivity (dialog, gconf_value_get_int (value));
173
setup_accessibility (GtkBuilder *dialog, GConfClient *client)
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);
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);
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);
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"))),
197
update_mode_sensitivity (dialog,
198
gconf_client_get_int (client,
199
MT_GCONF_HOME "/dwell_mode",
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);
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);
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);
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);
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);