rendered paste bodystatic PyObject *wait_till_gui_not_exist (PyObject *self, PyObject *args)
{
int time_wait = 30; // Max wait for 30 seconds
char *window;
char *env_sleep = NULL;
time_t start, cur;
Accessible *accessible = NULL;
if (!PyArg_ParseTuple (args, "s", &window))
return PyErr_Format (ldtp_error, "%s %s %d", "Argument missing / invalid", __FILE__, __LINE__);
/*
Copied from LTFX source code
*/
start = cur = time (NULL);
if ((env_sleep = getenv ("GUI_TIMEOUT")) != NULL)
{
time_wait = atoi (env_sleep);
if (time_wait == 0)
time_wait = 30;
}
accessible = get_gui_handle (appmap, window, window);
while ((difftime (cur, start) < time_wait) && (accessible != NULL))
{
nSleep (0, 15000);
cur = time (NULL);
if (accessible)
{
Accessible_unref (accessible);
accessible = NULL;
}
accessible = get_gui_handle (appmap, window, window);
}
if (accessible == NULL)
return Py_BuildValue ("i", 1);
else
{
Accessible_unref (accessible);
return Py_BuildValue ("i", 0);
}
}