2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* desktop.c: implements SpiDesktop.idl */
27 #include <libbonobo.h>
28 #include <libspi/desktop.h>
30 /* Our parent Gtk object type */
31 #define PARENT_TYPE SPI_ACCESSIBLE_TYPE
33 /* A pointer to our parent object class */
34 static SpiAccessibleClass *parent_class;
37 spi_desktop_init (SpiDesktop *desktop)
39 SPI_ACCESSIBLE (desktop)->atko = g_object_new (ATK_TYPE_OBJECT, NULL);
40 desktop->applications = NULL;
41 atk_object_set_name (ATK_OBJECT (SPI_ACCESSIBLE (desktop)->atko), "main");
45 impl_desktop_get_child_count (PortableServer_Servant servant,
46 CORBA_Environment * ev)
48 SpiDesktop *desktop = SPI_DESKTOP (bonobo_object_from_servant (servant));
49 if (desktop->applications)
51 return g_list_length (desktop->applications);
59 static Accessibility_Accessible
60 impl_desktop_get_child_at_index (PortableServer_Servant servant,
61 const CORBA_long index,
62 CORBA_Environment * ev)
64 SpiDesktop *desktop = SPI_DESKTOP (bonobo_object_from_servant (servant));
66 if ((desktop->applications) && (index < g_list_length (desktop->applications)))
68 fprintf (stderr, "getting application %ld\n", (long) index);
70 fprintf (stderr, "object address %p\n",
71 g_list_nth_data (desktop->applications, index));
72 retval = CORBA_Object_duplicate (
73 (CORBA_Object) g_list_nth_data (desktop->applications, index), ev);
77 fprintf (stderr, "no %ldth child\n", (long) index);
78 retval = CORBA_OBJECT_NIL;
80 return (Accessibility_Accessible) retval;
84 spi_desktop_class_init (SpiDesktopClass *klass)
86 SpiAccessibleClass * spi_accessible_class = (SpiAccessibleClass *) klass;
87 POA_Accessibility_Accessible__epv *epv = &spi_accessible_class->epv;
89 parent_class = g_type_class_ref (SPI_ACCESSIBLE_TYPE);
91 epv->_get_childCount = impl_desktop_get_child_count;
92 epv->getChildAtIndex = impl_desktop_get_child_at_index;
95 BONOBO_TYPE_FUNC_FULL (SpiDesktop,
96 Accessibility_Desktop,
101 spi_desktop_new (void)
103 SpiDesktop *retval = g_object_new (SPI_DESKTOP_TYPE, NULL);