static gboolean compare_focus (gpointer data) { AtkObject *atk_focus; AtkObject *gtk_focus; GtkWidget *focus_widget; GList *list, *l; atk_focus = atk_get_focus_object (); focus_widget = NULL; list = gtk_window_list_toplevels (); for (l = list; l; l = l->next) { GtkWindow *w = l->data; if (gtk_window_is_active (w)) { focus_widget = gtk_window_get_focus (w); break; } } g_list_free (list); if (GTK_IS_WIDGET (focus_widget)) gtk_focus = gtk_widget_get_accessible (focus_widget); else gtk_focus = NULL; if (gtk_focus != atk_focus) g_print ("gtk focus: %s != atk focus: %s\n", get_name (gtk_focus), get_name (atk_focus)); return G_SOURCE_CONTINUE; }
static void _test_focus_on_entry(AtkObject *obj) { AtkObject *focused_obj = NULL; gboolean success = FALSE; _printf("Testing focus....\n"); /* changing focus */ g_assert(ATK_IS_COMPONENT(obj)); success = atk_component_grab_focus(ATK_COMPONENT(obj)); g_assert(success); /* now focus should point to our button*/ focused_obj = atk_get_focus_object(); g_assert(focused_obj); g_assert(focused_obj == obj); _printf("DONE. All focus test passed successfully \n"); eail_test_code_called = TRUE; }
/** * Wrapper for atk_get_focus_object(). */ static PyObject* _atkutil_get_focus_object (PyObject *self) { PyAtkObject *atkobj; AtkObject *obj = NULL; debug ("_atkutil_get_focus_object\n"); obj = atk_get_focus_object (); if (obj) { atkobj = g_object_get_data (G_OBJECT (obj), PAPI_PYOBJECT); if (!atkobj) { atkobj = (PyAtkObject *) PyAtkObject_Type.tp_new (&PyAtkObject_Type, NULL, NULL); atkobj->obj = g_object_ref (obj); g_object_set_data (G_OBJECT (obj), PAPI_PYOBJECT, atkobj); } return (PyObject *) atkobj; } Py_RETURN_NONE; }
static VALUE rbatk_get_focus_object(VALUE self) { return GOBJ2RVAL(atk_get_focus_object()); }