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.
24 * desktop.c: implements SpiDesktop.idl
28 /* #include <config.h> */
29 #include <libbonobo.h>
34 * This pulls the CORBA definitions for the "Accessibility::Accessible" server
36 #include <libspi/Accessibility.h>
39 * This pulls the definition for the BonoboObject (Gtk Type)
44 * Our parent Gtk object type
46 #define PARENT_TYPE SPI_ACCESSIBLE_TYPE
49 * A pointer to our parent object class
51 static SpiAccessibleClass *parent_class;
54 spi_desktop_init (SpiDesktop *desktop)
56 SPI_ACCESSIBLE (desktop)->atko = g_object_new (atk_object_get_type(), NULL);
57 desktop->applications = NULL;
58 atk_object_set_name (ATK_OBJECT (SPI_ACCESSIBLE (desktop)->atko), "main");
62 impl_desktop_get_child_count (PortableServer_Servant servant,
63 CORBA_Environment * ev)
65 SpiDesktop *desktop = SPI_DESKTOP (bonobo_object_from_servant (servant));
66 if (desktop->applications)
68 return g_list_length (desktop->applications);
76 static Accessibility_Accessible
77 impl_desktop_get_child_at_index (PortableServer_Servant servant,
78 const CORBA_long index,
79 CORBA_Environment * ev)
81 SpiDesktop *desktop = SPI_DESKTOP (bonobo_object_from_servant (servant));
83 if ((desktop->applications) && (index < g_list_length (desktop->applications)))
85 fprintf (stderr, "getting application %ld\n", (long) index);
87 fprintf (stderr, "object address %p\n",
88 g_list_nth_data (desktop->applications, index));
89 retval = CORBA_Object_duplicate (
90 (CORBA_Object) g_list_nth_data (desktop->applications, index), ev);
94 fprintf (stderr, "no %ldth child\n", (long) index);
95 retval = CORBA_OBJECT_NIL;
97 return (Accessibility_Accessible) retval;
101 spi_desktop_class_init (SpiDesktopClass *klass)
103 SpiAccessibleClass * spi_accessible_class = (SpiAccessibleClass *) klass;
104 POA_Accessibility_Accessible__epv *epv = &spi_accessible_class->epv;
106 parent_class = g_type_class_ref (SPI_ACCESSIBLE_TYPE);
108 epv->_get_childCount = impl_desktop_get_child_count;
109 epv->getChildAtIndex = impl_desktop_get_child_at_index;
112 BONOBO_TYPE_FUNC_FULL (SpiDesktop,
113 Accessibility_Desktop,
118 spi_desktop_new (void)
120 SpiDesktop *retval = SPI_DESKTOP (g_object_new (SPI_DESKTOP_TYPE, NULL));