2002-01-08 21:03:07 +00:00
|
|
|
/* -*- mode: c; style: linux -*- */
|
|
|
|
|
|
|
|
/* keyboard-properties.c
|
|
|
|
* Copyright (C) 2000-2001 Ximian, Inc.
|
|
|
|
* Copyright (C) 2001 Jonathan Blandford
|
|
|
|
*
|
|
|
|
* Written by: Bradford Hovinen <hovinen@ximian.com>
|
2002-04-21 21:22:35 +00:00
|
|
|
* Rachel Hestilow <hestilow@ximian.com>
|
2002-01-08 21:03:07 +00:00
|
|
|
* Jonathan Blandford <jrb@redhat.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gnome.h>
|
|
|
|
#include <gconf/gconf-client.h>
|
|
|
|
#include <glade/glade.h>
|
|
|
|
|
|
|
|
#include "capplet-util.h"
|
|
|
|
#include "gconf-property-editor.h"
|
2002-03-11 01:48:31 +00:00
|
|
|
#include "activate-settings-daemon.h"
|
2003-01-08 07:04:42 +00:00
|
|
|
#include "capplet-stock-icons.h"
|
2002-01-08 21:03:07 +00:00
|
|
|
|
2008-01-02 18:02:21 +00:00
|
|
|
#include "gnome-keyboard-properties-a11y.h"
|
2003-11-12 22:00:55 +00:00
|
|
|
#include "gnome-keyboard-properties-xkb.h"
|
|
|
|
|
2007-11-03 02:22:05 +00:00
|
|
|
enum {
|
2002-02-11 04:41:20 +00:00
|
|
|
RESPONSE_APPLY = 1,
|
|
|
|
RESPONSE_CLOSE
|
|
|
|
};
|
|
|
|
|
2002-01-08 21:03:07 +00:00
|
|
|
static GladeXML *
|
|
|
|
create_dialog (void)
|
|
|
|
{
|
|
|
|
GladeXML *dialog;
|
2002-08-15 17:54:10 +00:00
|
|
|
GtkSizeGroup *size_group;
|
2007-05-05 18:57:09 +00:00
|
|
|
GtkWidget *image;
|
2002-01-08 21:03:07 +00:00
|
|
|
|
2007-11-03 02:22:05 +00:00
|
|
|
dialog =
|
|
|
|
glade_xml_new (GNOMECC_GLADE_DIR
|
|
|
|
"/gnome-keyboard-properties.glade",
|
|
|
|
"keyboard_dialog", NULL);
|
2002-01-08 21:03:07 +00:00
|
|
|
|
2002-08-15 17:54:10 +00:00
|
|
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("repeat_slow_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("delay_short_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("blink_slow_label"));
|
2006-01-03 09:57:53 +00:00
|
|
|
g_object_unref (G_OBJECT (size_group));
|
2002-08-15 17:54:10 +00:00
|
|
|
|
|
|
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("repeat_fast_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("delay_long_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("blink_fast_label"));
|
2006-01-03 09:57:53 +00:00
|
|
|
g_object_unref (G_OBJECT (size_group));
|
2002-08-15 17:54:10 +00:00
|
|
|
|
|
|
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("repeat_delay_scale"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("repeat_speed_scale"));
|
2007-11-03 02:22:05 +00:00
|
|
|
gtk_size_group_add_widget (size_group,
|
|
|
|
WID ("cursor_blink_time_scale"));
|
2006-01-03 09:57:53 +00:00
|
|
|
g_object_unref (G_OBJECT (size_group));
|
2002-08-15 17:54:10 +00:00
|
|
|
|
2007-11-03 02:22:05 +00:00
|
|
|
image =
|
|
|
|
gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON);
|
2007-05-05 18:57:09 +00:00
|
|
|
gtk_button_set_image (GTK_BUTTON (WID ("xkb_layouts_add")), image);
|
|
|
|
|
2007-11-03 02:22:05 +00:00
|
|
|
image =
|
|
|
|
gtk_image_new_from_stock (GTK_STOCK_REFRESH,
|
|
|
|
GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (WID ("xkb_reset_to_defaults")),
|
|
|
|
image);
|
2007-05-05 18:57:09 +00:00
|
|
|
|
2002-01-08 21:03:07 +00:00
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
2002-02-12 06:16:11 +00:00
|
|
|
static GConfValue *
|
2007-11-03 02:22:05 +00:00
|
|
|
blink_from_widget (GConfPropertyEditor * peditor, const GConfValue * value)
|
2002-02-12 06:16:11 +00:00
|
|
|
{
|
|
|
|
GConfValue *new_value;
|
|
|
|
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
2007-11-03 02:22:05 +00:00
|
|
|
gconf_value_set_int (new_value,
|
|
|
|
2600 - gconf_value_get_int (value));
|
2002-02-12 06:16:11 +00:00
|
|
|
|
|
|
|
return new_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GConfValue *
|
2007-11-03 02:22:05 +00:00
|
|
|
blink_to_widget (GConfPropertyEditor * peditor, const GConfValue * value)
|
2002-02-12 06:16:11 +00:00
|
|
|
{
|
|
|
|
GConfValue *new_value;
|
|
|
|
gint current_rate;
|
|
|
|
|
|
|
|
current_rate = gconf_value_get_int (value);
|
2003-08-11 17:55:34 +00:00
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
2007-11-03 02:22:05 +00:00
|
|
|
gconf_value_set_int (new_value,
|
|
|
|
CLAMP (2600 - current_rate, 100, 2500));
|
2002-02-12 06:16:11 +00:00
|
|
|
|
|
|
|
return new_value;
|
|
|
|
}
|
|
|
|
|
2002-02-09 05:23:16 +00:00
|
|
|
static void
|
2007-11-03 02:22:05 +00:00
|
|
|
dialog_response (GtkWidget * widget,
|
|
|
|
gint response_id, GConfChangeSet * changeset)
|
2002-02-09 05:23:16 +00:00
|
|
|
{
|
2002-05-29 04:14:29 +00:00
|
|
|
if (response_id == GTK_RESPONSE_HELP)
|
|
|
|
capplet_help (GTK_WINDOW (widget),
|
2007-11-03 02:22:05 +00:00
|
|
|
"user-guide.xml", "goscustperiph-2");
|
2002-05-29 04:14:29 +00:00
|
|
|
else
|
2002-02-11 04:41:20 +00:00
|
|
|
gtk_main_quit ();
|
2002-02-09 05:23:16 +00:00
|
|
|
}
|
|
|
|
|
2002-01-08 21:03:07 +00:00
|
|
|
static void
|
2007-11-03 02:22:05 +00:00
|
|
|
setup_dialog (GladeXML * dialog, GConfChangeSet * changeset)
|
2002-01-08 21:03:07 +00:00
|
|
|
{
|
|
|
|
GObject *peditor;
|
|
|
|
|
|
|
|
/* load all the images */
|
2003-01-08 07:04:42 +00:00
|
|
|
capplet_init_stock_icons ();
|
2007-05-05 18:57:09 +00:00
|
|
|
|
2002-01-08 21:03:07 +00:00
|
|
|
peditor = gconf_peditor_new_boolean
|
2007-11-03 02:22:05 +00:00
|
|
|
(changeset, "/desktop/gnome/peripherals/keyboard/repeat",
|
|
|
|
WID ("repeat_toggle"), NULL);
|
|
|
|
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
|
|
|
|
WID ("repeat_table"));
|
2002-01-08 21:03:07 +00:00
|
|
|
|
2002-07-16 22:07:42 +00:00
|
|
|
gconf_peditor_new_numeric_range
|
2007-11-03 02:22:05 +00:00
|
|
|
(changeset, "/desktop/gnome/peripherals/keyboard/delay",
|
|
|
|
WID ("repeat_delay_scale"), NULL);
|
2002-01-08 21:03:07 +00:00
|
|
|
|
2002-07-16 22:07:42 +00:00
|
|
|
gconf_peditor_new_numeric_range
|
2007-11-03 02:22:05 +00:00
|
|
|
(changeset, "/desktop/gnome/peripherals/keyboard/rate",
|
|
|
|
WID ("repeat_speed_scale"), NULL);
|
2002-01-08 21:03:07 +00:00
|
|
|
|
|
|
|
peditor = gconf_peditor_new_boolean
|
2007-11-03 02:22:05 +00:00
|
|
|
(changeset, "/desktop/gnome/interface/cursor_blink",
|
|
|
|
WID ("cursor_toggle"), NULL);
|
|
|
|
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
|
|
|
|
WID ("cursor_hbox"));
|
|
|
|
gconf_peditor_new_numeric_range (changeset,
|
|
|
|
"/desktop/gnome/interface/cursor_blink_time",
|
|
|
|
WID ("cursor_blink_time_scale"),
|
|
|
|
"conv-to-widget-cb",
|
|
|
|
blink_to_widget,
|
|
|
|
"conv-from-widget-cb",
|
|
|
|
blink_from_widget, NULL);
|
2002-01-08 21:03:07 +00:00
|
|
|
|
2003-06-26 11:40:10 +00:00
|
|
|
/* Ergonomics */
|
2002-01-08 21:03:07 +00:00
|
|
|
peditor = gconf_peditor_new_boolean
|
2007-11-03 02:22:05 +00:00
|
|
|
(changeset, "/desktop/gnome/typing_break/enabled",
|
|
|
|
WID ("break_enabled_toggle"), NULL);
|
|
|
|
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
|
|
|
|
WID ("break_details_table"));
|
|
|
|
gconf_peditor_new_numeric_range (changeset,
|
|
|
|
"/desktop/gnome/typing_break/type_time",
|
|
|
|
WID ("break_enabled_spin"), NULL);
|
|
|
|
gconf_peditor_new_numeric_range (changeset,
|
|
|
|
"/desktop/gnome/typing_break/break_time",
|
|
|
|
WID ("break_interval_spin"),
|
|
|
|
NULL);
|
|
|
|
gconf_peditor_new_boolean (changeset,
|
|
|
|
"/desktop/gnome/typing_break/allow_postpone",
|
|
|
|
WID ("break_postponement_toggle"),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect (G_OBJECT (WID ("keyboard_dialog")), "response",
|
|
|
|
(GCallback) dialog_response, changeset);
|
|
|
|
|
|
|
|
gtk_label_set_use_markup (GTK_LABEL
|
|
|
|
(GTK_BIN (WID ("break_enabled_toggle"))->
|
|
|
|
child), TRUE);
|
|
|
|
|
|
|
|
setup_xkb_tabs (dialog, changeset);
|
2008-01-02 18:02:21 +00:00
|
|
|
setup_a11y_tabs (dialog, changeset);
|
2002-01-08 21:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_legacy_settings (void)
|
|
|
|
{
|
|
|
|
GConfClient *client;
|
|
|
|
gboolean val_bool, def;
|
|
|
|
gulong val_int;
|
|
|
|
|
|
|
|
client = gconf_client_get_default ();
|
|
|
|
|
2007-11-03 02:22:05 +00:00
|
|
|
COPY_FROM_LEGACY (bool,
|
|
|
|
"/gnome/desktop/peripherals/keyboard/repeat",
|
|
|
|
"/Desktop/Keyboard/repeat=true");
|
|
|
|
COPY_FROM_LEGACY (bool,
|
|
|
|
"/gnome/desktop/peripherals/keyboard/click",
|
|
|
|
"/Desktop/Keyboard/click=true");
|
|
|
|
COPY_FROM_LEGACY (int, "/gnome/desktop/peripherals/keyboard/rate",
|
|
|
|
"/Desktop/Keyboard/rate=30");
|
|
|
|
COPY_FROM_LEGACY (int, "/gnome/desktop/peripherals/keyboard/delay",
|
|
|
|
"/Desktop/Keyboard/delay=500");
|
|
|
|
COPY_FROM_LEGACY (int,
|
|
|
|
"/gnome/desktop/peripherals/keyboard/volume",
|
|
|
|
"/Desktop/Keyboard/clickvolume=0");
|
2002-05-16 23:15:14 +00:00
|
|
|
#if 0
|
2007-11-03 02:22:05 +00:00
|
|
|
COPY_FROM_LEGACY (int,
|
|
|
|
"/gnome/desktop/peripherals/keyboard/bell_volume",
|
|
|
|
"/Desktop/Bell/percent=50");
|
2002-05-16 23:15:14 +00:00
|
|
|
#endif
|
2007-11-03 02:22:05 +00:00
|
|
|
COPY_FROM_LEGACY (int,
|
|
|
|
"/gnome/desktop/peripherals/keyboard/bell_pitch",
|
|
|
|
"/Desktop/Bell/pitch=50");
|
|
|
|
COPY_FROM_LEGACY (int,
|
|
|
|
"/gnome/desktop/peripherals/keyboard/bell_duration",
|
|
|
|
"/Desktop/Bell/duration=100");
|
2004-12-20 23:52:41 +00:00
|
|
|
g_object_unref (G_OBJECT (client));
|
2002-01-08 21:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-05-05 18:57:09 +00:00
|
|
|
main (int argc, char **argv)
|
2002-01-08 21:03:07 +00:00
|
|
|
{
|
2007-11-03 02:22:05 +00:00
|
|
|
GConfClient *client;
|
2002-02-11 04:41:20 +00:00
|
|
|
GConfChangeSet *changeset;
|
2007-11-03 02:22:05 +00:00
|
|
|
GladeXML *dialog;
|
2007-01-06 18:53:08 +00:00
|
|
|
GOptionContext *context;
|
2002-01-08 21:03:07 +00:00
|
|
|
|
2003-07-31 21:44:05 +00:00
|
|
|
static gboolean apply_only = FALSE;
|
|
|
|
static gboolean get_legacy = FALSE;
|
|
|
|
static gboolean switch_to_typing_break_page = FALSE;
|
2008-01-02 19:03:10 +00:00
|
|
|
static gboolean switch_to_a11y_page = FALSE;
|
2003-07-31 21:44:05 +00:00
|
|
|
|
2007-01-06 18:53:08 +00:00
|
|
|
static GOptionEntry cap_options[] = {
|
2007-11-03 02:22:05 +00:00
|
|
|
{"apply", 0, 0, G_OPTION_ARG_NONE, &apply_only,
|
|
|
|
N_
|
|
|
|
("Just apply settings and quit (compatibility only; now handled by daemon)"),
|
|
|
|
NULL},
|
|
|
|
{"init-session-settings", 0, 0, G_OPTION_ARG_NONE,
|
|
|
|
&apply_only,
|
|
|
|
N_
|
|
|
|
("Just apply settings and quit (compatibility only; now handled by daemon)"),
|
|
|
|
NULL},
|
|
|
|
{"get-legacy", 0, 0, G_OPTION_ARG_NONE, &get_legacy,
|
|
|
|
N_("Retrieve and store legacy settings"), NULL},
|
|
|
|
{"typing-break", 0, 0, G_OPTION_ARG_NONE,
|
|
|
|
&switch_to_typing_break_page,
|
|
|
|
N_
|
|
|
|
("Start the page with the typing break settings showing"),
|
|
|
|
NULL},
|
2008-01-02 19:03:10 +00:00
|
|
|
{"a11y", 0, 0, G_OPTION_ARG_NONE,
|
|
|
|
&switch_to_a11y_page,
|
|
|
|
N_
|
|
|
|
("Start the page with the accessibility settings showing"),
|
|
|
|
NULL},
|
2007-11-03 02:22:05 +00:00
|
|
|
{NULL}
|
2002-01-08 21:03:07 +00:00
|
|
|
};
|
|
|
|
|
2002-02-27 22:16:27 +00:00
|
|
|
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
|
|
textdomain (GETTEXT_PACKAGE);
|
2002-01-08 21:03:07 +00:00
|
|
|
|
2007-01-07 15:27:08 +00:00
|
|
|
context = g_option_context_new (_("- GNOME Keyboard Preferences"));
|
2007-11-03 02:22:05 +00:00
|
|
|
g_option_context_add_main_entries (context, cap_options,
|
|
|
|
GETTEXT_PACKAGE);
|
2007-01-06 18:53:08 +00:00
|
|
|
|
2007-11-03 02:22:05 +00:00
|
|
|
gnome_program_init ("gnome-keyboard-properties", VERSION,
|
|
|
|
LIBGNOMEUI_MODULE, argc, argv,
|
2007-01-06 18:53:08 +00:00
|
|
|
GNOME_PARAM_GOPTION_CONTEXT, context,
|
2002-01-08 21:03:07 +00:00
|
|
|
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
|
|
|
NULL);
|
|
|
|
|
2002-03-11 01:48:31 +00:00
|
|
|
activate_settings_daemon ();
|
2007-05-05 18:57:09 +00:00
|
|
|
|
2002-01-08 21:03:07 +00:00
|
|
|
client = gconf_client_get_default ();
|
2007-11-03 02:22:05 +00:00
|
|
|
gconf_client_add_dir (client,
|
|
|
|
"/desktop/gnome/peripherals/keyboard",
|
|
|
|
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
|
|
|
gconf_client_add_dir (client, "/desktop/gnome/interface",
|
|
|
|
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
2005-05-22 15:46:45 +00:00
|
|
|
g_object_unref (client);
|
2002-01-08 21:03:07 +00:00
|
|
|
|
|
|
|
if (get_legacy) {
|
|
|
|
get_legacy_settings ();
|
|
|
|
} else {
|
2002-02-12 06:16:11 +00:00
|
|
|
changeset = NULL;
|
2002-01-08 21:03:07 +00:00
|
|
|
dialog = create_dialog ();
|
2002-02-11 04:41:20 +00:00
|
|
|
setup_dialog (dialog, changeset);
|
2003-07-31 21:44:05 +00:00
|
|
|
if (switch_to_typing_break_page) {
|
2007-11-03 02:22:05 +00:00
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK
|
|
|
|
(WID
|
|
|
|
("keyboard_notebook")),
|
2008-01-02 19:03:10 +00:00
|
|
|
4);
|
|
|
|
}
|
|
|
|
else if (switch_to_a11y_page) {
|
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK
|
|
|
|
(WID
|
|
|
|
("keyboard_notebook")),
|
|
|
|
2);
|
|
|
|
|
2003-07-31 21:44:05 +00:00
|
|
|
}
|
2008-01-02 19:03:10 +00:00
|
|
|
|
2002-07-16 22:07:42 +00:00
|
|
|
capplet_set_icon (WID ("keyboard_dialog"),
|
2004-08-20 16:50:57 +00:00
|
|
|
"gnome-dev-keyboard");
|
2002-05-16 23:15:14 +00:00
|
|
|
gtk_widget_show (WID ("keyboard_dialog"));
|
2002-01-08 21:03:07 +00:00
|
|
|
gtk_main ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|