|
Packit |
15f964 |
/*
|
|
Packit |
15f964 |
* This program is free software; you can redistribute it and/or modify it
|
|
Packit |
15f964 |
* under the terms of the GNU Lesser General Public License as published by
|
|
Packit |
15f964 |
* the Free Software Foundation.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This program is distributed in the hope that it will be useful, but
|
|
Packit |
15f964 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit |
15f964 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit |
15f964 |
* for more details.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
15f964 |
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Authors:
|
|
Packit |
15f964 |
* Christopher James Lahey <clahey@ximian.com>
|
|
Packit |
15f964 |
* Bolian Yin <bolian.yin@sun.com>
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
*/
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include "evolution-config.h"
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include "gal-a11y-e-table-item.h"
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include <string.h>
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include <atk/atk.h>
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include "e-canvas.h"
|
|
Packit |
15f964 |
#include "e-selection-model.h"
|
|
Packit |
15f964 |
#include "e-table-click-to-add.h"
|
|
Packit |
15f964 |
#include "e-table-subset.h"
|
|
Packit |
15f964 |
#include "e-table.h"
|
|
Packit |
15f964 |
#include "e-tree.h"
|
|
Packit |
15f964 |
#include "gal-a11y-e-cell-registry.h"
|
|
Packit |
15f964 |
#include "gal-a11y-e-cell.h"
|
|
Packit |
15f964 |
#include "gal-a11y-e-table-click-to-add.h"
|
|
Packit |
15f964 |
#include "gal-a11y-e-table-column-header.h"
|
|
Packit |
15f964 |
#include "gal-a11y-e-table-item-factory.h"
|
|
Packit |
15f964 |
#include "gal-a11y-util.h"
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static GObjectClass *parent_class;
|
|
Packit |
15f964 |
static AtkComponentIface *component_parent_iface;
|
|
Packit |
15f964 |
static GType parent_type;
|
|
Packit |
15f964 |
static gint priv_offset;
|
|
Packit |
15f964 |
static GQuark quark_accessible_object = 0;
|
|
Packit |
15f964 |
#define GET_PRIVATE(object) \
|
|
Packit |
15f964 |
((GalA11yETableItemPrivate *) (((gchar *) object) + priv_offset))
|
|
Packit |
15f964 |
#define PARENT_TYPE (parent_type)
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
struct _GalA11yETableItemPrivate {
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
gint cols;
|
|
Packit |
15f964 |
gint rows;
|
|
Packit |
15f964 |
gulong selection_changed_id;
|
|
Packit |
15f964 |
gulong selection_row_changed_id;
|
|
Packit |
15f964 |
gulong cursor_changed_id;
|
|
Packit |
15f964 |
ETableCol ** columns;
|
|
Packit |
15f964 |
ESelectionModel *selection;
|
|
Packit |
15f964 |
AtkStateSet *state_set;
|
|
Packit |
15f964 |
GtkWidget *widget;
|
|
Packit |
788569 |
GHashTable *a11y_column_headers; /* ETableCol * ~> GalA11yETableColumnHeader * */
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean gal_a11y_e_table_item_ref_selection (GalA11yETableItem *a11y,
|
|
Packit |
15f964 |
ESelectionModel *selection);
|
|
Packit |
15f964 |
static gboolean gal_a11y_e_table_item_unref_selection (GalA11yETableItem *a11y);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static AtkObject * eti_ref_at (AtkTable *table, gint row, gint column);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
free_columns (ETableCol **columns)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
gint ii;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (!columns)
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
for (ii = 0; columns[ii]; ii++) {
|
|
Packit |
15f964 |
g_object_unref (columns[ii]);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_free (columns);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
table_item_cell_gone_cb (gpointer user_data,
|
|
Packit |
15f964 |
GObject *gone_cell)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GalA11yETableItem *a11y;
|
|
Packit |
15f964 |
GObject *old_cell;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
a11y = GAL_A11Y_E_TABLE_ITEM (user_data);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
old_cell = g_object_get_data (G_OBJECT (a11y), "gail-focus-object");
|
|
Packit |
15f964 |
if (old_cell == gone_cell)
|
|
Packit |
15f964 |
g_object_set_data (G_OBJECT (a11y), "gail-focus-object", NULL);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
item_finalized (gpointer user_data,
|
|
Packit |
15f964 |
GObject *gone_item)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GalA11yETableItem *a11y;
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv;
|
|
Packit |
15f964 |
GObject *old_cell;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
a11y = GAL_A11Y_E_TABLE_ITEM (user_data);
|
|
Packit |
15f964 |
priv = GET_PRIVATE (a11y);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv->item = NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
old_cell = g_object_get_data (G_OBJECT (a11y), "gail-focus-object");
|
|
Packit |
15f964 |
if (old_cell) {
|
|
Packit |
15f964 |
g_object_weak_unref (G_OBJECT (old_cell), table_item_cell_gone_cb, a11y);
|
|
Packit |
15f964 |
g_object_unref (old_cell);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
g_object_set_data (G_OBJECT (a11y), "gail-focus-object", NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (atk_state_set_add_state (priv->state_set, ATK_STATE_DEFUNCT))
|
|
Packit |
15f964 |
atk_object_notify_state_change (ATK_OBJECT (a11y), ATK_STATE_DEFUNCT, TRUE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->selection)
|
|
Packit |
15f964 |
gal_a11y_e_table_item_unref_selection (a11y);
|
|
Packit |
15f964 |
|
|
Packit |
788569 |
if (priv->columns) {
|
|
Packit |
788569 |
free_columns (priv->columns);
|
|
Packit |
788569 |
priv->columns = NULL;
|
|
Packit |
788569 |
}
|
|
Packit |
788569 |
|
|
Packit |
15f964 |
g_object_unref (a11y);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
gal_a11y_e_table_item_state_change_cb (AtkObject *atkobject,
|
|
Packit |
15f964 |
const gchar *state_name,
|
|
Packit |
15f964 |
gboolean was_set,
|
|
Packit |
15f964 |
gpointer user_data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (atkobject));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (atk_state_type_for_name (state_name) == ATK_STATE_DEFUNCT) {
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv = GET_PRIVATE (atkobject);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (priv != NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (was_set)
|
|
Packit |
15f964 |
atk_state_set_add_state (priv->state_set, ATK_STATE_DEFUNCT);
|
|
Packit |
15f964 |
else
|
|
Packit |
15f964 |
atk_state_set_remove_state (priv->state_set, ATK_STATE_DEFUNCT);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static AtkStateSet *
|
|
Packit |
15f964 |
eti_ref_state_set (AtkObject *accessible)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv = GET_PRIVATE (accessible);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_ref (priv->state_set);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return priv->state_set;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
inline static gint
|
|
Packit |
15f964 |
view_to_model_row (ETableItem *eti,
|
|
Packit |
15f964 |
gint row)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
if (eti->uses_source_model) {
|
|
Packit |
15f964 |
ETableSubset *etss = E_TABLE_SUBSET (eti->table_model);
|
|
Packit |
15f964 |
if (row >= 0 && row < etss->n_map) {
|
|
Packit |
15f964 |
eti->row_guess = row;
|
|
Packit |
15f964 |
return etss->map_table[row];
|
|
Packit |
15f964 |
} else
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
} else
|
|
Packit |
15f964 |
return row;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
inline static gint
|
|
Packit |
15f964 |
view_to_model_col (ETableItem *eti,
|
|
Packit |
15f964 |
gint view_col)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableCol *ecol = e_table_header_get_column (eti->header, view_col);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return (ecol != NULL) ? ecol->spec->model_col : -1;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
inline static gint
|
|
Packit |
15f964 |
model_to_view_row (ETableItem *eti,
|
|
Packit |
15f964 |
gint row)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
gint i;
|
|
Packit |
15f964 |
if (row == -1)
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
if (eti->uses_source_model) {
|
|
Packit |
15f964 |
ETableSubset *etss = E_TABLE_SUBSET (eti->table_model);
|
|
Packit |
15f964 |
if (eti->row_guess >= 0 && eti->row_guess < etss->n_map) {
|
|
Packit |
15f964 |
if (etss->map_table[eti->row_guess] == row) {
|
|
Packit |
15f964 |
return eti->row_guess;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
for (i = 0; i < etss->n_map; i++) {
|
|
Packit |
15f964 |
if (etss->map_table[i] == row)
|
|
Packit |
15f964 |
return i;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
} else
|
|
Packit |
15f964 |
return row;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
inline static gint
|
|
Packit |
15f964 |
model_to_view_col (ETableItem *eti,
|
|
Packit |
15f964 |
gint model_col)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
gint i;
|
|
Packit |
15f964 |
if (model_col == -1)
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
for (i = 0; i < eti->cols; i++) {
|
|
Packit |
15f964 |
ETableCol *ecol = e_table_header_get_column (eti->header, i);
|
|
Packit |
15f964 |
if (ecol->spec->model_col == model_col)
|
|
Packit |
15f964 |
return i;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
inline static GObject *
|
|
Packit |
15f964 |
eti_a11y_get_gobject (AtkObject *accessible)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
return atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_a11y_reset_focus_object (GalA11yETableItem *a11y,
|
|
Packit |
15f964 |
ETableItem *item,
|
|
Packit |
15f964 |
gboolean notify)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ESelectionModel * esm;
|
|
Packit |
15f964 |
gint cursor_row, cursor_col, view_row, view_col;
|
|
Packit |
15f964 |
AtkObject *cell, *old_cell;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
esm = item->selection;
|
|
Packit |
15f964 |
g_return_if_fail (esm);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
cursor_row = e_selection_model_cursor_row (esm);
|
|
Packit |
15f964 |
cursor_col = e_selection_model_cursor_col (esm);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
view_row = model_to_view_row (item, cursor_row);
|
|
Packit |
15f964 |
view_col = model_to_view_col (item, cursor_col);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (view_row == -1)
|
|
Packit |
15f964 |
view_row = 0;
|
|
Packit |
15f964 |
if (view_col == -1)
|
|
Packit |
15f964 |
view_col = 0;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
old_cell = (AtkObject *) g_object_get_data (G_OBJECT (a11y), "gail-focus-object");
|
|
Packit |
15f964 |
if (old_cell && GAL_A11Y_IS_E_CELL (old_cell))
|
|
Packit |
15f964 |
gal_a11y_e_cell_remove_state (
|
|
Packit |
15f964 |
GAL_A11Y_E_CELL (old_cell), ATK_STATE_FOCUSED, FALSE);
|
|
Packit |
15f964 |
if (old_cell) {
|
|
Packit |
15f964 |
g_object_weak_unref (G_OBJECT (old_cell), table_item_cell_gone_cb, a11y);
|
|
Packit |
15f964 |
g_object_unref (old_cell);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
cell = eti_ref_at (ATK_TABLE (a11y), view_row, view_col);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (cell != NULL) {
|
|
Packit |
15f964 |
g_object_set_data (G_OBJECT (a11y), "gail-focus-object", cell);
|
|
Packit |
15f964 |
gal_a11y_e_cell_add_state (
|
|
Packit |
15f964 |
GAL_A11Y_E_CELL (cell), ATK_STATE_FOCUSED, FALSE);
|
|
Packit |
15f964 |
g_object_weak_ref (G_OBJECT (cell), table_item_cell_gone_cb, a11y);
|
|
Packit |
15f964 |
} else
|
|
Packit |
15f964 |
g_object_set_data (G_OBJECT (a11y), "gail-focus-object", NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (notify && cell)
|
|
Packit |
15f964 |
g_signal_emit_by_name (a11y, "active-descendant-changed", cell);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
788569 |
static void eti_column_header_a11y_gone (gpointer user_data, GObject *a11y_col_header);
|
|
Packit |
788569 |
|
|
Packit |
788569 |
static void
|
|
Packit |
788569 |
eti_table_column_gone (gpointer user_data,
|
|
Packit |
788569 |
GObject *col)
|
|
Packit |
788569 |
{
|
|
Packit |
788569 |
GalA11yETableItem *a11y = user_data;
|
|
Packit |
788569 |
GalA11yETableItemPrivate *priv;
|
|
Packit |
788569 |
GalA11yETableColumnHeader *a11y_col_header;
|
|
Packit |
788569 |
|
|
Packit |
788569 |
g_return_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (a11y));
|
|
Packit |
788569 |
|
|
Packit |
788569 |
priv = GET_PRIVATE (a11y);
|
|
Packit |
788569 |
|
|
Packit |
788569 |
a11y_col_header = g_hash_table_lookup (priv->a11y_column_headers, col);
|
|
Packit |
788569 |
g_hash_table_remove (priv->a11y_column_headers, col);
|
|
Packit |
788569 |
|
|
Packit |
788569 |
if (a11y_col_header)
|
|
Packit |
788569 |
g_object_weak_unref (G_OBJECT (a11y_col_header), eti_column_header_a11y_gone, a11y);
|
|
Packit |
788569 |
}
|
|
Packit |
788569 |
|
|
Packit |
788569 |
static void
|
|
Packit |
788569 |
eti_column_header_a11y_gone (gpointer user_data,
|
|
Packit |
788569 |
GObject *a11y_col_header)
|
|
Packit |
788569 |
{
|
|
Packit |
788569 |
GalA11yETableItem *a11y = user_data;
|
|
Packit |
788569 |
GalA11yETableItemPrivate *priv;
|
|
Packit |
788569 |
GHashTableIter iter;
|
|
Packit |
788569 |
gpointer key, value;
|
|
Packit |
788569 |
|
|
Packit |
788569 |
g_return_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (a11y));
|
|
Packit |
788569 |
|
|
Packit |
788569 |
priv = GET_PRIVATE (a11y);
|
|
Packit |
788569 |
|
|
Packit |
788569 |
g_hash_table_iter_init (&iter, priv->a11y_column_headers);
|
|
Packit |
788569 |
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
|
Packit |
788569 |
ETableCol *col = key;
|
|
Packit |
788569 |
GalA11yETableColumnHeader *stored_a11y_col_header = value;
|
|
Packit |
788569 |
|
|
Packit |
788569 |
if (((GObject *) stored_a11y_col_header) == a11y_col_header) {
|
|
Packit |
788569 |
g_object_weak_unref (G_OBJECT (col), eti_table_column_gone, a11y);
|
|
Packit |
788569 |
g_hash_table_remove (priv->a11y_column_headers, col);
|
|
Packit |
788569 |
break;
|
|
Packit |
788569 |
}
|
|
Packit |
788569 |
}
|
|
Packit |
788569 |
}
|
|
Packit |
788569 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_dispose (GObject *object)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GalA11yETableItem *a11y = GAL_A11Y_E_TABLE_ITEM (object);
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv = GET_PRIVATE (a11y);
|
|
Packit |
788569 |
GHashTableIter iter;
|
|
Packit |
788569 |
gpointer key, value;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->columns) {
|
|
Packit |
15f964 |
free_columns (priv->columns);
|
|
Packit |
15f964 |
priv->columns = NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->item) {
|
|
Packit |
15f964 |
g_object_weak_unref (G_OBJECT (priv->item), item_finalized, a11y);
|
|
Packit |
15f964 |
priv->item = NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
788569 |
g_clear_object (&priv->state_set);
|
|
Packit |
788569 |
|
|
Packit |
788569 |
g_hash_table_iter_init (&iter, priv->a11y_column_headers);
|
|
Packit |
788569 |
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
|
Packit |
788569 |
ETableCol *col = key;
|
|
Packit |
788569 |
GalA11yETableColumnHeader *a11y_col_header = value;
|
|
Packit |
788569 |
|
|
Packit |
788569 |
g_object_weak_unref (G_OBJECT (col), eti_table_column_gone, a11y);
|
|
Packit |
788569 |
g_object_weak_unref (G_OBJECT (a11y_col_header), eti_column_header_a11y_gone, a11y);
|
|
Packit |
788569 |
}
|
|
Packit |
788569 |
|
|
Packit |
788569 |
g_hash_table_remove_all (priv->a11y_column_headers);
|
|
Packit |
788569 |
|
|
Packit |
15f964 |
if (parent_class->dispose)
|
|
Packit |
15f964 |
parent_class->dispose (object);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
788569 |
static void
|
|
Packit |
788569 |
eti_finalize (GObject *object)
|
|
Packit |
788569 |
{
|
|
Packit |
788569 |
GalA11yETableItem *a11y = GAL_A11Y_E_TABLE_ITEM (object);
|
|
Packit |
788569 |
GalA11yETableItemPrivate *priv = GET_PRIVATE (a11y);
|
|
Packit |
788569 |
|
|
Packit |
788569 |
g_hash_table_destroy (priv->a11y_column_headers);
|
|
Packit |
788569 |
|
|
Packit |
788569 |
if (parent_class->finalize)
|
|
Packit |
788569 |
parent_class->finalize (object);
|
|
Packit |
788569 |
}
|
|
Packit |
788569 |
|
|
Packit |
15f964 |
/* Static functions */
|
|
Packit |
15f964 |
static gint
|
|
Packit |
15f964 |
eti_get_n_children (AtkObject *accessible)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (accessible), 0);
|
|
Packit |
15f964 |
if (!eti_a11y_get_gobject (accessible))
|
|
Packit |
15f964 |
return 0;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return atk_table_get_n_columns (ATK_TABLE (accessible)) *
|
|
Packit |
15f964 |
(atk_table_get_n_rows (ATK_TABLE (accessible)) + 1);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static AtkObject *
|
|
Packit |
15f964 |
eti_ref_child (AtkObject *accessible,
|
|
Packit |
15f964 |
gint index)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
gint col, row;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (accessible), NULL);
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (accessible));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (index < item->cols) {
|
|
Packit |
788569 |
GalA11yETableItemPrivate *priv = GET_PRIVATE (accessible);
|
|
Packit |
15f964 |
ETableCol *ecol;
|
|
Packit |
15f964 |
AtkObject *child;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
ecol = e_table_header_get_column (item->header, index);
|
|
Packit |
788569 |
child = g_hash_table_lookup (priv->a11y_column_headers, ecol);
|
|
Packit |
788569 |
|
|
Packit |
788569 |
if (!child) {
|
|
Packit |
788569 |
child = gal_a11y_e_table_column_header_new (ecol, item, accessible);
|
|
Packit |
788569 |
if (child) {
|
|
Packit |
788569 |
g_hash_table_insert (priv->a11y_column_headers, ecol, child);
|
|
Packit |
788569 |
|
|
Packit |
788569 |
g_object_weak_ref (G_OBJECT (ecol), eti_table_column_gone, accessible);
|
|
Packit |
788569 |
g_object_weak_ref (G_OBJECT (child), eti_column_header_a11y_gone, accessible);
|
|
Packit |
788569 |
}
|
|
Packit |
788569 |
}
|
|
Packit |
788569 |
|
|
Packit |
788569 |
return child ? g_object_ref (child) : NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
index -= item->cols;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
col = index % item->cols;
|
|
Packit |
15f964 |
row = index / item->cols;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return eti_ref_at (ATK_TABLE (accessible), row, col);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_get_extents (AtkComponent *component,
|
|
Packit |
15f964 |
gint *x,
|
|
Packit |
15f964 |
gint *y,
|
|
Packit |
15f964 |
gint *width,
|
|
Packit |
15f964 |
gint *height,
|
|
Packit |
15f964 |
AtkCoordType coord_type)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
AtkObject *parent;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (component)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
parent = ATK_OBJECT (component)->accessible_parent;
|
|
Packit |
15f964 |
if (parent && ATK_IS_COMPONENT (parent))
|
|
Packit |
15f964 |
atk_component_get_extents (
|
|
Packit |
15f964 |
ATK_COMPONENT (parent),
|
|
Packit |
15f964 |
x, y,
|
|
Packit |
15f964 |
width, height,
|
|
Packit |
15f964 |
coord_type);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (parent && GAL_A11Y_IS_E_TABLE_CLICK_TO_ADD (parent)) {
|
|
Packit |
15f964 |
ETableClickToAdd *etcta = E_TABLE_CLICK_TO_ADD (
|
|
Packit |
15f964 |
atk_gobject_accessible_get_object (
|
|
Packit |
15f964 |
ATK_GOBJECT_ACCESSIBLE (parent)));
|
|
Packit |
15f964 |
if (etcta) {
|
|
Packit |
15f964 |
*width = etcta->width;
|
|
Packit |
15f964 |
*height = etcta->height;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static AtkObject *
|
|
Packit |
15f964 |
eti_ref_accessible_at_point (AtkComponent *component,
|
|
Packit |
15f964 |
gint x,
|
|
Packit |
15f964 |
gint y,
|
|
Packit |
15f964 |
AtkCoordType coord_type)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
gint row = -1;
|
|
Packit |
15f964 |
gint col = -1;
|
|
Packit |
15f964 |
gint x_origin, y_origin;
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
GtkWidget *tableOrTree;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (component)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
atk_component_get_extents (
|
|
Packit |
15f964 |
component,
|
|
Packit |
15f964 |
&x_origin,
|
|
Packit |
15f964 |
&y_origin,
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
coord_type);
|
|
Packit |
15f964 |
x -= x_origin;
|
|
Packit |
15f964 |
y -= y_origin;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
tableOrTree = gtk_widget_get_parent (GTK_WIDGET (item->parent.canvas));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (E_IS_TREE (tableOrTree))
|
|
Packit |
15f964 |
e_tree_get_cell_at (E_TREE (tableOrTree), x, y, &row, &col);
|
|
Packit |
15f964 |
else
|
|
Packit |
15f964 |
e_table_get_cell_at (E_TABLE (tableOrTree), x, y, &row, &col);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (row != -1 && col != -1) {
|
|
Packit |
15f964 |
return eti_ref_at (ATK_TABLE (component), row, col);
|
|
Packit |
15f964 |
} else {
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* atk table */
|
|
Packit |
15f964 |
static AtkObject *
|
|
Packit |
15f964 |
eti_ref_at (AtkTable *table,
|
|
Packit |
15f964 |
gint row,
|
|
Packit |
15f964 |
gint column)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
AtkObject * ret;
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv = GET_PRIVATE (table);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT))
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (column >= 0 &&
|
|
Packit |
15f964 |
column < item->cols &&
|
|
Packit |
15f964 |
row >= 0 &&
|
|
Packit |
15f964 |
row < item->rows &&
|
|
Packit |
15f964 |
item->cell_views_realized) {
|
|
Packit |
15f964 |
ECellView *cell_view = item->cell_views[column];
|
|
Packit |
15f964 |
ETableCol *ecol = e_table_header_get_column (item->header, column);
|
|
Packit |
15f964 |
ret = gal_a11y_e_cell_registry_get_object (
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
item,
|
|
Packit |
15f964 |
cell_view,
|
|
Packit |
15f964 |
ATK_OBJECT (table),
|
|
Packit |
15f964 |
ecol->spec->model_col,
|
|
Packit |
15f964 |
column,
|
|
Packit |
15f964 |
row);
|
|
Packit |
15f964 |
if (ATK_IS_OBJECT (ret)) {
|
|
Packit |
15f964 |
/* if current cell is focused, add FOCUSED state */
|
|
Packit |
15f964 |
if (e_selection_model_cursor_row (item->selection) ==
|
|
Packit |
15f964 |
GAL_A11Y_E_CELL (ret)->row &&
|
|
Packit |
15f964 |
e_selection_model_cursor_col (item->selection) ==
|
|
Packit |
15f964 |
GAL_A11Y_E_CELL (ret)->model_col)
|
|
Packit |
15f964 |
gal_a11y_e_cell_add_state (
|
|
Packit |
15f964 |
GAL_A11Y_E_CELL (ret),
|
|
Packit |
15f964 |
ATK_STATE_FOCUSED, FALSE);
|
|
Packit |
15f964 |
} else
|
|
Packit |
15f964 |
ret = NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return ret;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gint
|
|
Packit |
15f964 |
eti_get_index_at (AtkTable *table,
|
|
Packit |
15f964 |
gint row,
|
|
Packit |
15f964 |
gint column)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return column + (row + 1) * item->cols;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gint
|
|
Packit |
15f964 |
eti_get_column_at_index (AtkTable *table,
|
|
Packit |
15f964 |
gint index)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return index % item->cols;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gint
|
|
Packit |
15f964 |
eti_get_row_at_index (AtkTable *table,
|
|
Packit |
15f964 |
gint index)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return index / item->cols - 1;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gint
|
|
Packit |
15f964 |
eti_get_n_columns (AtkTable *table)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return item->cols;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gint
|
|
Packit |
15f964 |
eti_get_n_rows (AtkTable *table)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return item->rows;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gint
|
|
Packit |
15f964 |
eti_get_column_extent_at (AtkTable *table,
|
|
Packit |
15f964 |
gint row,
|
|
Packit |
15f964 |
gint column)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
gint width;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_table_item_get_cell_geometry (
|
|
Packit |
15f964 |
item,
|
|
Packit |
15f964 |
&row,
|
|
Packit |
15f964 |
&column,
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
&width,
|
|
Packit |
15f964 |
NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return width;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gint
|
|
Packit |
15f964 |
eti_get_row_extent_at (AtkTable *table,
|
|
Packit |
15f964 |
gint row,
|
|
Packit |
15f964 |
gint column)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
gint height;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return -1;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_table_item_get_cell_geometry (
|
|
Packit |
15f964 |
item,
|
|
Packit |
15f964 |
&row,
|
|
Packit |
15f964 |
&column,
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
&height);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return height;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static AtkObject *
|
|
Packit |
15f964 |
eti_get_caption (AtkTable *table)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
/* Unimplemented */
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static const gchar *
|
|
Packit |
15f964 |
eti_get_column_description (AtkTable *table,
|
|
Packit |
15f964 |
gint column)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
ETableCol *ecol;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
ecol = e_table_header_get_column (item->header, column);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return ecol->text;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static AtkObject *
|
|
Packit |
15f964 |
eti_get_column_header (AtkTable *table,
|
|
Packit |
15f964 |
gint column)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
ETableCol *ecol;
|
|
Packit |
15f964 |
AtkObject *atk_obj = NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
ecol = e_table_header_get_column (item->header, column);
|
|
Packit |
15f964 |
if (ecol) {
|
|
Packit |
15f964 |
atk_obj = gal_a11y_e_table_column_header_new (ecol, item, ATK_OBJECT (table));
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return atk_obj;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static const gchar *
|
|
Packit |
15f964 |
eti_get_row_description (AtkTable *table,
|
|
Packit |
15f964 |
gint row)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
/* Unimplemented */
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static AtkObject *
|
|
Packit |
15f964 |
eti_get_row_header (AtkTable *table,
|
|
Packit |
15f964 |
gint row)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
/* Unimplemented */
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static AtkObject *
|
|
Packit |
15f964 |
eti_get_summary (AtkTable *table)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
/* Unimplemented */
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
table_is_row_selected (AtkTable *table,
|
|
Packit |
15f964 |
gint row)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv = GET_PRIVATE (table);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (row < 0)
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT))
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return e_selection_model_is_row_selected (
|
|
Packit |
15f964 |
item->selection, view_to_model_row (item, row));
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
table_is_selected (AtkTable *table,
|
|
Packit |
15f964 |
gint row,
|
|
Packit |
15f964 |
gint column)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
return table_is_row_selected (table, row);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gint
|
|
Packit |
15f964 |
table_get_selected_rows (AtkTable *table,
|
|
Packit |
15f964 |
gint **rows_selected)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
gint n_selected, row, index_selected;
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv = GET_PRIVATE (table);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT))
|
|
Packit |
15f964 |
return 0;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return 0;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
n_selected = e_selection_model_selected_count (item->selection);
|
|
Packit |
15f964 |
if (rows_selected) {
|
|
Packit |
15f964 |
*rows_selected = (gint *) g_malloc (n_selected * sizeof (gint));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
index_selected = 0;
|
|
Packit |
15f964 |
for (row = 0; row < item->rows && index_selected < n_selected; ++row) {
|
|
Packit |
15f964 |
if (atk_table_is_row_selected (table, row)) {
|
|
Packit |
15f964 |
(*rows_selected)[index_selected] = row;
|
|
Packit |
15f964 |
++index_selected;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
return n_selected;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
table_add_row_selection (AtkTable *table,
|
|
Packit |
15f964 |
gint row)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (table_is_row_selected (table, row))
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
e_selection_model_toggle_single_row (
|
|
Packit |
15f964 |
item->selection,
|
|
Packit |
15f964 |
view_to_model_row (item, row));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
table_remove_row_selection (AtkTable *table,
|
|
Packit |
15f964 |
gint row)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv = GET_PRIVATE (table);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT))
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (!atk_table_is_row_selected (table, row))
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_selection_model_toggle_single_row (
|
|
Packit |
15f964 |
item->selection, view_to_model_row (item, row));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_atk_table_iface_init (AtkTableIface *iface)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
iface->ref_at = eti_ref_at;
|
|
Packit |
15f964 |
iface->get_index_at = eti_get_index_at;
|
|
Packit |
15f964 |
iface->get_column_at_index = eti_get_column_at_index;
|
|
Packit |
15f964 |
iface->get_row_at_index = eti_get_row_at_index;
|
|
Packit |
15f964 |
iface->get_n_columns = eti_get_n_columns;
|
|
Packit |
15f964 |
iface->get_n_rows = eti_get_n_rows;
|
|
Packit |
15f964 |
iface->get_column_extent_at = eti_get_column_extent_at;
|
|
Packit |
15f964 |
iface->get_row_extent_at = eti_get_row_extent_at;
|
|
Packit |
15f964 |
iface->get_caption = eti_get_caption;
|
|
Packit |
15f964 |
iface->get_column_description = eti_get_column_description;
|
|
Packit |
15f964 |
iface->get_column_header = eti_get_column_header;
|
|
Packit |
15f964 |
iface->get_row_description = eti_get_row_description;
|
|
Packit |
15f964 |
iface->get_row_header = eti_get_row_header;
|
|
Packit |
15f964 |
iface->get_summary = eti_get_summary;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
iface->is_row_selected = table_is_row_selected;
|
|
Packit |
15f964 |
iface->is_selected = table_is_selected;
|
|
Packit |
15f964 |
iface->get_selected_rows = table_get_selected_rows;
|
|
Packit |
15f964 |
iface->add_row_selection = table_add_row_selection;
|
|
Packit |
15f964 |
iface->remove_row_selection = table_remove_row_selection;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_atk_component_iface_init (AtkComponentIface *iface)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
component_parent_iface = g_type_interface_peek_parent (iface);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
iface->ref_accessible_at_point = eti_ref_accessible_at_point;
|
|
Packit |
15f964 |
iface->get_extents = eti_get_extents;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_rows_inserted (ETableModel *model,
|
|
Packit |
15f964 |
gint row,
|
|
Packit |
15f964 |
gint count,
|
|
Packit |
15f964 |
AtkObject *table_item)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
gint n_cols,n_rows,i,j;
|
|
Packit |
15f964 |
GalA11yETableItem * item_a11y;
|
|
Packit |
15f964 |
gint old_nrows;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (table_item);
|
|
Packit |
15f964 |
item_a11y = GAL_A11Y_E_TABLE_ITEM (table_item);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
n_cols = atk_table_get_n_columns (ATK_TABLE (table_item));
|
|
Packit |
15f964 |
n_rows = atk_table_get_n_rows (ATK_TABLE (table_item));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
old_nrows = GET_PRIVATE (item_a11y)->rows;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (n_cols > 0 && n_rows > 0);
|
|
Packit |
15f964 |
g_return_if_fail (old_nrows == n_rows - count);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GET_PRIVATE (table_item)->rows = n_rows;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_emit_by_name (
|
|
Packit |
15f964 |
table_item, "row-inserted", row,
|
|
Packit |
15f964 |
count, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
for (i = row; i < (row + count); i++) {
|
|
Packit |
15f964 |
for (j = 0; j < n_cols; j++) {
|
|
Packit |
15f964 |
g_signal_emit_by_name (
|
|
Packit |
15f964 |
table_item,
|
|
Packit |
15f964 |
"children_changed::add",
|
|
Packit |
15f964 |
(((i + 1) * n_cols) + j), NULL, NULL);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_emit_by_name (table_item, "visible-data-changed");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_rows_deleted (ETableModel *model,
|
|
Packit |
15f964 |
gint row,
|
|
Packit |
15f964 |
gint count,
|
|
Packit |
15f964 |
AtkObject *table_item)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
gint i,j, n_rows, n_cols, old_nrows;
|
|
Packit |
15f964 |
ETableItem *item = E_TABLE_ITEM (
|
|
Packit |
15f964 |
atk_gobject_accessible_get_object (
|
|
Packit |
15f964 |
ATK_GOBJECT_ACCESSIBLE (table_item)));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
n_rows = atk_table_get_n_rows (ATK_TABLE (table_item));
|
|
Packit |
15f964 |
n_cols = atk_table_get_n_columns (ATK_TABLE (table_item));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
old_nrows = GET_PRIVATE (table_item)->rows;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (row + count <= old_nrows);
|
|
Packit |
15f964 |
g_return_if_fail (old_nrows == n_rows + count);
|
|
Packit |
15f964 |
GET_PRIVATE (table_item)->rows = n_rows;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_emit_by_name (
|
|
Packit |
15f964 |
table_item, "row-deleted", row,
|
|
Packit |
15f964 |
count, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
for (i = row; i < (row + count); i++) {
|
|
Packit |
15f964 |
for (j = 0; j < n_cols; j++) {
|
|
Packit |
15f964 |
g_signal_emit_by_name (
|
|
Packit |
15f964 |
table_item,
|
|
Packit |
15f964 |
"children_changed::remove",
|
|
Packit |
15f964 |
(((i + 1) * n_cols) + j), NULL, NULL);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
g_signal_emit_by_name (table_item, "visible-data-changed");
|
|
Packit |
15f964 |
eti_a11y_reset_focus_object ((GalA11yETableItem *) table_item, item, TRUE);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_model_changed (ETableModel *model,
|
|
Packit |
15f964 |
AtkObject *table_item)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv;
|
|
Packit |
15f964 |
gint row_count;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (table_item));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv = GET_PRIVATE (table_item);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
row_count = e_table_model_row_count (model);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->rows != row_count) {
|
|
Packit |
15f964 |
priv->rows = row_count;
|
|
Packit |
15f964 |
g_signal_emit_by_name (table_item, "visible-data-changed");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_tree_model_node_changed_cb (ETreeModel *model,
|
|
Packit |
15f964 |
ETreePath node,
|
|
Packit |
15f964 |
ETableItem *eti)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
AtkObject *atk_obj;
|
|
Packit |
15f964 |
GalA11yETableItem *a11y;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_TABLE_ITEM (eti));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
atk_obj = atk_gobject_accessible_for_object (G_OBJECT (eti));
|
|
Packit |
15f964 |
a11y = GAL_A11Y_E_TABLE_ITEM (atk_obj);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* we can't figure out which rows are changed, so just send out a signal ... */
|
|
Packit |
15f964 |
if (GET_PRIVATE (a11y)->rows > 0)
|
|
Packit |
15f964 |
g_signal_emit_by_name (a11y, "visible-data-changed");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
enum {
|
|
Packit |
15f964 |
ETI_HEADER_UNCHANGED = 0,
|
|
Packit |
15f964 |
ETI_HEADER_REORDERED,
|
|
Packit |
15f964 |
ETI_HEADER_NEW_ADDED,
|
|
Packit |
15f964 |
ETI_HEADER_REMOVED
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/*
|
|
Packit |
15f964 |
* 1. Check what actually happened: column reorder, remove or add
|
|
Packit |
15f964 |
* 2. Update cache
|
|
Packit |
15f964 |
* 3. Emit signals
|
|
Packit |
15f964 |
*/
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_header_structure_changed (ETableHeader *eth,
|
|
Packit |
15f964 |
AtkObject *a11y)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
gboolean reorder_found = FALSE, added_found = FALSE, removed_found = FALSE;
|
|
Packit |
15f964 |
GalA11yETableItem * a11y_item;
|
|
Packit |
15f964 |
ETableCol ** cols, **prev_cols;
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv;
|
|
Packit |
15f964 |
gint *state = NULL, *prev_state = NULL, *reorder = NULL;
|
|
Packit |
15f964 |
gint i,j,n_rows,n_cols, prev_n_cols;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
a11y_item = GAL_A11Y_E_TABLE_ITEM (a11y);
|
|
Packit |
15f964 |
priv = GET_PRIVATE (a11y_item);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Assume rows do not changed. */
|
|
Packit |
15f964 |
n_rows = priv->rows;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
prev_n_cols = priv->cols;
|
|
Packit |
15f964 |
prev_cols = priv->columns;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
cols = e_table_header_get_columns (eth);
|
|
Packit |
15f964 |
n_cols = eth->col_count;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (cols && prev_cols && n_cols > 0);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Init to ETI_HEADER_UNCHANGED. */
|
|
Packit |
15f964 |
state = g_malloc0 (sizeof (gint) * (MAX (prev_n_cols, n_cols) + 1));
|
|
Packit |
15f964 |
prev_state = g_malloc0 (sizeof (gint) * (MAX (prev_n_cols, n_cols) + 1));
|
|
Packit |
15f964 |
reorder = g_malloc0 (sizeof (gint) * (MAX (prev_n_cols, n_cols) + 1));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Compare with previously saved column headers. */
|
|
Packit |
15f964 |
for (i = 0; i < n_cols && cols[i]; i++) {
|
|
Packit |
15f964 |
for (j = 0; j < prev_n_cols && prev_cols[j]; j++) {
|
|
Packit |
15f964 |
if (prev_cols[j] == cols[i] && i != j) {
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
reorder_found = TRUE;
|
|
Packit |
15f964 |
state[i] = ETI_HEADER_REORDERED;
|
|
Packit |
15f964 |
reorder[i] = j;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
break;
|
|
Packit |
15f964 |
} else if (prev_cols[j] == cols[i]) {
|
|
Packit |
15f964 |
/* OK, this column is not changed. */
|
|
Packit |
15f964 |
break;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* cols[i] is new added column. */
|
|
Packit |
15f964 |
if (j == prev_n_cols) {
|
|
Packit |
15f964 |
added_found = TRUE;
|
|
Packit |
15f964 |
state[i] = ETI_HEADER_NEW_ADDED;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Now try to find if there are removed columns. */
|
|
Packit |
15f964 |
for (i = 0; i < prev_n_cols && prev_cols[i]; i++) {
|
|
Packit |
15f964 |
for (j = 0; j < n_cols && cols[j]; j++)
|
|
Packit |
15f964 |
if (prev_cols[j] == cols[i])
|
|
Packit |
15f964 |
break;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Removed columns found. */
|
|
Packit |
15f964 |
if (j == n_cols) {
|
|
Packit |
15f964 |
removed_found = TRUE;
|
|
Packit |
15f964 |
prev_state[j] = ETI_HEADER_REMOVED;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* If nothing interesting just return. */
|
|
Packit |
15f964 |
if (!reorder_found && !added_found && !removed_found) {
|
|
Packit |
15f964 |
g_free (state);
|
|
Packit |
15f964 |
g_free (reorder);
|
|
Packit |
15f964 |
g_free (prev_state);
|
|
Packit |
788569 |
free_columns (cols);
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Emit signals */
|
|
Packit |
15f964 |
if (reorder_found)
|
|
Packit |
15f964 |
g_signal_emit_by_name (a11y_item, "column_reordered");
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (removed_found) {
|
|
Packit |
15f964 |
for (i = 0; i < prev_n_cols; i++) {
|
|
Packit |
15f964 |
if (prev_state[i] == ETI_HEADER_REMOVED) {
|
|
Packit |
15f964 |
g_signal_emit_by_name (
|
|
Packit |
15f964 |
a11y_item, "column-deleted", i, 1);
|
|
Packit |
15f964 |
for (j = 0; j < n_rows; j++)
|
|
Packit |
15f964 |
g_signal_emit_by_name (
|
|
Packit |
15f964 |
a11y_item,
|
|
Packit |
15f964 |
"children_changed::remove",
|
|
Packit |
15f964 |
((j + 1) * prev_n_cols + i),
|
|
Packit |
15f964 |
NULL, NULL);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (added_found) {
|
|
Packit |
15f964 |
for (i = 0; i < n_cols; i++) {
|
|
Packit |
15f964 |
if (state[i] == ETI_HEADER_NEW_ADDED) {
|
|
Packit |
15f964 |
g_signal_emit_by_name (
|
|
Packit |
15f964 |
a11y_item, "column-inserted", i, 1);
|
|
Packit |
15f964 |
for (j = 0; j < n_rows; j++)
|
|
Packit |
15f964 |
g_signal_emit_by_name (
|
|
Packit |
15f964 |
a11y_item,
|
|
Packit |
15f964 |
"children_changed::add",
|
|
Packit |
15f964 |
((j + 1) * n_cols + i),
|
|
Packit |
15f964 |
NULL, NULL);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv->cols = n_cols;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_free (state);
|
|
Packit |
15f964 |
g_free (reorder);
|
|
Packit |
15f964 |
g_free (prev_state);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
free_columns (priv->columns);
|
|
Packit |
15f964 |
priv->columns = cols;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_real_initialize (AtkObject *obj,
|
|
Packit |
15f964 |
gpointer data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem * eti;
|
|
Packit |
15f964 |
ETableModel * model;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
|
|
Packit |
15f964 |
eti = E_TABLE_ITEM (data);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
model = eti->table_model;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_connect_object (
|
|
Packit |
15f964 |
model, "model-rows-inserted",
|
|
Packit |
15f964 |
G_CALLBACK (eti_rows_inserted), obj, 0);
|
|
Packit |
15f964 |
g_signal_connect_object (
|
|
Packit |
15f964 |
model, "model-rows-deleted",
|
|
Packit |
15f964 |
G_CALLBACK (eti_rows_deleted), obj, 0);
|
|
Packit |
15f964 |
g_signal_connect_object (
|
|
Packit |
15f964 |
model, "model-changed",
|
|
Packit |
15f964 |
G_CALLBACK (eti_model_changed), obj, 0);
|
|
Packit |
15f964 |
g_signal_connect_object (
|
|
Packit |
15f964 |
eti->header, "structure_change",
|
|
Packit |
15f964 |
G_CALLBACK (eti_header_structure_changed), obj, 0);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_class_init (GalA11yETableItemClass *class)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (class);
|
|
Packit |
15f964 |
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
quark_accessible_object =
|
|
Packit |
15f964 |
g_quark_from_static_string ("gtk-accessible-object");
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
parent_class = g_type_class_ref (PARENT_TYPE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
object_class->dispose = eti_dispose;
|
|
Packit |
788569 |
object_class->finalize = eti_finalize;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
atk_object_class->get_n_children = eti_get_n_children;
|
|
Packit |
15f964 |
atk_object_class->ref_child = eti_ref_child;
|
|
Packit |
15f964 |
atk_object_class->initialize = eti_real_initialize;
|
|
Packit |
15f964 |
atk_object_class->ref_state_set = eti_ref_state_set;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_init (GalA11yETableItem *a11y)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv = GET_PRIVATE (a11y);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv->selection_changed_id = 0;
|
|
Packit |
15f964 |
priv->selection_row_changed_id = 0;
|
|
Packit |
15f964 |
priv->cursor_changed_id = 0;
|
|
Packit |
15f964 |
priv->selection = NULL;
|
|
Packit |
788569 |
priv->a11y_column_headers = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* atk selection */
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void atk_selection_interface_init (AtkSelectionIface *iface);
|
|
Packit |
15f964 |
static gboolean selection_add_selection (AtkSelection *selection,
|
|
Packit |
15f964 |
gint i);
|
|
Packit |
15f964 |
static gboolean selection_clear_selection (AtkSelection *selection);
|
|
Packit |
15f964 |
static AtkObject *
|
|
Packit |
15f964 |
selection_ref_selection (AtkSelection *selection,
|
|
Packit |
15f964 |
gint i);
|
|
Packit |
15f964 |
static gint selection_get_selection_count (AtkSelection *selection);
|
|
Packit |
15f964 |
static gboolean selection_is_child_selected (AtkSelection *selection,
|
|
Packit |
15f964 |
gint i);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* callbacks */
|
|
Packit |
15f964 |
static void eti_a11y_selection_model_removed_cb (ETableItem *eti,
|
|
Packit |
15f964 |
ESelectionModel *selection,
|
|
Packit |
15f964 |
gpointer data);
|
|
Packit |
15f964 |
static void eti_a11y_selection_model_added_cb (ETableItem *eti,
|
|
Packit |
15f964 |
ESelectionModel *selection,
|
|
Packit |
15f964 |
gpointer data);
|
|
Packit |
15f964 |
static void eti_a11y_selection_changed_cb (ESelectionModel *selection,
|
|
Packit |
15f964 |
GalA11yETableItem *a11y);
|
|
Packit |
15f964 |
static void eti_a11y_selection_row_changed_cb (ESelectionModel *selection,
|
|
Packit |
15f964 |
gint row,
|
|
Packit |
15f964 |
GalA11yETableItem *a11y);
|
|
Packit |
15f964 |
static void eti_a11y_cursor_changed_cb (ESelectionModel *selection,
|
|
Packit |
15f964 |
gint row, gint col,
|
|
Packit |
15f964 |
GalA11yETableItem *a11y);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* gal_a11y_e_table_item_get_type:
|
|
Packit |
15f964 |
* @void:
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Registers the &GalA11yETableItem class if necessary, and returns the type ID
|
|
Packit |
15f964 |
* associated to it.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Return value: The type ID of the &GalA11yETableItem class.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
GType
|
|
Packit |
15f964 |
gal_a11y_e_table_item_get_type (void)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
static GType type = 0;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (!type) {
|
|
Packit |
15f964 |
AtkObjectFactory *factory;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GTypeInfo info = {
|
|
Packit |
15f964 |
sizeof (GalA11yETableItemClass),
|
|
Packit |
15f964 |
(GBaseInitFunc) NULL,
|
|
Packit |
15f964 |
(GBaseFinalizeFunc) NULL,
|
|
Packit |
15f964 |
(GClassInitFunc) eti_class_init,
|
|
Packit |
15f964 |
(GClassFinalizeFunc) NULL,
|
|
Packit |
15f964 |
NULL, /* class_data */
|
|
Packit |
15f964 |
sizeof (GalA11yETableItem),
|
|
Packit |
15f964 |
0,
|
|
Packit |
15f964 |
(GInstanceInitFunc) eti_init,
|
|
Packit |
15f964 |
NULL /* value_table_item */
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static const GInterfaceInfo atk_component_info = {
|
|
Packit |
15f964 |
(GInterfaceInitFunc) eti_atk_component_iface_init,
|
|
Packit |
15f964 |
(GInterfaceFinalizeFunc) NULL,
|
|
Packit |
15f964 |
NULL
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
static const GInterfaceInfo atk_table_info = {
|
|
Packit |
15f964 |
(GInterfaceInitFunc) eti_atk_table_iface_init,
|
|
Packit |
15f964 |
(GInterfaceFinalizeFunc) NULL,
|
|
Packit |
15f964 |
NULL
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static const GInterfaceInfo atk_selection_info = {
|
|
Packit |
15f964 |
(GInterfaceInitFunc) atk_selection_interface_init,
|
|
Packit |
15f964 |
(GInterfaceFinalizeFunc) NULL,
|
|
Packit |
15f964 |
NULL
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
factory = atk_registry_get_factory (
|
|
Packit |
15f964 |
atk_get_default_registry (), GNOME_TYPE_CANVAS_ITEM);
|
|
Packit |
15f964 |
parent_type = atk_object_factory_get_accessible_type (factory);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
type = gal_a11y_type_register_static_with_private (
|
|
Packit |
15f964 |
PARENT_TYPE, "GalA11yETableItem", &info, 0,
|
|
Packit |
15f964 |
sizeof (GalA11yETableItemPrivate), &priv_offset);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_type_add_interface_static (type, ATK_TYPE_COMPONENT, &atk_component_info);
|
|
Packit |
15f964 |
g_type_add_interface_static (type, ATK_TYPE_TABLE, &atk_table_info);
|
|
Packit |
15f964 |
g_type_add_interface_static (type, ATK_TYPE_SELECTION, &atk_selection_info);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return type;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
AtkObject *
|
|
Packit |
15f964 |
gal_a11y_e_table_item_new (ETableItem *item)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GalA11yETableItem *a11y;
|
|
Packit |
15f964 |
AtkObject *accessible;
|
|
Packit |
15f964 |
ESelectionModel * esm;
|
|
Packit |
15f964 |
AtkObject *parent;
|
|
Packit |
15f964 |
const gchar *name;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (item && item->cols >= 0, NULL);
|
|
Packit |
15f964 |
a11y = g_object_new (gal_a11y_e_table_item_get_type (), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
atk_object_initialize (ATK_OBJECT (a11y), item);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GET_PRIVATE (a11y)->state_set = atk_state_set_new ();
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
atk_state_set_add_state (GET_PRIVATE (a11y)->state_set, ATK_STATE_MANAGES_DESCENDANTS);
|
|
Packit |
15f964 |
atk_state_set_add_state (GET_PRIVATE (a11y)->state_set, ATK_STATE_ENABLED);
|
|
Packit |
15f964 |
atk_state_set_add_state (GET_PRIVATE (a11y)->state_set, ATK_STATE_SENSITIVE);
|
|
Packit |
15f964 |
atk_state_set_add_state (GET_PRIVATE (a11y)->state_set, ATK_STATE_SHOWING);
|
|
Packit |
15f964 |
atk_state_set_add_state (GET_PRIVATE (a11y)->state_set, ATK_STATE_VISIBLE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_connect (a11y, "state-change", G_CALLBACK (gal_a11y_e_table_item_state_change_cb), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
accessible = ATK_OBJECT (a11y);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Initialize cell data. */
|
|
Packit |
15f964 |
GET_PRIVATE (a11y)->cols = item->cols;
|
|
Packit |
15f964 |
GET_PRIVATE (a11y)->rows = item->rows >= 0 ? item->rows : 0;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GET_PRIVATE (a11y)->columns = e_table_header_get_columns (item->header);
|
|
Packit |
788569 |
if (GET_PRIVATE (a11y)->columns == NULL) {
|
|
Packit |
788569 |
g_clear_object (&a11y);
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
788569 |
}
|
|
Packit |
788569 |
|
|
Packit |
788569 |
GET_PRIVATE (a11y)->item = item;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_connect (
|
|
Packit |
15f964 |
item, "selection_model_removed",
|
|
Packit |
15f964 |
G_CALLBACK (eti_a11y_selection_model_removed_cb), NULL);
|
|
Packit |
15f964 |
g_signal_connect (
|
|
Packit |
15f964 |
item, "selection_model_added",
|
|
Packit |
15f964 |
G_CALLBACK (eti_a11y_selection_model_added_cb), NULL);
|
|
Packit |
15f964 |
if (item->selection)
|
|
Packit |
15f964 |
gal_a11y_e_table_item_ref_selection (
|
|
Packit |
15f964 |
a11y,
|
|
Packit |
15f964 |
item->selection);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* find the TableItem's parent: table or tree */
|
|
Packit |
15f964 |
GET_PRIVATE (a11y)->widget = gtk_widget_get_parent (
|
|
Packit |
15f964 |
GTK_WIDGET (item->parent.canvas));
|
|
Packit |
15f964 |
parent = gtk_widget_get_accessible (GET_PRIVATE (a11y)->widget);
|
|
Packit |
15f964 |
name = atk_object_get_name (parent);
|
|
Packit |
15f964 |
if (name)
|
|
Packit |
15f964 |
atk_object_set_name (accessible, name);
|
|
Packit |
15f964 |
atk_object_set_parent (accessible, parent);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (E_IS_TREE (GET_PRIVATE (a11y)->widget)) {
|
|
Packit |
15f964 |
ETreeModel *model;
|
|
Packit |
15f964 |
model = e_tree_get_model (E_TREE (GET_PRIVATE (a11y)->widget));
|
|
Packit |
15f964 |
g_signal_connect (
|
|
Packit |
15f964 |
model, "node_changed",
|
|
Packit |
15f964 |
G_CALLBACK (eti_tree_model_node_changed_cb), item);
|
|
Packit |
15f964 |
accessible->role = ATK_ROLE_TREE_TABLE;
|
|
Packit |
15f964 |
} else if (E_IS_TABLE (GET_PRIVATE (a11y)->widget)) {
|
|
Packit |
15f964 |
accessible->role = ATK_ROLE_TABLE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_weak_ref (G_OBJECT (item), item_finalized, g_object_ref (a11y));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
esm = item->selection;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (esm != NULL) {
|
|
Packit |
15f964 |
eti_a11y_reset_focus_object (a11y, item, FALSE);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return ATK_OBJECT (a11y);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
gal_a11y_e_table_item_ref_selection (GalA11yETableItem *a11y,
|
|
Packit |
15f964 |
ESelectionModel *selection)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (a11y && selection, FALSE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv = GET_PRIVATE (a11y);
|
|
Packit |
15f964 |
priv->selection_changed_id = g_signal_connect (
|
|
Packit |
15f964 |
selection, "selection-changed",
|
|
Packit |
15f964 |
G_CALLBACK (eti_a11y_selection_changed_cb), a11y);
|
|
Packit |
15f964 |
priv->selection_row_changed_id = g_signal_connect (
|
|
Packit |
15f964 |
selection, "selection-row-changed",
|
|
Packit |
15f964 |
G_CALLBACK (eti_a11y_selection_row_changed_cb), a11y);
|
|
Packit |
15f964 |
priv->cursor_changed_id = g_signal_connect (
|
|
Packit |
15f964 |
selection, "cursor-changed",
|
|
Packit |
15f964 |
G_CALLBACK (eti_a11y_cursor_changed_cb), a11y);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv->selection = selection;
|
|
Packit |
15f964 |
g_object_ref (selection);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
gal_a11y_e_table_item_unref_selection (GalA11yETableItem *a11y)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (a11y, FALSE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv = GET_PRIVATE (a11y);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (priv->selection_changed_id != 0, FALSE);
|
|
Packit |
15f964 |
g_return_val_if_fail (priv->selection_row_changed_id != 0, FALSE);
|
|
Packit |
15f964 |
g_return_val_if_fail (priv->cursor_changed_id != 0, FALSE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_handler_disconnect (
|
|
Packit |
15f964 |
priv->selection,
|
|
Packit |
15f964 |
priv->selection_changed_id);
|
|
Packit |
15f964 |
g_signal_handler_disconnect (
|
|
Packit |
15f964 |
priv->selection,
|
|
Packit |
15f964 |
priv->selection_row_changed_id);
|
|
Packit |
15f964 |
g_signal_handler_disconnect (
|
|
Packit |
15f964 |
priv->selection,
|
|
Packit |
15f964 |
priv->cursor_changed_id);
|
|
Packit |
15f964 |
priv->cursor_changed_id = 0;
|
|
Packit |
15f964 |
priv->selection_row_changed_id = 0;
|
|
Packit |
15f964 |
priv->selection_changed_id = 0;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_unref (priv->selection);
|
|
Packit |
15f964 |
priv->selection = NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* callbacks */
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_a11y_selection_model_removed_cb (ETableItem *eti,
|
|
Packit |
15f964 |
ESelectionModel *selection,
|
|
Packit |
15f964 |
gpointer data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
AtkObject *atk_obj;
|
|
Packit |
15f964 |
GalA11yETableItem *a11y;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_TABLE_ITEM (eti));
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SELECTION_MODEL (selection));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
atk_obj = atk_gobject_accessible_for_object (G_OBJECT (eti));
|
|
Packit |
15f964 |
a11y = GAL_A11Y_E_TABLE_ITEM (atk_obj);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (selection == GET_PRIVATE (a11y)->selection)
|
|
Packit |
15f964 |
gal_a11y_e_table_item_unref_selection (a11y);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_a11y_selection_model_added_cb (ETableItem *eti,
|
|
Packit |
15f964 |
ESelectionModel *selection,
|
|
Packit |
15f964 |
gpointer data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
AtkObject *atk_obj;
|
|
Packit |
15f964 |
GalA11yETableItem *a11y;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_TABLE_ITEM (eti));
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SELECTION_MODEL (selection));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
atk_obj = atk_gobject_accessible_for_object (G_OBJECT (eti));
|
|
Packit |
15f964 |
a11y = GAL_A11Y_E_TABLE_ITEM (atk_obj);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (GET_PRIVATE (a11y)->selection)
|
|
Packit |
15f964 |
gal_a11y_e_table_item_unref_selection (a11y);
|
|
Packit |
15f964 |
gal_a11y_e_table_item_ref_selection (a11y, selection);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_a11y_selection_changed_cb (ESelectionModel *selection,
|
|
Packit |
15f964 |
GalA11yETableItem *a11y)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv = GET_PRIVATE (a11y);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT))
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (a11y));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_emit_by_name (a11y, "selection_changed");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_a11y_selection_row_changed_cb (ESelectionModel *selection,
|
|
Packit |
15f964 |
gint row,
|
|
Packit |
15f964 |
GalA11yETableItem *a11y)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
eti_a11y_selection_changed_cb (selection, a11y);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
eti_a11y_cursor_changed_cb (ESelectionModel *selection,
|
|
Packit |
15f964 |
gint row,
|
|
Packit |
15f964 |
gint col,
|
|
Packit |
15f964 |
GalA11yETableItem *a11y)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
GalA11yETableItemPrivate *priv = GET_PRIVATE (a11y);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (a11y));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT))
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (a11y)));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (item);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (row == -1 && col == -1)
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
eti_a11y_reset_focus_object (a11y, item, TRUE);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* atk selection */
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void atk_selection_interface_init (AtkSelectionIface *iface)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (iface != NULL);
|
|
Packit |
15f964 |
iface->add_selection = selection_add_selection;
|
|
Packit |
15f964 |
iface->clear_selection = selection_clear_selection;
|
|
Packit |
15f964 |
iface->ref_selection = selection_ref_selection;
|
|
Packit |
15f964 |
iface->get_selection_count = selection_get_selection_count;
|
|
Packit |
15f964 |
iface->is_child_selected = selection_is_child_selected;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
selection_add_selection (AtkSelection *selection,
|
|
Packit |
15f964 |
gint index)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
AtkTable *table;
|
|
Packit |
15f964 |
gint row, col, cursor_row, cursor_col, model_row, model_col;
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (selection)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
table = ATK_TABLE (selection);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
row = atk_table_get_row_at_index (table, index);
|
|
Packit |
15f964 |
col = atk_table_get_column_at_index (table, index);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
model_row = view_to_model_row (item, row);
|
|
Packit |
15f964 |
model_col = view_to_model_col (item, col);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
cursor_row = e_selection_model_cursor_row (item->selection);
|
|
Packit |
15f964 |
cursor_col = e_selection_model_cursor_col (item->selection);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* check whether is selected already */
|
|
Packit |
15f964 |
if (model_row == cursor_row && model_col == cursor_col)
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (model_row != cursor_row) {
|
|
Packit |
15f964 |
/* we need to make the item get focus */
|
|
Packit |
15f964 |
e_canvas_item_grab_focus (GNOME_CANVAS_ITEM (item), TRUE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* FIXME, currently we only support single row selection */
|
|
Packit |
15f964 |
atk_selection_clear_selection (selection);
|
|
Packit |
15f964 |
atk_table_add_row_selection (table, row);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_selection_model_change_cursor (
|
|
Packit |
15f964 |
item->selection,
|
|
Packit |
15f964 |
model_row,
|
|
Packit |
15f964 |
model_col);
|
|
Packit |
15f964 |
e_selection_model_cursor_changed (
|
|
Packit |
15f964 |
item->selection,
|
|
Packit |
15f964 |
model_row,
|
|
Packit |
15f964 |
model_col);
|
|
Packit |
15f964 |
e_selection_model_cursor_activated (
|
|
Packit |
15f964 |
item->selection,
|
|
Packit |
15f964 |
model_row,
|
|
Packit |
15f964 |
model_col);
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
selection_clear_selection (AtkSelection *selection)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
ETableItem *item;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (selection)));
|
|
Packit |
15f964 |
if (!item)
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_selection_model_clear (item->selection);
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static AtkObject *
|
|
Packit |
15f964 |
selection_ref_selection (AtkSelection *selection,
|
|
Packit |
15f964 |
gint index)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
AtkTable *table;
|
|
Packit |
15f964 |
gint row, col;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
table = ATK_TABLE (selection);
|
|
Packit |
15f964 |
row = atk_table_get_row_at_index (table, index);
|
|
Packit |
15f964 |
col = atk_table_get_column_at_index (table, index);
|
|
Packit |
15f964 |
if (!atk_table_is_row_selected (table, row))
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return eti_ref_at (table, row, col);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gint
|
|
Packit |
15f964 |
selection_get_selection_count (AtkSelection *selection)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
AtkTable *table;
|
|
Packit |
15f964 |
gint n_selected;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
table = ATK_TABLE (selection);
|
|
Packit |
15f964 |
n_selected = atk_table_get_selected_rows (table, NULL);
|
|
Packit |
15f964 |
if (n_selected > 0)
|
|
Packit |
15f964 |
n_selected *= atk_table_get_n_columns (table);
|
|
Packit |
15f964 |
return n_selected;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
selection_is_child_selected (AtkSelection *selection,
|
|
Packit |
15f964 |
gint i)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
gint row;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
row = atk_table_get_row_at_index (ATK_TABLE (selection), i);
|
|
Packit |
15f964 |
return atk_table_is_row_selected (ATK_TABLE (selection), row);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
gal_a11y_e_table_item_init (void)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
if (atk_get_root ())
|
|
Packit |
15f964 |
atk_registry_set_factory_type (
|
|
Packit |
15f964 |
atk_get_default_registry (),
|
|
Packit |
15f964 |
E_TYPE_TABLE_ITEM,
|
|
Packit |
15f964 |
gal_a11y_e_table_item_factory_get_type ());
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|