From 2ba68734fdf438ab3c0e519c03990ad388186a71 Mon Sep 17 00:00:00 2001 From: Tim Wo Date: Wed, 12 Nov 2003 05:12:04 +0000 Subject: new files (gal-a11y-e-cell-tree.c/h) added adding 2 new functions to add 2003-11-03 Tim Wo * gal/a11y/e-table/Makefile.am: new files (gal-a11y-e-cell-tree.c/h) added * gal/a11y/e-table/gal-a11y-e-cell.h: adding 2 new functions to add or remove atk states * gal/a11y/e-table/gal-a11y-e-cell.c (eti_dispose): unref the state_set (eti_ref_state_set): new function (eti_class_init): create and initialize the state_set (eti_init): override the "ref_state_set" function in AtkObjectClass with "eti_ref_state_set" (gal_a11y_e_cell_add_state): adding a return value (gal_a11y_e_cell_remove_state): new function * gal/e-table/e-cell-tree.c: (e_cell_tree_class_init): register GalA11yECellText as the a11y implementation for ECellText. (e_cell_tree_view_get_subcell_view): new function to retrieve the cell_view of subcell in ECellTree * gal/e-table/e-cell-tree.h: adding 1 new function to retrieve the cell_view of subcell in ECellTree * gal/a11y/e-table/gal-a11y-e-cell-tree.c: new file. A11y implementation for ECellTree * gal/a11y/e-table/gal-a11y-e-cell-tree.h: new file. A11y implementation for ECellTree svn path=/trunk/; revision=23296 --- a11y/e-table/gal-a11y-e-cell-tree.c | 154 ++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 a11y/e-table/gal-a11y-e-cell-tree.c (limited to 'a11y/e-table/gal-a11y-e-cell-tree.c') 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 , Sun Microsystem Inc. 2003. + * + * Copyright (C) 2002 Ximian, Inc. + */ + +#include +#include +#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; +} -- cgit v1.2.3