Added new test that uses the C bindings API (test/simple-at).
[platform/core/uifw/at-spi2-atk.git] / test / simple-at.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 #include <stdlib.h>
24 #include "spi.h"
25
26 void report_focus_event (void *fp);
27
28 void report_button_press (void *fp);
29
30 int
31 main(int argc, char **argv)
32 {
33   int i, j;
34   int n_desktops;
35   int n_apps;
36   Accessible *desktop;
37   Accessible *application;
38   AccessibleEventListener *focus_listener;
39   AccessibleEventListener *button_listener;
40
41   SPI_init();
42
43   focus_listener = CreateEventListener (report_focus_event);
44   button_listener = CreateEventListener (report_button_press);
45
46   RegisterGlobalEventListener (focus_listener, "focus:");
47   RegisterGlobalEventListener (button_listener, "Gtk:GtkWidget:button-press-event");
48
49   n_desktops = GetDesktopCount ();
50
51   for (i=0; i<n_desktops; ++i)
52     {
53       desktop = getDesktop (i);
54       fprintf (stderr, "desktop %d name: %s\n", i, Accessible_getName (desktop));
55       n_apps = Accessible_getChildCount (desktop);
56       for (j=0; j<n_apps; ++j)
57         {
58           application = Accessible_getChildAtIndex (desktop, j);
59           fprintf (stderr, "app %d name: %s\n", j, Accessible_getName (application));
60         }
61     }
62   SPI_event_main(FALSE);
63 }
64
65 void
66 report_focus_event (void *fp)
67 {
68   fprintf (stderr, "focus\n");
69 }
70
71 void
72 report_button_press (void *fp)
73 {
74   fprintf (stderr, "button press\n");
75 }