static gchar* get_label (AtspiAccessible *accessible) { GArray *relations; AtspiRelation *relation; gint i; gchar *result = ""; relations = atspi_accessible_get_relation_set (accessible, NULL); if (relations == NULL) { return ""; } for (i = 0; i < relations->len; i++) { relation = g_array_index (relations, AtspiRelation*, i); if (atspi_relation_get_relation_type (relation) == ATSPI_RELATION_LABELLED_BY) { result = atspi_accessible_get_name (atspi_relation_get_target (relation, 0), NULL); } } if (relations != NULL) g_array_free (relations, TRUE); return result; }
int main(int argc, gchar **argv) { gint i; AtspiAccessible *desktop = NULL; AtspiAccessible *app = NULL; gchar *app_name = NULL; gboolean found = FALSE; app_name = parse_args (&argc, &argv); if (!app_name) { g_print ("ERROR: We only dump the content of a specific app, specify the name\n"); return 0; } atspi_init (); desktop = atspi_get_desktop (0); for (i = 0; i < atspi_accessible_get_child_count (desktop, NULL); i++) { app = atspi_accessible_get_child_at_index (desktop, i, NULL); if (!g_strcmp0 (atspi_accessible_get_name (app, NULL), app_name)) { found = TRUE; dump_node_content (app, " "); } g_object_unref (app); } if (!found) { g_print ("ERROR: Application \"%s\" not found\n", app_name); return 0; } return 1; }
static void on_event (const AtspiEvent *event, void *data) { AtspiAccessible *application = NULL; gchar *app_name = NULL; if (event->source == NULL) return; /* We only care about focus/selection gain */ if (!event->detail1) return; application = atspi_accessible_get_application (event->source, NULL); if (application == NULL) return; app_name = atspi_accessible_get_name (application, NULL); if ((filter_name != NULL) && (g_strcmp0 (app_name, filter_name) != 0)) goto clean; print_info (event->source, app_name); clean: g_free (app_name); }
AtspiAccessible * get_root_obj (const char *file_name) { int i; AtspiAccessible *obj = NULL; run_app (file_name); /* sleep is needed to wait for fored test application*/ sleep (1); obj = atspi_get_desktop (0); gint child_count = atspi_accessible_get_child_count (obj, NULL); if (child_count < 1) { g_test_message ("Fail, test application not found\n"); g_test_fail (); kill (child_pid, SIGTERM); return NULL; } for (i=0; i<child_count; i++) { AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,i, NULL); if (!strcmp (atspi_accessible_get_name (child, NULL), "root_object")) return child; } g_test_message ("test object not found\n"); g_test_fail (); kill (child_pid, SIGTERM); return NULL; }
static void checkAtspiAccessible(AtspiAccessible* accessible, const char* targetName, AtspiRole targetRole) { g_assert(ATSPI_IS_ACCESSIBLE(accessible)); GOwnPtr<char> name(atspi_accessible_get_name(accessible, 0)); g_assert_cmpstr(targetName, ==, name.get()); g_assert_cmpint(targetRole, ==, atspi_accessible_get_role(accessible, 0)); }
static gchar* print_info (AtspiAccessible *accessible) { gchar *name = "NULL"; gchar *role_name = "NULL"; if (accessible != NULL) { name = atspi_accessible_get_name (accessible, NULL); if ((name == NULL) || (g_strcmp0 (name, "") == 0)) name = get_label (accessible); role_name = atspi_accessible_get_role_name (accessible, NULL); } return g_strdup_printf ("(%s, %s)", name, role_name); }
static GRefPtr<AtspiAccessible> findTestServerApplication() { // Only one desktop is supported by ATSPI at the moment. GRefPtr<AtspiAccessible> desktop = adoptGRef(atspi_get_desktop(0)); // Look for the server application in the list of apps. GRefPtr<AtspiAccessible> current; int childCount = atspi_accessible_get_child_count(desktop.get(), 0); for (int i = 0; i < childCount; i++) { current = adoptGRef(atspi_accessible_get_child_at_index(desktop.get(), i, 0)); if (!g_strcmp0(atspi_accessible_get_name(current.get(), 0), kTestServerAppName)) return current; } return 0; }
static void print_info (AtspiAccessible *accessible, gchar *app_name) { gchar *name = "NULL"; gchar *role_name = "NULL"; gchar *state_set = NULL; if (accessible != NULL) { name = atspi_accessible_get_name (accessible, NULL); if ((name == NULL) || (g_strcmp0 (name, "") == 0)) name = get_label (accessible); role_name = atspi_accessible_get_role_name (accessible, NULL); } state_set = get_state_set (accessible); g_print ("(%s, %s, %s, %s)\n", app_name, name, role_name, state_set); g_free (state_set); }
void basic (AtspiAccessible *obj) { gchar *str; gint count; gint i; AtspiAccessible *accessible; GError *error = NULL; str = atspi_accessible_get_name (obj, &error); if (str) g_free (str); accessible = atspi_accessible_get_parent (obj, NULL); if (accessible) g_object_unref (accessible); count = atspi_accessible_get_child_count (obj, &error); for (i = 0; i < count; i++) { accessible = atspi_accessible_get_child_at_index (obj, i, &error); if (accessible) g_object_unref (accessible); } }