1
/* -*- mode: c; style: linux -*- */
3
/* keyboard-properties.c
4
* Copyright (C) 2000-2001 Ximian, Inc.
5
* Copyright (C) 2001 Jonathan Blandford
7
* Written by: Bradford Hovinen <hovinen@ximian.com>
8
* Rachel Hestilow <hestilow@ximian.com>
9
* Jonathan Blandford <jrb@redhat.com>
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2, or (at your option)
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
31
#include <gconf/gconf-client.h>
33
#include "capplet-util.h"
34
#include "gconf-property-editor.h"
35
#include "activate-settings-daemon.h"
36
#include "capplet-stock-icons.h"
38
#include "gnome-keyboard-properties-a11y.h"
39
#include "gnome-keyboard-properties-xkb.h"
50
GtkSizeGroup *size_group;
53
dialog = gtk_builder_new ();
54
gtk_builder_add_from_file (dialog, GNOMECC_UI_DIR
55
"/gnome-keyboard-properties-dialog.ui",
58
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
59
gtk_size_group_add_widget (size_group, WID ("repeat_slow_label"));
60
gtk_size_group_add_widget (size_group, WID ("delay_short_label"));
61
gtk_size_group_add_widget (size_group, WID ("blink_slow_label"));
62
g_object_unref (G_OBJECT (size_group));
64
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
65
gtk_size_group_add_widget (size_group, WID ("repeat_fast_label"));
66
gtk_size_group_add_widget (size_group, WID ("delay_long_label"));
67
gtk_size_group_add_widget (size_group, WID ("blink_fast_label"));
68
g_object_unref (G_OBJECT (size_group));
70
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
71
gtk_size_group_add_widget (size_group, WID ("repeat_delay_scale"));
72
gtk_size_group_add_widget (size_group, WID ("repeat_speed_scale"));
73
gtk_size_group_add_widget (size_group, WID ("cursor_blink_time_scale"));
74
g_object_unref (G_OBJECT (size_group));
76
image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON);
77
gtk_button_set_image (GTK_BUTTON (WID ("xkb_layouts_add")), image);
79
image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON);
80
gtk_button_set_image (GTK_BUTTON (WID ("xkb_reset_to_defaults")), image);
86
blink_from_widget (GConfPropertyEditor * peditor, const GConfValue * value)
88
GConfValue *new_value;
90
new_value = gconf_value_new (GCONF_VALUE_INT);
91
gconf_value_set_int (new_value,
92
2600 - gconf_value_get_int (value));
98
blink_to_widget (GConfPropertyEditor * peditor, const GConfValue * value)
100
GConfValue *new_value;
103
current_rate = gconf_value_get_int (value);
104
new_value = gconf_value_new (GCONF_VALUE_INT);
105
gconf_value_set_int (new_value,
106
CLAMP (2600 - current_rate, 100, 2500));
112
dialog_response (GtkWidget * widget,
113
gint response_id, GConfChangeSet * changeset)
115
if (response_id == GTK_RESPONSE_HELP)
116
capplet_help (GTK_WINDOW (widget), "goscustperiph-2");
122
setup_dialog (GtkBuilder * dialog, GConfChangeSet * changeset)
127
peditor = gconf_peditor_new_boolean
128
(changeset, "/desktop/gnome/peripherals/keyboard/repeat",
129
WID ("repeat_toggle"), NULL);
130
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
131
WID ("repeat_table"));
133
gconf_peditor_new_numeric_range
134
(changeset, "/desktop/gnome/peripherals/keyboard/delay",
135
WID ("repeat_delay_scale"), NULL);
137
gconf_peditor_new_numeric_range
138
(changeset, "/desktop/gnome/peripherals/keyboard/rate",
139
WID ("repeat_speed_scale"), NULL);
141
peditor = gconf_peditor_new_boolean
142
(changeset, "/desktop/gnome/interface/cursor_blink",
143
WID ("cursor_toggle"), NULL);
144
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
145
WID ("cursor_hbox"));
146
gconf_peditor_new_numeric_range (changeset,
147
"/desktop/gnome/interface/cursor_blink_time",
148
WID ("cursor_blink_time_scale"),
151
"conv-from-widget-cb",
152
blink_from_widget, NULL);
155
monitor = g_find_program_in_path ("gnome-typing-monitor");
156
if (monitor != NULL) {
159
peditor = gconf_peditor_new_boolean
160
(changeset, "/desktop/gnome/typing_break/enabled",
161
WID ("break_enabled_toggle"), NULL);
162
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
163
WID ("break_details_table"));
164
gconf_peditor_new_numeric_range (changeset,
165
"/desktop/gnome/typing_break/type_time",
166
WID ("break_enabled_spin"), NULL);
167
gconf_peditor_new_numeric_range (changeset,
168
"/desktop/gnome/typing_break/break_time",
169
WID ("break_interval_spin"),
171
gconf_peditor_new_boolean (changeset,
172
"/desktop/gnome/typing_break/allow_postpone",
173
WID ("break_postponement_toggle"),
177
/* don't show the typing break tab if the daemon is not available */
178
GtkNotebook *nb = GTK_NOTEBOOK (WID ("keyboard_notebook"));
179
gint tb_page = gtk_notebook_page_num (nb, WID ("break_enabled_toggle"));
180
gtk_notebook_remove_page (nb, tb_page);
183
g_signal_connect (WID ("keyboard_dialog"), "response",
184
(GCallback) dialog_response, changeset);
186
setup_xkb_tabs (dialog, changeset);
187
setup_a11y_tabs (dialog, changeset);
191
main (int argc, char **argv)
194
GConfChangeSet *changeset;
196
GOptionContext *context;
198
static gboolean apply_only = FALSE;
199
static gboolean switch_to_typing_break_page = FALSE;
200
static gboolean switch_to_a11y_page = FALSE;
202
static GOptionEntry cap_options[] = {
203
{"apply", 0, 0, G_OPTION_ARG_NONE, &apply_only,
205
("Just apply settings and quit (compatibility only; now handled by daemon)"),
207
{"init-session-settings", 0, 0, G_OPTION_ARG_NONE,
210
("Just apply settings and quit (compatibility only; now handled by daemon)"),
212
{"typing-break", 0, 0, G_OPTION_ARG_NONE,
213
&switch_to_typing_break_page,
215
("Start the page with the typing break settings showing"),
217
{"a11y", 0, 0, G_OPTION_ARG_NONE,
218
&switch_to_a11y_page,
220
("Start the page with the accessibility settings showing"),
226
context = g_option_context_new (_("- GNOME Keyboard Preferences"));
227
g_option_context_add_main_entries (context, cap_options,
230
capplet_init (context, &argc, &argv);
232
activate_settings_daemon ();
234
client = gconf_client_get_default ();
235
gconf_client_add_dir (client,
236
"/desktop/gnome/peripherals/keyboard",
237
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
238
gconf_client_add_dir (client, "/desktop/gnome/interface",
239
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
240
g_object_unref (client);
243
dialog = create_dialog ();
244
setup_dialog (dialog, changeset);
245
if (switch_to_typing_break_page) {
246
gtk_notebook_set_current_page (GTK_NOTEBOOK
248
("keyboard_notebook")),
251
else if (switch_to_a11y_page) {
252
gtk_notebook_set_current_page (GTK_NOTEBOOK
254
("keyboard_notebook")),
259
capplet_set_icon (WID ("keyboard_dialog"),
260
"preferences-desktop-keyboard");
261
gtk_widget_show (WID ("keyboard_dialog"));