~ubuntu-branches/ubuntu/breezy/control-center/breezy

« back to all changes in this revision

Viewing changes to capplets/accessibility/keyboard/gnome-accessibility-keyboard-properties.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2005-03-17 22:28:32 UTC
  • Revision ID: james.westby@ubuntu.com-20050317222832-r2cw3974bm9qjrva
Tags: upstream-2.8.2
ImportĀ upstreamĀ versionĀ 2.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c; style: linux -*- */
 
2
 
 
3
/* gnome-accessibility-keyboard-properties.c
 
4
 * Copyright (C) 2002 Ximian, Inc.
 
5
 *
 
6
 * Written by: Jody Goldberg <jody@gnome.org>
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2, or (at your option)
 
11
 * any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
21
 * 02111-1307, USA.
 
22
 */
 
23
 
 
24
#ifdef HAVE_CONFIG_H
 
25
#  include <config.h>
 
26
#endif
 
27
 
 
28
#include <gnome.h>
 
29
#include <gconf/gconf-client.h>
 
30
 
 
31
#include <capplet-util.h>
 
32
#include <activate-settings-daemon.h>
 
33
#include "accessibility-keyboard.h"
 
34
 
 
35
#ifdef HAVE_X11_EXTENSIONS_XKB_H
 
36
#  include <X11/X.h>
 
37
#  include <X11/Xlib.h>
 
38
#  include <X11/XKBlib.h>
 
39
#  include <X11/extensions/XKBstr.h>
 
40
#  include <gdk/gdk.h>
 
41
#  include <gdk/gdkx.h>
 
42
 
 
43
static void
 
44
xkb_enabled (void)
 
45
{
 
46
        gboolean have_xkb = FALSE;
 
47
        int opcode, errorBase, major, minor, xkbEventBase;
 
48
 
 
49
        gdk_error_trap_push ();
 
50
        have_xkb = XkbQueryExtension (GDK_DISPLAY (),
 
51
                                      &opcode, &xkbEventBase, &errorBase, &major, &minor)
 
52
                && XkbUseExtension (GDK_DISPLAY (), &major, &minor);
 
53
        XSync (GDK_DISPLAY (), FALSE);
 
54
        gdk_error_trap_pop ();
 
55
 
 
56
        if (!have_xkb) {
 
57
                GtkWidget *warn = gtk_message_dialog_new (NULL, 0,
 
58
                      GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
 
59
                      _("This system does not seem to have the XKB extension.  The keyboard accessibility features will not operate without it."));
 
60
                gtk_dialog_run (GTK_DIALOG (warn));
 
61
                gtk_widget_destroy (warn);
 
62
        }
 
63
}
 
64
#endif
 
65
 
 
66
static void
 
67
dialog_response (GtkWidget *widget,
 
68
                 gint       response_id,
 
69
                 GConfChangeSet *changeset)
 
70
{
 
71
        switch (response_id) {
 
72
        case GTK_RESPONSE_HELP:
 
73
                capplet_help (GTK_WINDOW (widget),
 
74
                              "user-guide.xml",
 
75
                              "goscustaccess-6");
 
76
                break;
 
77
        case GTK_RESPONSE_DELETE_EVENT:
 
78
        case GTK_RESPONSE_CLOSE:
 
79
                gtk_main_quit ();
 
80
                break;
 
81
        default:
 
82
                /* Import CDE AccessX File */
 
83
                break;
 
84
        }
 
85
}
 
86
 
 
87
int
 
88
main (int argc, char **argv) 
 
89
{
 
90
        GtkWidget *dialog;
 
91
        GConfChangeSet *changeset;
 
92
        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 
93
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
94
        textdomain (GETTEXT_PACKAGE);
 
95
 
 
96
        gnome_program_init ("gnome-accessibility-keyboard-properties", VERSION,
 
97
                            LIBGNOMEUI_MODULE, argc, argv,
 
98
                            GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
 
99
                            NULL);
 
100
        activate_settings_daemon ();
 
101
 
 
102
#ifdef HAVE_X11_EXTENSIONS_XKB_H
 
103
        xkb_enabled ();
 
104
#endif
 
105
 
 
106
        changeset = NULL;
 
107
        dialog = setup_accessX_dialog (changeset);
 
108
        g_signal_connect (G_OBJECT (dialog),
 
109
                "response",
 
110
                G_CALLBACK (dialog_response), changeset);
 
111
        capplet_set_icon (dialog, "gnome-settings-accessibility-keyboard");
 
112
        gtk_widget_show_all (dialog);
 
113
        gtk_main ();
 
114
 
 
115
        return 0;
 
116
}