diff options
Diffstat (limited to 'a11y')
-rw-r--r-- | a11y/e-table/gal-a11y-e-cell-tree.c | 154 | ||||
-rw-r--r-- | a11y/e-table/gal-a11y-e-cell-tree.h | 48 | ||||
-rw-r--r-- | a11y/e-table/gal-a11y-e-cell.c | 50 | ||||
-rw-r--r-- | a11y/e-table/gal-a11y-e-cell.h | 8 |
4 files changed, 260 insertions, 0 deletions
diff --git a/a11y/e-table/gal-a11y-e-cell-tree.c b/a11y/e-table/gal-a11y-e-cell-tree.c new file mode 100644 index 0000000000..3f7071d72b --- /dev/null +++ b/a11y/e-table/gal-a11y-e-cell-tree.c @@ -0,0 +1,154 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: + * Tim Wo <tim.wo@sun.com>, Sun Microsystem Inc. 2003. + * + * Copyright (C) 2002 Ximian, Inc. + */ + +#include <config.h> +#include <atk/atkaction.h> +#include "gal-a11y-e-cell-tree.h" +#include "gal-a11y-util.h" +#include "gal/e-table/e-cell-tree.h" +#include "gal/e-table/e-table.h" +#include "gal/e-table/e-tree-table-adapter.h" + +#define CS_CLASS(a11y) (G_TYPE_INSTANCE_GET_CLASS ((a11y), C_TYPE_STREAM, GalA11yECellTreeClass)) +static AtkObjectClass *a11y_parent_class; +#define A11Y_PARENT_TYPE (gal_a11y_e_cell_get_type ()) + +static void +ectr_do_action_expand (AtkAction *action) +{ + GalA11yECell *a11y; + ETableModel *table_model; + ETreePath node; + ETreeModel *tree_model; + ETreeTableAdapter *tree_table_adapter; + + a11y = GAL_A11Y_E_CELL (action); + table_model = a11y->item->table_model; + node = e_table_model_value_at (table_model, -1, a11y->row); + tree_model = e_table_model_value_at (table_model, -2, a11y->row); + tree_table_adapter = e_table_model_value_at (table_model, -3, a11y->row); + + if (e_tree_model_node_is_expandable (tree_model, node)) { + e_tree_table_adapter_node_set_expanded (tree_table_adapter, + node, + TRUE); + gal_a11y_e_cell_add_state (a11y, ATK_STATE_EXPANDED, TRUE); + } +} + +static void +ectr_do_action_collapse (AtkAction *action) +{ + GalA11yECell *a11y; + ETableModel *table_model; + ETreePath node; + ETreeModel *tree_model; + ETreeTableAdapter *tree_table_adapter; + + a11y = GAL_A11Y_E_CELL (action); + table_model = a11y->item->table_model; + node = e_table_model_value_at (table_model, -1, a11y->row); + tree_model = e_table_model_value_at (table_model, -2, a11y->row); + tree_table_adapter = e_table_model_value_at (table_model, -3, a11y->row); + + if (e_tree_model_node_is_expandable (tree_model, node)) { + e_tree_table_adapter_node_set_expanded (tree_table_adapter, + node, + FALSE); + gal_a11y_e_cell_remove_state (a11y, ATK_STATE_EXPANDED, TRUE); + } +} + +static void +ectr_class_init (GalA11yECellTreeClass *klass) +{ + a11y_parent_class = g_type_class_ref (A11Y_PARENT_TYPE); +} + +static void +ectr_init (GalA11yECellTree *a11y) +{ +} + +GType +gal_a11y_e_cell_tree_get_type (void) +{ + static GType type = 0; + + if (!type) { + GTypeInfo info = { + sizeof (GalA11yECellTreeClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) ectr_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (GalA11yECellTree), + 0, + (GInstanceInitFunc) ectr_init, + NULL /* value_cell_text */ + }; + + type = g_type_register_static (A11Y_PARENT_TYPE, "GalA11yECellTree", &info, 0); + gal_a11y_e_cell_type_add_action_interface (type); + } + + return type; +} + +AtkObject * +gal_a11y_e_cell_tree_new (ETableItem *item, + ECellView *cell_view, + AtkObject *parent, + int model_col, + int view_col, + int row) +{ + GalA11yECell *a11y; + GtkWidget *e_table; + gint model_row; + + ECellView *subcell_view; + subcell_view = e_cell_tree_view_get_subcell_view (cell_view); + + if (subcell_view->ecell) { + a11y = gal_a11y_e_cell_registry_get_object (NULL, + item, + subcell_view, + parent, + model_col, + view_col, + row); + } else { + a11y = g_object_new (gal_a11y_e_cell_tree_get_type (), NULL); + + gal_a11y_e_cell_construct (a11y, + item, + cell_view, + parent, + model_col, + view_col, + row); + } + + gal_a11y_e_cell_add_action (a11y, + "expand", + "expands the row in the ETree containing this cell", + NULL, + (ACTION_FUNC)ectr_do_action_expand); + + gal_a11y_e_cell_add_action (a11y, + "collapse", + "collapses the row in the ETree containing this cell", + NULL, + (ACTION_FUNC)ectr_do_action_collapse); + + gal_a11y_e_cell_add_state (a11y, ATK_STATE_EXPANDABLE, FALSE); + + return a11y; +} diff --git a/a11y/e-table/gal-a11y-e-cell-tree.h b/a11y/e-table/gal-a11y-e-cell-tree.h new file mode 100644 index 0000000000..4d48b66de4 --- /dev/null +++ b/a11y/e-table/gal-a11y-e-cell-tree.h @@ -0,0 +1,48 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: + * Tim Wo <tim.wo@sun.com>, Sun Microsystem Inc. 2003. + * + * Copyright (C) 2002 Ximian, Inc. + */ + +#ifndef __GAL_A11Y_E_CELL_TREE_H__ +#define __GAL_A11Y_E_CELL_TREE_H__ + +#include <glib-object.h> +#include <gal/e-table/e-table-item.h> +#include <gal/e-table/e-cell-tree.h> +#include "gal-a11y-e-cell.h" + +#define GAL_A11Y_TYPE_E_CELL_TREE (gal_a11y_e_cell_tree_get_type ()) +#define GAL_A11Y_E_CELL_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_CELL_TREE, GalA11yECellTree)) +#define GAL_A11Y_E_CELL_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_CELL_TREE, GalA11yECellTreeClass)) +#define GAL_A11Y_IS_E_CELL_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_CELL_TREE)) +#define GAL_A11Y_IS_E_CELL_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_CELL_TREE)) + +typedef struct _GalA11yECellTree GalA11yECellTree; +typedef struct _GalA11yECellTreeClass GalA11yECellTreeClass; +typedef struct _GalA11yECellTreePrivate GalA11yECellTreePrivate; + +/* This struct should actually be larger as this isn't what we derive from. + * The GalA11yECellTreePrivate comes right after the parent class structure. + **/ +struct _GalA11yECellTree { + GalA11yECell object; +}; + +struct _GalA11yECellTreeClass { + GalA11yECellClass parent_class; +}; + + +/* Standard Glib function */ +GType gal_a11y_e_cell_tree_get_type (void); +AtkObject *gal_a11y_e_cell_tree_new (ETableItem *item, + ECellView *cell_view, + AtkObject *parent, + int model_col, + int view_col, + int row); + +#endif /* ! __GAL_A11Y_E_CELL_TREE_H__ */ diff --git a/a11y/e-table/gal-a11y-e-cell.c b/a11y/e-table/gal-a11y-e-cell.c index a387c6ed6f..69dcf8d621 100644 --- a/a11y/e-table/gal-a11y-e-cell.c +++ b/a11y/e-table/gal-a11y-e-cell.c @@ -57,11 +57,24 @@ eti_dispose (GObject *object) a11y->view_col = -1; a11y->row = -1; + if (a11y->state_set) + g_object_unref (a11y->state_set); + if (parent_class->dispose) parent_class->dispose (object); } /* Static functions */ +static AtkStateSet * +eti_ref_state_set (AtkObject *accessible) +{ + GalA11yECell *cell = GAL_A11Y_E_CELL (accessible); + g_return_val_if_fail (cell->state_set, NULL); + + g_object_ref(cell->state_set); + return cell->state_set; +} + static AtkObject* eti_get_parent (AtkObject *accessible) { @@ -154,6 +167,7 @@ eti_class_init (GalA11yECellClass *klass) atk_object_class->get_parent = eti_get_parent; atk_object_class->get_index_in_parent = eti_get_index_in_parent; + atk_object_class->ref_state_set = eti_ref_state_set; } static void @@ -165,6 +179,10 @@ eti_init (GalA11yECell *a11y) a11y->model_col = -1; a11y->view_col = -1; a11y->row = -1; + + a11y->state_set = atk_state_set_new (); + atk_state_set_add_state (a11y->state_set, ATK_STATE_TRANSIENT); + atk_state_set_add_state (a11y->state_set, ATK_STATE_ENABLED); } @@ -407,9 +425,40 @@ gal_a11y_e_cell_add_state (GalA11yECell *cell, if (state_type == ATK_STATE_VISIBLE) g_signal_emit_by_name (cell, "visible_data_changed"); } + + return rc; } + else + return FALSE; } +gboolean +gal_a11y_e_cell_remove_state (GalA11yECell *cell, + AtkStateType state_type, + gboolean emit_signal) +{ + if (atk_state_set_contains_state (cell->state_set, state_type)) { + gboolean rc; + + rc = atk_state_set_remove_state (cell->state_set, state_type); + /* + * The signal should only be generated if the value changed, + * not when the cell is set up. So states that are set + * initially should pass FALSE as the emit_signal argument. + */ + + if (emit_signal) { + atk_object_notify_state_change (ATK_OBJECT (cell), state_type, FALSE); + /* If state_type is ATK_STATE_VISIBLE, additional notification */ + if (state_type == ATK_STATE_VISIBLE) + g_signal_emit_by_name (cell, "visible_data_changed"); + } + + return rc; + } + else + return FALSE; +} /** * gal_a11y_e_cell_get_type: @@ -451,6 +500,7 @@ gal_a11y_e_cell_get_type (void) return type; } + AtkObject * gal_a11y_e_cell_new (ETableItem *item, ECellView *cell_view, diff --git a/a11y/e-table/gal-a11y-e-cell.h b/a11y/e-table/gal-a11y-e-cell.h index 81f5f147ca..53a6c0089d 100644 --- a/a11y/e-table/gal-a11y-e-cell.h +++ b/a11y/e-table/gal-a11y-e-cell.h @@ -87,5 +87,13 @@ gboolean gal_a11y_e_cell_remove_action (GalA11yECell *cell, gboolean gal_a11y_e_cell_remove_action_by_name (GalA11yECell *cell, const gchar *action_name); +gboolean gal_a11y_e_cell_add_state (GalA11yECell *cell, + AtkStateType state_type, + gboolean emit_signal); + +gboolean gal_a11y_e_cell_remove_state (GalA11yECell *cell, + AtkStateType state_type, + gboolean emit_signal); + #endif /* ! __GAL_A11Y_E_CELL_H__ */ |