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 Desktop.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 ACCESSIBLE_TYPE
49 * A pointer to our parent object class
51 static AccessibleClass *parent_class;
54 desktop_init (Desktop *desktop)
56 ACCESSIBLE (desktop)->atko = g_object_new (atk_object_get_type(), NULL);
57 atk_object_set_name (ATK_OBJECT (ACCESSIBLE (desktop)->atko), "main");
61 impl_desktop_get_child_count (PortableServer_Servant servant,
62 CORBA_Environment * ev)
64 Desktop *desktop = DESKTOP (bonobo_object_from_servant (servant));
65 if (desktop->applications)
67 return g_list_length (desktop->applications);
75 static Accessibility_Accessible
76 impl_desktop_get_child_at_index (PortableServer_Servant servant,
77 const CORBA_long index,
78 CORBA_Environment * ev)
80 Desktop *desktop = DESKTOP (bonobo_object_from_servant (servant));
82 if ((desktop->applications) && (index < g_list_length (desktop->applications)))
84 fprintf (stderr, "getting application %ld\n", (long) index);
86 fprintf (stderr, "object address %p\n",
87 g_list_nth_data (desktop->applications, index));
88 retval = CORBA_Object_duplicate (
89 (CORBA_Object) g_list_nth_data (desktop->applications, index), ev);
93 fprintf (stderr, "no %ldth child\n", (long) index);
94 retval = CORBA_OBJECT_NIL;
96 return (Accessibility_Accessible) retval;
100 desktop_class_init (DesktopClass *klass)
102 AccessibleClass * accessible_class = (AccessibleClass *) klass;
103 POA_Accessibility_Accessible__epv *epv = &accessible_class->epv;
105 parent_class = g_type_class_ref (ACCESSIBLE_TYPE);
107 epv->_get_childCount = impl_desktop_get_child_count;
108 epv->getChildAtIndex = impl_desktop_get_child_at_index;
112 desktop_get_type (void)
114 static GType type = 0;
117 static const GTypeInfo tinfo = {
118 sizeof (DesktopClass),
119 (GBaseInitFunc) NULL,
120 (GBaseFinalizeFunc) NULL,
121 (GClassInitFunc) desktop_class_init,
122 (GClassFinalizeFunc) NULL,
123 NULL, /* class data */
126 (GInstanceInitFunc) desktop_init,
127 NULL /* value table */
130 * Here we use bonobo_type_unique instead of
131 * gtk_type_unique, this auto-generates a load of
132 * CORBA structures for us. All derived types must
133 * use bonobo_type_unique.
135 type = bonobo_type_unique (
137 POA_Accessibility_Desktop__init,
139 G_STRUCT_OFFSET (DesktopClass, epv),
151 DESKTOP (g_object_new (desktop_get_type (), NULL));