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 desktop->applications = NULL;
58 atk_object_set_name (ATK_OBJECT (ACCESSIBLE (desktop)->atko), "main");
62 impl_desktop_get_child_count (PortableServer_Servant servant,
63 CORBA_Environment * ev)
65 Desktop *desktop = 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 Desktop *desktop = 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 desktop_class_init (DesktopClass *klass)
103 AccessibleClass * accessible_class = (AccessibleClass *) klass;
104 POA_Accessibility_Accessible__epv *epv = &accessible_class->epv;
106 parent_class = g_type_class_ref (ACCESSIBLE_TYPE);
108 epv->_get_childCount = impl_desktop_get_child_count;
109 epv->getChildAtIndex = impl_desktop_get_child_at_index;
113 desktop_get_type (void)
115 static GType type = 0;
118 static const GTypeInfo tinfo = {
119 sizeof (DesktopClass),
120 (GBaseInitFunc) NULL,
121 (GBaseFinalizeFunc) NULL,
122 (GClassInitFunc) desktop_class_init,
123 (GClassFinalizeFunc) NULL,
124 NULL, /* class data */
127 (GInstanceInitFunc) desktop_init,
128 NULL /* value table */
131 * Here we use bonobo_type_unique instead of
132 * gtk_type_unique, this auto-generates a load of
133 * CORBA structures for us. All derived types must
134 * use bonobo_type_unique.
136 type = bonobo_type_unique (
138 POA_Accessibility_Desktop__init,
140 G_STRUCT_OFFSET (DesktopClass, epv),
152 DESKTOP (g_object_new (desktop_get_type (), NULL));