1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30
#include <glib/gi18n.h>
33
#include <gconf/gconf-client.h>
35
#include "gdm-common.h"
37
#include "gdm-settings-client.h"
38
#include "gdm-settings-keys.h"
40
#include "gdm-chooser-host.h"
41
#include "gdm-host-chooser-dialog.h"
43
#define ACCESSIBILITY_KEY "/desktop/gnome/interface/accessibility"
45
static Atom AT_SPI_IOR;
49
assistive_registry_launch (void)
57
command = AT_SPI_REGISTRYD_DIR "/at-spi-registryd";
61
res = g_shell_parse_argv (command, NULL, &argv, &error);
63
g_warning ("Unable to parse command: %s", error->message);
68
res = g_spawn_async (NULL,
72
| G_SPAWN_STDOUT_TO_DEV_NULL
73
| G_SPAWN_STDERR_TO_DEV_NULL,
81
g_warning ("Unable to run command %s: %s", command, error->message);
85
if (kill (pid, 0) < 0) {
86
g_warning ("at-spi-registryd not running");
93
static GdkFilterReturn
94
filter_watch (GdkXEvent *xevent,
98
XEvent *xev = (XEvent *)xevent;
100
if (xev->xany.type == PropertyNotify
101
&& xev->xproperty.atom == AT_SPI_IOR) {
104
return GDK_FILTER_REMOVE;
107
return GDK_FILTER_CONTINUE;
111
filter_timeout (gpointer data)
113
g_warning ("The accessibility registry was not found.");
121
assistive_registry_start (void)
126
root = gdk_get_default_root_window ();
129
AT_SPI_IOR = XInternAtom (GDK_DISPLAY (), "AT_SPI_IOR", False);
132
gdk_window_set_events (root, GDK_PROPERTY_CHANGE_MASK);
134
if ( ! assistive_registry_launch ()) {
135
g_warning ("The accessibility registry could not be started.");
139
gdk_window_add_filter (root, filter_watch, NULL);
140
tid = g_timeout_add_seconds (5, filter_timeout, NULL);
144
gdk_window_remove_filter (root, filter_watch, NULL);
145
g_source_remove (tid);
149
at_set_gtk_modules (void)
151
GSList *modules_list;
156
gboolean found_atk_bridge;
162
found_atk_bridge = FALSE;
164
if ((old = g_getenv ("GTK_MODULES")) != NULL) {
165
modules = g_strsplit (old, ":", -1);
166
for (n = 0; modules[n]; n++) {
167
if (!strcmp (modules[n], "gail")) {
169
} else if (!strcmp (modules[n], "atk-bridge")) {
170
found_atk_bridge = TRUE;
173
modules_list = g_slist_prepend (modules_list, modules[n]);
180
modules_list = g_slist_prepend (modules_list, "gail");
184
if (!found_atk_bridge) {
185
modules_list = g_slist_prepend (modules_list, "atk-bridge");
189
modules = g_new (char *, n + 1);
191
for (l = modules_list; l; l = l->next) {
192
modules[n--] = g_strdup (l->data);
195
g_setenv ("GTK_MODULES", g_strjoinv (":", modules), TRUE);
196
g_strfreev (modules);
197
g_slist_free (modules_list);
203
const char *env_a_t_support;
204
gboolean a_t_support;
205
GConfClient *gconf_client;
207
gconf_client = gconf_client_get_default ();
209
env_a_t_support = g_getenv ("GNOME_ACCESSIBILITY");
210
if (env_a_t_support) {
211
a_t_support = atoi (env_a_t_support);
213
a_t_support = gconf_client_get_bool (gconf_client, ACCESSIBILITY_KEY, NULL);
217
assistive_registry_start ();
218
at_set_gtk_modules ();
221
g_object_unref (gconf_client);
225
main (int argc, char *argv[])
229
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
230
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
231
textdomain (GETTEXT_PACKAGE);
233
setlocale (LC_ALL, "");
235
gdm_set_fatal_warnings_if_unstable ();
240
gdm_log_set_debug (TRUE);
242
g_debug ("Chooser for display %s xauthority:%s",
243
g_getenv ("DISPLAY"),
244
g_getenv ("XAUTHORITY"));
246
gdk_init (&argc, &argv);
250
gtk_init (&argc, &argv);
252
chooser = gdm_host_chooser_dialog_new (GDM_CHOOSER_HOST_KIND_MASK_ALL);
253
gtk_widget_set_size_request (chooser, 480, 600);
255
if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_OK) {
256
GdmChooserHost *host;
258
host = gdm_host_chooser_dialog_get_host (GDM_HOST_CHOOSER_DIALOG (chooser));
261
/* FIXME: handle different host types here? */
264
gdm_address_get_hostname (gdm_chooser_host_get_address (host), &hostname);
265
/* FIXME: fall back to numerical address? */
266
if (hostname != NULL) {
267
g_print ("hostname: %s\n", hostname);
273
gtk_widget_destroy (chooser);