All pastes #26831 Raw Edit

Something

public text v1 · immutable
#26831 ·published 2005-10-27 16:44 UTC
rendered paste body
#include <Python.h>

#include <glib.h>
#include <glib/gprintf.h>
#include <cspi/spi.h>

static GThread *ldtp_thread = NULL;
static AccessibleEventListener *window_listener = NULL;

static PyObject *ldtp_main (PyObject *self, PyObject *args)
{
  g_print ("Inside ldtp main\n");
  return Py_BuildValue ("");
}

static PyMethodDef ldtp_methods[] = {
  {"ldtpmain",(PyCFunction) ldtp_main, METH_VARARGS,
   "Main Function"},
  {NULL, NULL, 0, NULL}           /* sentinel */
};

void ldtp_exit (void)
{
  SPI_exit ();
  putenv ("AT_BRIDGE_SHUTDOWN=1");
}

void report_window_event (const AccessibleEvent *event, void *user_data)
{
  if (event)
    {
      AccessibleEvent_ref (event);
      g_print ("%d\n", Accessible_getRole (event->source));
      AccessibleEvent_unref (event);
    }
}

gpointer ldtp_thread_func (gpointer data)
{
  SPI_event_main ();
  return NULL;
}

PyMODINIT_FUNC initldtp (void)
{
  int init_error;

  PyEval_InitThreads();

  Py_AtExit (ldtp_exit);

  init_error = SPI_init ();
  if (init_error)
    {
      g_warning ("Error: SPI Init\n");
      return;
    }
  Py_InitModule ("ldtp", ldtp_methods);
  
  /*
   * Register event listener for windows
   */
  window_listener = SPI_createAccessibleEventListener (NULL, NULL);
  /*
   * Listen for new popup dialogs
   */
  if (window_listener)
    SPI_registerGlobalEventListener (window_listener,
				     "window:activate");
  AccessibleEventListener_addCallback (window_listener, report_window_event, NULL);

  ldtp_thread = g_thread_create (ldtp_thread_func, NULL, TRUE, NULL);

  return;
}