Add AccessX capplet.

This commit is contained in:
Jody Goldberg 2002-03-23 04:39:24 +00:00
parent d37c0f9d73
commit 5399ce0b1a
19 changed files with 403 additions and 12 deletions

View file

@ -1,5 +1,6 @@
always_built_SUBDIRS = \
common default-applications desktop-links \
common accessibility \
default-applications desktop-links \
background keyboard mouse sound \
file-types theme-switcher ui-properties \
screensaver font keybindings

View file

@ -0,0 +1,2 @@
Makefile
Makefile.in

View file

@ -0,0 +1 @@
SUBDIRS = keyboard

View file

@ -974,6 +974,9 @@ peditor_numeric_range_value_changed (GConfClient *client,
if (value != NULL) {
value_wid = peditor->p->conv_to_widget_cb (peditor, value);
g_return_if_fail (value_wid->type == GCONF_VALUE_FLOAT);
gtk_adjustment_set_value (GTK_ADJUSTMENT (peditor->p->ui_control), gconf_value_get_float (value_wid));
gconf_value_free (value_wid);
}

View file

@ -4,5 +4,9 @@ cd.desktop
cd.desktop.in
legacy-applications.desktop
legacy-applications.desktop.in
session.desktop
session.desktop.in
Advanced.directory
Advanced.directory.in
Accessibility.directory
Accessibility.directory.in

View file

@ -0,0 +1,5 @@
[Desktop Entry]
_Name=Accessibility
_Comment=Accessibility Settings
Type=Directory
Icon=accessibility-directory.png

View file

@ -6,7 +6,7 @@ capplets =
## Pixmaps
pixmaps_pre = $(capplets:=-capplet.png)
pixmaps_DATA = $(pixmaps_pre) advanced-directory.png
pixmaps_DATA = $(pixmaps_pre) advanced-directory.png accessibility-directory.png
pixmapsdir = $(GNOMECC_ICONS_DIR)
##
@ -40,7 +40,7 @@ all-local: $(desktop_files) $(groups_files)
## foo.directory.in is merged with the translations to create foo.directory
## foo.directory is installed and renamed
##
groups = Advanced
groups = Advanced Accessibility
groups_files = $(groups:=.directory)
groups_in_files = $(groups_files:.directory=.directory.in)
groups_in_in_files = $(groups_files:.directory=.directory.in.in)

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

View file

@ -1,3 +1,13 @@
2002-03-19 Jody Goldberg <jody@gnome.org>
* gnome-keyboard-properties.c (_to_widget) : fix signature.
(*_from_widget) : fix signature.
2002-03-13 Jody Goldberg <jody@gnome.org>
* gnome-keyboard-properties.c (setup_accessibility) : new.
(main) : install the accessibility page.
2002-03-19 Richard Hestilow <hestilow@ximian.com>
* gnome-keyboard-properties.c (bell_enums): Swap around. This

View file

@ -1,7 +1,9 @@
bin_PROGRAMS = gnome2-keyboard-properties
gnome2_keyboard_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS)
gnome2_keyboard_properties_SOURCES = gnome-keyboard-properties.c
gnome2_keyboard_properties_LDADD = \
../accessibility/keyboard/libaccessibility-keyboard.a \
$(GNOMECC_CAPPLETS_LIBS)
@INTLTOOL_DESKTOP_RULE@

View file

@ -35,6 +35,7 @@
#include "capplet-util.h"
#include "gconf-property-editor.h"
#include "activate-settings-daemon.h"
#include <../accessibility/keyboard/accessibility-keyboard.h>
enum
{
@ -53,7 +54,7 @@ create_dialog (void)
}
static GConfValue *
rate_to_widget (GConfPropertyEditor *peditor, GConfValue *value)
rate_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
{
GConfValue *new_value;
int rate;
@ -75,7 +76,7 @@ rate_to_widget (GConfPropertyEditor *peditor, GConfValue *value)
}
static GConfValue *
rate_from_widget (GConfPropertyEditor *peditor, GConfValue *value)
rate_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
{
static int rates[] = {
255, 192, 64, 1
@ -90,7 +91,7 @@ rate_from_widget (GConfPropertyEditor *peditor, GConfValue *value)
}
static GConfValue *
delay_to_widget (GConfPropertyEditor *peditor, GConfValue *value)
delay_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
{
GConfValue *new_value;
int delay;
@ -132,7 +133,7 @@ static GConfEnumStringPair bell_enums[] = {
};
static GConfValue *
bell_from_widget (GConfPropertyEditor *peditor, GConfValue *value)
bell_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
{
GConfValue *new_value;
@ -144,7 +145,7 @@ bell_from_widget (GConfPropertyEditor *peditor, GConfValue *value)
}
static GConfValue *
bell_to_widget (GConfPropertyEditor *peditor, GConfValue *value)
bell_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
{
GConfValue *new_value;
gint val = 2;
@ -162,7 +163,7 @@ bell_to_widget (GConfPropertyEditor *peditor, GConfValue *value)
static GConfValue *
blink_from_widget (GConfPropertyEditor *peditor, GConfValue *value)
blink_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
{
GConfValue *new_value;
@ -173,7 +174,7 @@ blink_from_widget (GConfPropertyEditor *peditor, GConfValue *value)
}
static GConfValue *
blink_to_widget (GConfPropertyEditor *peditor, GConfValue *value)
blink_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
{
GConfValue *new_value;
gint current_rate;
@ -303,6 +304,14 @@ get_legacy_settings (void)
COPY_FROM_LEGACY (int, "/gnome/desktop/peripherals/keyboard/bell_duration", "/Desktop/Bell/duration=100");
}
static void
setup_accessibility (GladeXML *dialog, GConfChangeSet *changeset)
{
GtkWidget *notebook = WID ("notebook1");
GtkWidget *label = gtk_label_new (_("Accessibility"));
GtkWidget *page = setup_accessX_dialog (changeset, FALSE);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
}
int
main (int argc, char **argv)
@ -344,6 +353,7 @@ main (int argc, char **argv)
changeset = NULL;
dialog = create_dialog ();
setup_dialog (dialog, changeset);
setup_accessibility (dialog, changeset);
gtk_widget_show_all (WID ("keyboard_dialog"));
gtk_main ();

View file

@ -39,6 +39,7 @@ AC_CHECK_FUNCS(setenv,[AC_DEFINE(HAVE_SETENV)])
dnl keyboard-properties-capplet
AC_CHECK_HEADERS(X11/extensions/xf86misc.h, XF86MISC_LIBS="-lXxf86misc")
AC_SUBST(XF86MISC_LIBS)
AC_CHECK_HEADERS(X11/extensions/XKB.h)
dnl ==============================================
dnl Check that we meet the dependencies
@ -205,5 +206,7 @@ capplets/sound/Makefile
capplets/theme-switcher/Makefile
capplets/theme-switcher/control/Makefile
capplets/ui-properties/Makefile
capplets/accessibility/Makefile
capplets/accessibility/keyboard/Makefile
schemas/Makefile
libsounds/Makefile])

View file

@ -1,3 +1,8 @@
Makefile
Makefile.in
gnome2-settings-daemon
GNOME_SettingsDaemon-common.c
GNOME_SettingsDaemon-skels.c
GNOME_SettingsDaemon-stubs.c
GNOME_SettingsDaemon.h
GNOME_SettingsDaemon.server

View file

@ -20,6 +20,8 @@ gnome2_settings_daemon_SOURCES = \
gnome-settings-locate-pointer.h \
gnome-settings-sound.c \
gnome-settings-sound.h \
gnome-settings-accessibility-keyboard.h \
gnome-settings-accessibility-keyboard.c \
xsettings-common.c \
xsettings-manager.c \
xsettings-common.h \
@ -62,4 +64,4 @@ CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
$(BUILT_SOURCES) \
$(server_DATA) \
$(server_in_files) \
$(server_in_files) \

View file

@ -0,0 +1,300 @@
/* gnome-settings-keyboard.c
*
* Copyright © 2001 Ximian, Inc.
*
* Written by Bradford Hovinen <hovinen@ximian.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.
*/
#include "config.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gconf/gconf-client.h>
#include "gnome-settings-accessibility-keyboard.h"
#include "gnome-settings-daemon.h"
#ifdef HAVE_X11_EXTENSIONS_XKB_H
# include <X11/XKBlib.h>
# include <X11/extensions/XKBstr.h>
#define CONFIG_ROOT "/desktop/gnome/accesibility/keyboard"
static gboolean we_are_changing_xkb_state = FALSE;
static int
get_int (GConfClient *client, char const *key)
{
int res = gconf_client_get_int (client, key, NULL);
if (res <= 0)
res = 1;
return res;
}
static void
set_int (GConfClient *client, char const *key, int val)
{
GError *err;
if (!gconf_client_set_int (client, key, val, &err)) {
g_warning (err->message);
g_error_free (err);
}
}
static void
set_bool (GConfClient *client, char const *key, int val)
{
GError *err;
if (!gconf_client_set_bool (client, key, val ? TRUE : FALSE, &err)) {
g_warning (err->message);
g_error_free (err);
}
}
static void
set_server_from_gconf (GConfEntry *ignored)
{
unsigned long which;
gint32 enabled, enable_mask;
XkbDescRec *desc;
GConfClient *client = gconf_client_get_default ();
if (!we_are_changing_xkb_state) {
fprintf (stderr, "We changed gconf accessibility state\n");
return;
} else
fprintf (stderr, "Someone changed gcond accessibility state\n");
enable_mask = XkbAccessXKeysMask |
XkbSlowKeysMask |
XkbBounceKeysMask |
XkbStickyKeysMask |
XkbMouseKeysMask |
XkbMouseKeysAccelMask |
XkbAccessXKeysMask |
XkbAccessXTimeoutMask |
XkbAccessXFeedbackMask;
enabled = XkbAccessXFeedbackMask;
desc = XkbGetMap(GDK_DISPLAY (), 0, XkbUseCoreKbd);
XkbGetControls (GDK_DISPLAY (), XkbAllControlsMask, desc);
desc->ctrls->ax_options = XkbAX_LatchToLockMask;
/* general */
if (gconf_client_get_bool (client, CONFIG_ROOT "/enable", NULL))
enabled |= XkbAccessXKeysMask;
if (gconf_client_get_bool (client, CONFIG_ROOT "/feature_state_change_beep", NULL))
desc->ctrls->ax_options |= XkbAX_FeatureFBMask | XkbAX_SlowWarnFBMask;
if (gconf_client_get_bool (client, CONFIG_ROOT "/timeout_enable", NULL))
enabled |= XkbAccessXTimeoutMask;
desc->ctrls->ax_timeout = get_int (client,
CONFIG_ROOT "/timeout");
/* bounce keys */
if (gconf_client_get_bool (client, CONFIG_ROOT "/bouncekeys_enable", NULL))
enabled |= XkbBounceKeysMask;
if (gconf_client_get_bool (client, CONFIG_ROOT "/bouncekeys_beep_reject", NULL))
enabled |= XkbAX_BKRejectFBMask;
desc->ctrls->debounce_delay = get_int (client,
CONFIG_ROOT "/bouncekeys_delay");
/* mouse keys */
if (gconf_client_get_bool (client, CONFIG_ROOT "/mousekeys_enable", NULL))
enabled |= XkbMouseKeysMask;
desc->ctrls->mk_interval = 10;
desc->ctrls->mk_curve = 50;
desc->ctrls->mk_max_speed = get_int (client,
CONFIG_ROOT "/mousekeys_max_speed");
desc->ctrls->mk_time_to_max = get_int (client,
CONFIG_ROOT "/mousekeys_accel_time");
desc->ctrls->mk_delay = get_int (client,
CONFIG_ROOT "/mousekeys_init_delay");
/* slow keys */
if (gconf_client_get_bool (client, CONFIG_ROOT "/slowkeys_enable", NULL))
enabled |= XkbSlowKeysMask;
if (gconf_client_get_bool (client, CONFIG_ROOT "/slowkeys_beep_press", NULL))
desc->ctrls->ax_options |= XkbAX_SKPressFBMask;
if (gconf_client_get_bool (client, CONFIG_ROOT "/slowkeys_beep_accept", NULL))
desc->ctrls->ax_options |= XkbAX_SKAcceptFBMask;
if (gconf_client_get_bool (client, CONFIG_ROOT "/slowkeys_beep_reject", NULL))
enabled |= XkbAX_SKRejectFBMask;
desc->ctrls->slow_keys_delay = get_int (client,
CONFIG_ROOT "/slowkeys_delay");
/* sticky keys */
if (gconf_client_get_bool (client, CONFIG_ROOT "/stickykeys_enable", NULL))
enabled |= XkbStickyKeysMask;
if (gconf_client_get_bool (client, CONFIG_ROOT "/stickykeys_two_key_off", NULL))
desc->ctrls->ax_options |= XkbAX_TwoKeysMask;
if (gconf_client_get_bool (client, CONFIG_ROOT "/stickykeys_modifier_beep", NULL))
desc->ctrls->ax_options |= XkbAX_StickyKeysFBMask;
/* toggle keys */
if (gconf_client_get_bool (client, CONFIG_ROOT "/togglekeys_enable", NULL))
desc->ctrls->ax_options |= XkbAX_IndicatorFBMask;
desc->ctrls->enabled_ctrls &= ~enable_mask;
desc->ctrls->enabled_ctrls |= (enable_mask & enabled);
/* guard against reloading gconf when the X server notices that the XKB
* state has changed and calls us.
*/
g_return_if_fail (!we_are_changing_xkb_state);
which = XkbAccessXKeysMask | XkbAccessXTimeoutMask |
XkbControlsEnabledMask |
XkbMouseKeysMask | XkbMouseKeysAccelMask |
XkbSlowKeysMask | XkbBounceKeysMask;
we_are_changing_xkb_state = TRUE;
XkbSetControls (GDK_DISPLAY (), which, desc);
XFlush (GDK_DISPLAY ());
we_are_changing_xkb_state = FALSE;
}
static void
set_gconf_from_server (GConfEntry *ignored)
{
XkbDescRec *desc;
GConfClient *client = gconf_client_get_default ();
desc = XkbGetMap(GDK_DISPLAY (), 0, XkbUseCoreKbd);
XkbGetControls (GDK_DISPLAY (), XkbAllControlsMask, desc);
desc->ctrls->ax_options = XkbAX_LatchToLockMask;
/* guard against reloading the server when gconf notices that the state
* has changed and calls us.
*/
g_return_if_fail (!we_are_changing_xkb_state);
we_are_changing_xkb_state = TRUE;
set_bool (client, CONFIG_ROOT "/enable",
desc->ctrls->enabled_ctrls & XkbAccessXKeysMask);
set_bool (client, CONFIG_ROOT "/feature_state_change_beep",
desc->ctrls->ax_options & (XkbAX_FeatureFBMask | XkbAX_SlowWarnFBMask));
set_bool (client, CONFIG_ROOT "/timeout_enable",
desc->ctrls->enabled_ctrls & XkbAccessXTimeoutMask);
set_int (client, CONFIG_ROOT "/timeout",
desc->ctrls->ax_timeout);
set_bool (client, CONFIG_ROOT "/bouncekeys_enable",
desc->ctrls->enabled_ctrls & XkbBounceKeysMask);
set_int (client, CONFIG_ROOT "/bouncekeys_delay",
desc->ctrls->debounce_delay);
set_bool (client, CONFIG_ROOT "/bouncekeys_beep_reject",
desc->ctrls->enabled_ctrls & XkbAX_BKRejectFBMask);
set_bool (client, CONFIG_ROOT "/mousekeys_enable",
desc->ctrls->enabled_ctrls & XkbMouseKeysMask);
set_int (client, CONFIG_ROOT "/mousekeys_max_speed",
desc->ctrls->mk_max_speed);
set_int (client, CONFIG_ROOT "/mousekeys_accel_time",
desc->ctrls->mk_time_to_max);
set_int (client, CONFIG_ROOT "/mousekeys_init_delay",
desc->ctrls->mk_delay);
set_bool (client, CONFIG_ROOT "/slowkeys_enable",
desc->ctrls->enabled_ctrls & XkbSlowKeysMask);
set_bool (client, CONFIG_ROOT "/slowkeys_beep_press",
desc->ctrls->ax_options & XkbAX_SKPressFBMask);
set_bool (client, CONFIG_ROOT "/slowkeys_beep_accept",
desc->ctrls->ax_options & XkbAX_SKAcceptFBMask);
set_bool (client, CONFIG_ROOT "/slowkeys_beep_reject",
desc->ctrls->enabled_ctrls & XkbAX_SKRejectFBMask);
set_int (client, CONFIG_ROOT "/slowkeys_delay",
desc->ctrls->slow_keys_delay);
set_bool (client, CONFIG_ROOT "/stickykeys_enable",
desc->ctrls->enabled_ctrls & XkbStickyKeysMask);
set_bool (client, CONFIG_ROOT "/stickykeys_two_key_off",
desc->ctrls->ax_options & XkbAX_TwoKeysMask);
set_bool (client, CONFIG_ROOT "/stickykeys_modifier_beep",
desc->ctrls->ax_options & XkbAX_StickyKeysFBMask);
set_bool (client, CONFIG_ROOT "/togglekeys_enable",
desc->ctrls->ax_options & XkbAX_IndicatorFBMask);
we_are_changing_xkb_state = FALSE;
}
static int xkbEventBase;
static GdkFilterReturn
cb_xkb_event_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user)
{
XEvent *xev = (XEvent *)xevent;
if (xev->xany.type == (xkbEventBase + XkbEventCode)) {
XkbEvent *xkbEv = (XkbEvent *) event;
fprintf (stderr, "xkb event\n");
if(xkbEv->any.xkb_type == XkbControlsNotify) {
if (!we_are_changing_xkb_state) {
fprintf (stderr, "Someone changed XKB state\n");
set_gconf_from_server (NULL);
} else
fprintf (stderr, "We changed XKB state\n");
}
return GDK_FILTER_REMOVE;
}
return GDK_FILTER_CONTINUE;
}
/**
* gnome_settings_accessibility_keyboard_init :
*
* If the display supports XKB initialize it.
*/
void
gnome_settings_accessibility_keyboard_init (GConfClient *client)
{
int opcode, errorBase, major, minor;
if (!XkbQueryExtension (GDK_DISPLAY (),
&opcode, &xkbEventBase, &errorBase, &major, &minor) ||
!XkbUseExtension (GDK_DISPLAY (), &major, &minor))
return;
XkbSelectEvents (GDK_DISPLAY (),
XkbUseCoreKbd, XkbAllEventsMask, XkbAllEventsMask);
gdk_window_add_filter (NULL, &cb_xkb_event_filter, NULL);
gnome_settings_daemon_register_callback (CONFIG_ROOT, &set_server_from_gconf);
}
void
gnome_settings_accessibility_keyboard_load (GConfClient *client)
{
set_server_from_gconf (NULL);
}
#else
void
gnome_settings_accessibility_keyboard_init (GConfClient *client)
{
g_warning ("Unsupported in this build");
}
void
gnome_settings_accessibility_keyboard_load (GConfClient *client)
{
g_warning ("Unsupported in this build");
}
#endif

