2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
26 #include <libbonobo.h>
27 #include "../cspi-lowlevel.h"
30 cspi_dup_ref (CORBA_Object object)
32 return bonobo_object_dup_ref (object, cspi_ev ());
36 cspi_release_unref (CORBA_Object object)
38 bonobo_object_release_unref (object, NULL);
42 cspi_check_ev (const char *error_string)
44 CORBA_Environment *ev = cspi_peek_ev ();
46 if (ev->_major != CORBA_NO_EXCEPTION)
50 err = bonobo_exception_get_text (ev);
52 if (!cspi_exception_throw (ev, (char *) error_string)) {
53 fprintf (stderr, "Warning: AT-SPI error: %s: %s\n",
59 CORBA_exception_free (ev);
70 cspi_exception_get_text (void)
74 txt = bonobo_exception_get_text (cspi_ev ());
82 * Returns a 'canonicalized' value for DISPLAY,
83 * with the screen number stripped off if present.
86 cspi_display_name (void)
88 static const char *canonical_display_name = NULL;
89 if (!canonical_display_name)
91 const gchar *display_env = g_getenv ("AT_SPI_DISPLAY");
94 display_env = g_getenv ("DISPLAY");
95 if (!display_env || !display_env[0])
96 canonical_display_name = ":0";
99 gchar *display_p, *screen_p;
100 canonical_display_name = g_strdup (display_env);
101 display_p = strrchr (canonical_display_name, ':');
102 screen_p = strrchr (canonical_display_name, '.');
103 if (screen_p && display_p && (screen_p > display_p))
111 canonical_display_name = display_env;
114 return canonical_display_name;
121 CORBA_Object registry;
122 CORBA_Environment ev;
124 if (!bonobo_init (0, NULL))
126 g_error ("Could not initialize Bonobo");
129 obj_id = "OAFIID:Accessibility_Registry:1.0";
131 CORBA_exception_init (&ev);
133 bonobo_activation_set_activation_env_value ("AT_SPI_DISPLAY",
134 cspi_display_name ());
136 registry = bonobo_activation_activate_from_id (
137 obj_id, 0, NULL, &ev);
139 if (ev._major != CORBA_NO_EXCEPTION)
141 g_error ("AT-SPI error: during registry activation: %s\n",
142 bonobo_exception_get_text (&ev));
145 if (registry == CORBA_OBJECT_NIL)
147 g_warning ("Could not locate registry");
156 cspi_ping (CORBA_Object object)
158 return bonobo_unknown_ping (object, NULL);
168 cspi_main_quit (void)