static void
eti_rows_deleted (ETableModel *model,
                  gint row,
                  gint count,
                  AtkObject *table_item)
{
	gint i,j, n_rows, n_cols, old_nrows;
	ETableItem *item = E_TABLE_ITEM (
		atk_gobject_accessible_get_object (
		ATK_GOBJECT_ACCESSIBLE (table_item)));

	n_rows = atk_table_get_n_rows (ATK_TABLE (table_item));
	n_cols = atk_table_get_n_columns (ATK_TABLE (table_item));

	old_nrows = GET_PRIVATE (table_item)->rows;

	g_return_if_fail (row + count <= old_nrows);
	g_return_if_fail (old_nrows == n_rows + count);
	GET_PRIVATE (table_item)->rows = n_rows;

	g_signal_emit_by_name (
		table_item, "row-deleted", row,
		count, NULL);

	for (i = row; i < (row + count); i++) {
		for (j = 0; j < n_cols; j++) {
			g_signal_emit_by_name (
				table_item,
				"children_changed::remove",
				(((i + 1) * n_cols) + j), NULL, NULL);
		}
	}
	g_signal_emit_by_name (table_item, "visible-data-changed");
	eti_a11y_reset_focus_object ((GalA11yETableItem *) table_item, item, TRUE);
}
/* Static functions */
static gint
eti_get_n_children (AtkObject *accessible)
{
	g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (accessible), 0);
	if (!eti_a11y_get_gobject (accessible))
		return 0;

	return atk_table_get_n_columns (ATK_TABLE (accessible)) *
		(atk_table_get_n_rows (ATK_TABLE (accessible)) + 1);
}
static AtkObject *
eti_ref_child (AtkObject *accessible,
               gint index)
{
	ETableItem *item;
	gint col, row;

	g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (accessible), NULL);
	item = E_TABLE_ITEM (eti_a11y_get_gobject (accessible));
	if (!item)
		return NULL;

	if (index < item->cols) {
		ETableCol *ecol;
		AtkObject *child;

		ecol = e_table_header_get_column (item->header, index);
		child = gal_a11y_e_table_column_header_new (ecol, item, accessible);
		return child;
	}
	index -= item->cols;

	col = index % item->cols;
	row = index / item->cols;

	return eti_ref_at (ATK_TABLE (accessible), row, col);
}
int AccessibilityUIElement::columnCount()
{
    if (!ATK_IS_TABLE(m_element.get()))
        return 0;

    return atk_table_get_n_columns(ATK_TABLE(m_element.get()));
}
Exemple #5
0
int AccessibilityUIElement::rowCount()
{
    if (!m_element || !ATK_IS_TABLE(m_element.get()))
        return 0;

    return atk_table_get_n_rows(ATK_TABLE(m_element.get()));
}
JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRowHeaders()
{
    if (!ATK_IS_TABLE(m_element.get()))
        return JSStringCreateWithCharacters(0, 0);

    Vector<RefPtr<AccessibilityUIElement> > rowHeaders = getRowHeaders(ATK_TABLE(m_element.get()));
    return createStringWithAttributes(rowHeaders);
}
int AccessibilityUIElement::columnCount()
{
    if (!m_element)
        return 0;

    ASSERT(ATK_IS_TABLE(m_element));

    return atk_table_get_n_columns(ATK_TABLE(m_element));
}
PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::cellForColumnAndRow(unsigned col, unsigned row)
{
    if (!ATK_IS_TABLE(m_element.get()))
        return nullptr;

    // Adopt the AtkObject representing the cell because
    // at_table_ref_at() transfers full ownership.
    GRefPtr<AtkObject> foundCell = adoptGRef(atk_table_ref_at(ATK_TABLE(m_element.get()), row, col));
    return foundCell ? AccessibilityUIElement::create(foundCell.get()) : nullptr;
}
Exemple #9
0
AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row)
{
    if (!m_element)
        return 0;

    ASSERT(ATK_IS_TABLE(m_element));

    AtkObject* foundCell = atk_table_ref_at(ATK_TABLE(m_element), row, column);
    return foundCell ? AccessibilityUIElement(foundCell) : 0;
}
static AtkObject*
gucharmap_chartable_accessible_ref_accessible_at_point (AtkComponent *component,
                                              gint x, 
                                              gint y,
                                              AtkCoordType coord_type)
{
  GtkWidget *widget;
  GucharmapChartable *chartable;
  GucharmapChartablePrivate *chartable_priv;
  gint x_pos, y_pos;
  gint row, col;

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
  if (widget == NULL)
    /* State is defunct */
    return NULL;

  chartable = GUCHARMAP_CHARTABLE (widget);
  chartable_priv = chartable->priv;

  atk_component_get_extents (component, &x_pos, &y_pos,
                             NULL, NULL, coord_type);

  /* Find cell at offset x - x_pos, y - y_pos */

  x_pos = x - x_pos;
  y_pos = y - y_pos;

  for (col = 0; col < chartable_priv->cols; col++)
    {
      if (x_pos < _gucharmap_chartable_x_offset (chartable, col))
        {
          col--;
          break;
        }
    }
  if (col == chartable_priv->cols || col < 0)
    return NULL;

  for (row = 0; row < chartable_priv->rows; row++)
    {
      if (y_pos < _gucharmap_chartable_y_offset (chartable, row))
        {
          row--;
          break;
        }
    }
  if (row == chartable_priv->rows || row < 0)
    return NULL;

  row += chartable_priv->page_first_cell / chartable_priv->cols;

  return gucharmap_chartable_accessible_ref_at (ATK_TABLE (component), row, col);
}
AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row)
{
    if (!m_element)
        return 0;

    ASSERT(ATK_IS_TABLE(m_element));

    // Adopt the AtkObject representing the cell because
    // at_table_ref_at() transfers full ownership.
    GRefPtr<AtkObject> foundCell = adoptGRef(atk_table_ref_at(ATK_TABLE(m_element), row, column));
    return foundCell ? AccessibilityUIElement(foundCell.get()) : 0;
}
static AtkObject* /* reference */
find_object (GucharmapChartable   *chartable,
             gunichar  uc,
             AtkObject *obj)
{
  GucharmapChartablePrivate *chartable_priv = chartable->priv;
  gint row, column;

  row = uc / chartable_priv->cols;
  column = _gucharmap_chartable_cell_column (chartable, uc);

  return atk_table_ref_at (ATK_TABLE (obj), row, column);
}
static JSStringRef indexRangeInTable(PlatformUIElement element, bool isRowRange)
{
    GOwnPtr<gchar> rangeString(g_strdup("{0, 0}"));

    if (!element)
        return JSStringCreateWithUTF8CString(rangeString.get());

    ASSERT(ATK_IS_OBJECT(element));

    AtkObject* axTable = atk_object_get_parent(ATK_OBJECT(element));
    if (!axTable || !ATK_IS_TABLE(axTable))
        return JSStringCreateWithUTF8CString(rangeString.get());

    // Look for the cell in the table.
    gint indexInParent = atk_object_get_index_in_parent(ATK_OBJECT(element));
    if (indexInParent == -1)
        return JSStringCreateWithUTF8CString(rangeString.get());

    int row = -1;
    int column = -1;
    row = atk_table_get_row_at_index(ATK_TABLE(axTable), indexInParent);
    column = atk_table_get_column_at_index(ATK_TABLE(axTable), indexInParent);

    // Get the actual values, if row and columns are valid values.
    if (row != -1 && column != -1) {
        int base = 0;
        int length = 0;
        if (isRowRange) {
            base = row;
            length = atk_table_get_row_extent_at(ATK_TABLE(axTable), row, column);
        } else {
            base = column;
            length = atk_table_get_column_extent_at(ATK_TABLE(axTable), row, column);
        }
        rangeString.set(g_strdup_printf("{%d, %d}", base, length));
    }

    return JSStringCreateWithUTF8CString(rangeString.get());
}
static void
eti_rows_inserted (ETableModel *model,
                   gint row,
                   gint count,
                   AtkObject *table_item)
{
	gint n_cols,n_rows,i,j;
	GalA11yETableItem * item_a11y;
	gint old_nrows;

	g_return_if_fail (table_item);
	item_a11y = GAL_A11Y_E_TABLE_ITEM (table_item);

	n_cols = atk_table_get_n_columns (ATK_TABLE (table_item));
	n_rows = atk_table_get_n_rows (ATK_TABLE (table_item));

	old_nrows = GET_PRIVATE (item_a11y)->rows;

	g_return_if_fail (n_cols > 0 && n_rows > 0);
	g_return_if_fail (old_nrows == n_rows - count);

	GET_PRIVATE (table_item)->rows = n_rows;

	g_signal_emit_by_name (
		table_item, "row-inserted", row,
		count, NULL);

	for (i = row; i < (row + count); i++) {
		for (j = 0; j < n_cols; j++) {
			g_signal_emit_by_name (
				table_item,
				"children_changed::add",
				(((i + 1) * n_cols) + j), NULL, NULL);
		}
	}

	g_signal_emit_by_name (table_item, "visible-data-changed");
}
static void
_test_gengrid_object(AtkObject *obj)
{
   int child_count = atk_object_get_n_accessible_children(obj);
   int rows, cols, row_at_index, column_at_index, index_at;
   gboolean success;
   AtkTable *table;
   AtkObject *table_child;
   for (int i = 0; i < child_count; i++)
     {
        AtkObject *child = atk_object_ref_accessible_child(obj, i);
        _print_object_info(child);
        g_object_unref(child);
     }
   g_assert(ATK_IS_TABLE(obj));
   table = ATK_TABLE(obj);
   rows = atk_table_get_n_rows(table);
   g_assert(rows == 3);
   cols = atk_table_get_n_columns(table);
   g_assert(cols == 3);
   row_at_index = atk_table_get_row_at_index(table, 4);
   g_assert(row_at_index == 1);
   column_at_index = atk_table_get_column_at_index(table, 2);
   g_assert(column_at_index == 0);
   index_at = atk_table_get_index_at(table, 2, 2);
   g_assert(index_at == 8);
   table_child = atk_table_ref_at(table, 1, 1);
   g_assert(ATK_IS_OBJECT(table_child));
   _print_object_info(table_child);
   success = atk_table_add_column_selection(table, 1);
   g_assert(success);
   success =  atk_table_is_column_selected(table, 1);
   g_assert(success);
   success = atk_table_remove_column_selection(table, 1);
   g_assert(success);
   success = atk_table_add_row_selection(table, 1);
   g_assert(success);
   success = atk_table_is_row_selected(table, 1);
   g_assert(success);
   success = atk_table_remove_row_selection(table, 0);
   g_assert(success);

}
static void
eti_a11y_reset_focus_object (GalA11yETableItem *a11y,
                             ETableItem *item,
                             gboolean notify)
{
	ESelectionModel * esm;
	gint cursor_row, cursor_col, view_row, view_col;
	AtkObject *cell, *old_cell;

	esm = item->selection;
	g_return_if_fail (esm);

	cursor_row = e_selection_model_cursor_row (esm);
	cursor_col = e_selection_model_cursor_col (esm);

	view_row = model_to_view_row (item, cursor_row);
	view_col = model_to_view_col (item, cursor_col);

	if (view_row == -1)
		view_row = 0;
	if (view_col == -1)
		view_col = 0;

	old_cell = (AtkObject *) g_object_get_data (G_OBJECT (a11y), "gail-focus-object");
	if (old_cell && GAL_A11Y_IS_E_CELL (old_cell))
		gal_a11y_e_cell_remove_state (
			GAL_A11Y_E_CELL (old_cell), ATK_STATE_FOCUSED, FALSE);
	if (old_cell)
		g_object_unref (old_cell);

	cell = eti_ref_at (ATK_TABLE (a11y), view_row, view_col);

	if (cell != NULL) {
		g_object_set_data (G_OBJECT (a11y), "gail-focus-object", cell);
		gal_a11y_e_cell_add_state (
			GAL_A11Y_E_CELL (cell), ATK_STATE_FOCUSED, FALSE);
	} else
		g_object_set_data (G_OBJECT (a11y), "gail-focus-object", NULL);

	if (notify && cell)
		g_signal_emit_by_name (a11y, "active-descendant-changed", cell);
}
static AtkObject *
eti_ref_accessible_at_point (AtkComponent *component,
                             gint x,
                             gint y,
                             AtkCoordType coord_type)
{
	gint row = -1;
	gint col = -1;
	gint x_origin, y_origin;
	ETableItem *item;
	GtkWidget *tableOrTree;

	item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (component)));
	if (!item)
		return NULL;

	atk_component_get_extents (
		component,
		&x_origin,
		&y_origin,
		NULL,
		NULL,
		coord_type);
	x -= x_origin;
	y -= y_origin;

	tableOrTree = gtk_widget_get_parent (GTK_WIDGET (item->parent.canvas));

	if (E_IS_TREE (tableOrTree))
		e_tree_get_cell_at (E_TREE (tableOrTree), x, y, &row, &col);
	else
		e_table_get_cell_at (E_TABLE (tableOrTree), x, y, &row, &col);

	if (row != -1 && col != -1) {
		return eti_ref_at (ATK_TABLE (component), row, col);
	} else {
		return NULL;
	}
}
Exemple #18
0
static void 
_check_object (AtkObject *obj)
{
  AtkRole role;
  static G_CONST_RETURN char *name = NULL;
  static gboolean first_time = TRUE;

  role = atk_object_get_role (obj);
  if (role == ATK_ROLE_PUSH_BUTTON)
  /*
   * Find the specified optionmenu item
   */
    {
      AtkRole valid_roles[NUM_VALID_ROLES];
      AtkObject *atk_option_menu;
      GtkWidget *widget;

      if (name == NULL)
      {
        name = g_getenv ("TEST_ACCESSIBLE_NAME");
        if (name == NULL)
          name = "foo";
      }
      valid_roles[0] = ATK_ROLE_PUSH_BUTTON;
      atk_option_menu = find_object_by_accessible_name_and_role (obj, name,
                               valid_roles, NUM_VALID_ROLES);

      if (atk_option_menu == NULL)
        {
          g_print ("Object not found for %s\n", name);
          return;
        }
      else
        {
          g_print ("Object found for %s\n", name);
        }


      g_assert (GTK_IS_ACCESSIBLE (atk_option_menu));
      widget = GTK_ACCESSIBLE (atk_option_menu)->widget;
      g_assert (GTK_IS_OPTION_MENU (widget));

      if (first_time)
        first_time = FALSE;
      else
        return;

      /*
       * This action opens the GtkOptionMenu whose name is "foo" or whatever
       * was specified in the environment variable TEST_ACCESSIBLE_NAME
       */
      atk_action_do_action (ATK_ACTION (atk_option_menu), 0);
    }
  else if ((role == ATK_ROLE_MENU_ITEM) ||
           (role == ATK_ROLE_CHECK_MENU_ITEM) ||
           (role == ATK_ROLE_RADIO_MENU_ITEM) ||
           (role == ATK_ROLE_TEAR_OFF_MENU_ITEM))
    {
      AtkObject *parent, *child;
      AtkRole parent_role;

      /*
       * If we receive focus while waiting for the menu to be closed
       * we return immediately
       */
      if (doing_action)
        return;

      parent = atk_object_get_parent (obj);
      parent_role = atk_object_get_role (parent);
      g_assert (parent_role == ATK_ROLE_MENU);
    
      child = atk_object_ref_accessible_child (parent, 1);
      doing_action = TRUE;
      gtk_timeout_add (5000, _do_menu_item_action, child);
    }
  else
    {
      G_CONST_RETURN char *accessible_name;

      accessible_name = atk_object_get_name (obj);
      if (accessible_name)
        {
          g_print ("Name: %s\n", accessible_name);
        } 
      else if (GTK_IS_ACCESSIBLE (obj))
        {
          GtkWidget *widget = GTK_ACCESSIBLE (obj)->widget;
          g_print ("Type: %s\n", g_type_name (G_OBJECT_TYPE (widget)));
        } 
      if (role == ATK_ROLE_TABLE)
        {
          gint n_cols, i;

          n_cols = atk_table_get_n_columns (ATK_TABLE (obj));
          g_print ("Number of Columns: %d\n", n_cols);

          for (i  = 0; i < n_cols; i++)
            {
              AtkObject *header;

              header = atk_table_get_column_header (ATK_TABLE (obj), i);
              g_print ("header: %s %s\n", 
                           g_type_name (G_OBJECT_TYPE (header)),
                           atk_object_get_name (header));
            }
        }
    }
}