Advertisement
Dhairyashil

At-spi-2.0_demo_example

Feb 23rd, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.32 KB | None | 0 0
  1. #include <atspi/atspi.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. #include <dbus/dbus.h>
  5.  
  6. void cb(const AtspiEvent *event, void *user_data)
  7. {  
  8.     printf("test 1.1 \n"); 
  9.     gint i;
  10.     AtspiAccessible *desktop = NULL;
  11.     AtspiAccessible *app = NULL;
  12.     desktop = atspi_get_desktop (0);
  13.     for (i = 0; i < atspi_accessible_get_child_count (desktop, NULL); i++) {
  14.         app = atspi_accessible_get_child_at_index (desktop, i, NULL);
  15.         g_print ("(Index, application, application_child_count)=(%d,%s,%d)\n",
  16.         i, atspi_accessible_get_name (app, NULL), atspi_accessible_get_child_count (app, NULL));
  17.         g_object_unref (app);
  18.     }
  19. }
  20.  
  21. int main(int argc,char *argv[])
  22. {
  23.     printf("At-spi-Test:  \n");        
  24.  
  25.     int init_error = atspi_init();
  26.     printf("at-spi is initialised-: %d \n",init_error);
  27.  
  28.     AtspiEventListener* listener= atspi_event_listener_new(cb,NULL,NULL);  
  29.     gboolean val = atspi_event_listener_register (listener,"focus:",NULL);
  30.     printf("val--> %d \n",val);
  31.     val = atspi_event_listener_register (listener,"window:",NULL);
  32.     val = atspi_event_listener_register (listener,"window:minimize",NULL);
  33.    
  34.     atspi_event_main ();
  35.     return 0;
  36. }
  37. /*
  38. Compile This code using:
  39.                      gcc -Wall -I/usr/include/at-spi-2.0/ -I/usr/include/glib-2.0/ -I/usr/include/dbus-1.0  $(pkg-config --cflags glib-2.0 gobject-2.0 atspi-2) test.c -latspi
  40.  
  41. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement