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 spi_desktop_finalize (GObject *object)
47 (G_OBJECT_CLASS (parent_class))->finalize (object);
51 impl_desktop_get_child_count (PortableServer_Servant servant,
52 CORBA_Environment * ev)
54 SpiDesktop *desktop = SPI_DESKTOP (bonobo_object_from_servant (servant));
55 if (desktop->applications)
57 return g_list_length (desktop->applications);
65 static Accessibility_Accessible
66 impl_desktop_get_child_at_index (PortableServer_Servant servant,
67 const CORBA_long index,
68 CORBA_Environment * ev)
70 SpiDesktop *desktop = SPI_DESKTOP (bonobo_object_from_servant (servant));
72 if ((desktop->applications) && (index < g_list_length (desktop->applications)))
74 fprintf (stderr, "getting application %ld\n", (long) index);
76 fprintf (stderr, "object address %p\n",
77 g_list_nth_data (desktop->applications, index));
78 retval = bonobo_object_dup_ref (
79 (CORBA_Object) g_list_nth_data (desktop->applications, index), ev);
83 fprintf (stderr, "no %ldth child\n", (long) index);
84 retval = CORBA_OBJECT_NIL;
86 return (Accessibility_Accessible) retval;
90 spi_desktop_class_init (SpiDesktopClass *klass)
92 GObjectClass * object_class = (GObjectClass *) klass;
93 SpiAccessibleClass * spi_accessible_class = (SpiAccessibleClass *) klass;
94 POA_Accessibility_Accessible__epv *epv = &spi_accessible_class->epv;
96 object_class->finalize = spi_desktop_finalize;
98 parent_class = g_type_class_ref (SPI_ACCESSIBLE_TYPE);
100 epv->_get_childCount = impl_desktop_get_child_count;
101 epv->getChildAtIndex = impl_desktop_get_child_at_index;
104 BONOBO_TYPE_FUNC_FULL (SpiDesktop,
105 Accessibility_Desktop,
110 spi_desktop_new (void)
112 SpiDesktop *retval = g_object_new (SPI_DESKTOP_TYPE, NULL);