View file

@ -0,0 +1,32 @@
/* gnome-settings-accessibility-keyboard.h
*
* Copyright © 2002 Ximian, Inc.
*
* Written by Jody Goldberg <jody@gnome.org>
*
* 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.
*/
#ifndef __GNOME_SETTINGS_ACCESSIBILITY_KEYBOARD_H
#define __GNOME_SETTINGS_ACCESSIBILITY_KEYBOARD_H
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
void gnome_settings_accessibility_keyboard_init (GConfClient *client);
void gnome_settings_accessibility_keyboard_load (GConfClient *client);
#endif /* __GNOME_SETTINGS_ACCESSIBILITY_KEYBOARD_H */

View file

@ -40,6 +40,7 @@
#include "gnome-settings-background.h"
#include "gnome-settings-sound.h"
#include "gnome-settings-wm.h"
#include "gnome-settings-accessibility-keyboard.h"
#include "GNOME_SettingsDaemon.h"
@ -226,6 +227,7 @@ gnome_settings_daemon_new (void)
gnome_settings_background_init (client);
gnome_settings_sound_init (client);
gnome_settings_wm_init (client);
gnome_settings_accessibility_keyboard_init (client);
for (list = directories; list; list = list->next)
{
@ -258,6 +260,7 @@ gnome_settings_daemon_new (void)
gnome_settings_sound_load (client);
gnome_settings_background_load (client);
gnome_settings_wm_load (client);
gnome_settings_accessibility_keyboard_load (client);
return G_OBJECT (daemon);
}

View file

@ -19,6 +19,10 @@
* ms.po: Updated Malay Translation.
2002-03-20 Jody Goldberg <jody@gnome.org>
* POTFILES.in : Add accessibility/keyboard
2002-03-19 Richard Hestilow <hestilow@ximian.com>
* POTFILES.in: Add activate-settings-daemon.c.

View file

@ -1,4 +1,7 @@
# Add files with translateable strings here.
capplets/accessibility/keyboard/accessibility-keyboard.c
capplets/accessibility/keyboard/gnome-accessibility-keyboard-properties.glade2
capplets/accessibility/keyboard/gnome-accessibility-keyboard-properties.c
capplets/background/background.desktop.in
capplets/background/background-properties-capplet.c
capplets/background/background-properties.glade
@ -8,6 +11,7 @@ capplets/common/activate-settings-daemon.c
capplets/default-applications/default-applications.desktop.in
capplets/default-applications/gnome-default-applications-properties.c
capplets/default-applications/gnome-default-applications-properties.glade
capplets/desktop-links/Accessibility.directory.in.in
capplets/desktop-links/Advanced.directory.in.in
capplets/desktop-links/cd.desktop.in.in
capplets/desktop-links/legacy-applications.desktop.in.in