static gboolean control_spi_listener_process_event (gpointer data) { AccessibleEvent *event; ControlSpiListener *listener = CONTROL_SPI_LISTENER (data); while (g_queue_is_empty(listener->event_queue) == FALSE) { event = (AccessibleEvent *)g_queue_pop_head(listener->event_queue); if (strcmp (event->type, "window:activate") == 0) { if (listener->root) Accessible_unref (listener->root); Accessible_ref (event->source); listener->root = event->source; } AccessibleEvent_unref (event); } control_spi_listener_free_actions_list (listener); control_spi_listener_build_actions_list (listener, listener->root, 0); control_spi_listener_dump_actions_list (listener); g_signal_emit (listener, control_spi_listener_signals[SIGNAL_CHANGED], 0, NULL); listener->idle_id = 0; return FALSE; }
static void restartTerm(Accessible *newTerm, AccessibleText *newTextTerm) { char *c,*d; const char *e; long i,len; char *text; if (curFocus) finiTerm(); Accessible_ref(curFocus = newTerm); curTerm = newTextTerm; logMessage(LOG_DEBUG,"new term %p",curTerm); text = AccessibleText_getText(curTerm,0,LONG_MAX); curNumRows = 0; if (curRows) { for (i=0;i<curNumRows;i++) free(curRows[i]); free(curRows); } free(curRowLengths); c = text; while (*c) { curNumRows++; if (!(c = strchr(c,'\n'))) break; c++; } logMessage(LOG_DEBUG,"%ld rows",curNumRows); curRows = malloc(curNumRows * sizeof(*curRows)); curRowLengths = malloc(curNumRows * sizeof(*curRowLengths)); i = 0; curNumCols = 0; for (c = text; *c; c = d+1) { d = strchr(c,'\n'); if (d) *d = 0; e = c; curRowLengths[i] = (len = my_mbsrtowcs(NULL,&e,0,NULL)) + (d != NULL); if (len > curNumCols) curNumCols = len; else if (len < 0) { if (len==-2) logMessage(LOG_ERR,"unterminated sequence %s",c); else if (len==-1) logSystemError("mbrlen"); curRowLengths[i] = (len = -1) + (d != NULL); } curRows[i] = malloc((len + (d!=NULL)) * sizeof(*curRows[i])); e = c; my_mbsrtowcs(curRows[i],&e,len,NULL); if (d) curRows[i][len]='\n'; else break; i++; } logMessage(LOG_DEBUG,"%ld cols",curNumCols); SPI_freeString(text); caretPosition(AccessibleText_getCaretOffset(curTerm)); }
static void control_spi_listener_build_actions_list (ControlSpiListener *listener, Accessible *parent, int depth) { Accessible* child; AccessibleRole role; int i, child_count; if (depth > SEARCH_DEPTH) return; child_count = Accessible_getChildCount (parent); child_count = MIN (child_count, SEARCH_BREADTH); for (i = 0; i < child_count; ++i) { char *name; char *normalized_name; child = Accessible_getChildAtIndex (parent, i); if (child == parent) continue; name = Accessible_getName (child); #if DEBUG { gchar *role_name; role_name = Accessible_getRoleName (child); g_message ("Looking at %s %s", role_name, name); } #endif if (name) { normalized_name = control_spi_listener_normalize (name); if (normalized_name && strlen(normalized_name) > 0 && is_actionable (child)) { AccessibleItem *item; item = g_new0(AccessibleItem, 1); Accessible_ref (child); item->accessible = child; item->name = g_strdup (normalized_name); listener->actions = g_slist_append (listener->actions, item); } SPI_freeString (name); g_free (normalized_name); } if (is_worth_searching (child)) control_spi_listener_build_actions_list (listener, child, depth+1); Accessible_unref (child); } }
static void log_accessible (EventLog *log, Accessible *accessible) { GtkTextTag *tag; GtkTextIter iter; char *text, *name, *descr, *short_descr; char *role_name, *ifaces; if (!accessible) { log_message (log, "<Null>"); return; } tag = gtk_text_buffer_create_tag (log->log_text, NULL, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); Accessible_ref (accessible); g_object_set_data_full (G_OBJECT (tag), "accessible", accessible, (GDestroyNotify) Accessible_unref ); ifaces = accessible_get_iface_string (accessible); role_name = Accessible_getRoleName (accessible); name = Accessible_getName (accessible); descr = Accessible_getDescription (accessible); short_descr = ellipsize (descr); /* FIXME: nice mangled printout of supported interfaces ? */ text = g_strdup_printf ("%s:%s:%s:%s", ifaces, role_name ? role_name : "--", name ? name : "--", short_descr ? short_descr : "--"); gtk_text_buffer_get_end_iter (log->log_text, &iter); gtk_text_buffer_insert_with_tags (log->log_text, &iter, text, -1, tag, NULL); g_free (text); g_free (short_descr); SPI_freeString (descr); SPI_freeString (name); SPI_freeString (role_name); g_free (ifaces); log_track_end (log); }
static void cspi_event (CSpiEventListener *listener, AccessibleEvent *event) { GList *l; CSpiEventListener *clistener = (CSpiEventListener *) listener; InternalEvent *ievent; AccessibleEvent *aevent; ievent = g_new0(InternalEvent, 1); ievent->event.type = g_strdup (event->type); ievent->event.source = event->source; ievent->event.detail1 = event->detail1; ievent->event.detail2 = event->detail2; ievent->event.v_type = event->v_type; if (event->v_type == EVENT_DATA_STRING) { ievent->event.v.text = g_strdup (event->v.text); } else memcpy (&ievent->event.v, &event->v, sizeof(event->v)); ievent->id = _e_id++; ievent->magic = SPI_INTERNAL_EVENT_MAGIC; ievent->ref_count = 0; aevent = (AccessibleEvent *)ievent; Accessible_ref (aevent->source); AccessibleEvent_ref (aevent); /* FIXME: re-enterancy hazard on this list */ for (l = clistener->callbacks; l; l = l->next) { EventHandler *eh = l->data; /* cast hides our private stuff from client handlers */ eh->cb.event (aevent, eh->user_data); } AccessibleEvent_unref (aevent); }
void windows_ref ( SQByteArray * _pointer ) { Accessible * accessibleObject = windows_to_accessible(_pointer); Accessible_ref ( accessibleObject ); }