new files (gal-a11y-e-cell-tree.c/h) added adding 2 new functions to add
2003-11-03 Tim Wo <tim.wo@sun.com> * 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
This commit is contained in:
154
a11y/e-table/gal-a11y-e-cell-tree.c
Normal file
154
a11y/e-table/gal-a11y-e-cell-tree.c
Normal file
@ -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;
|
||||
}
|
48
a11y/e-table/gal-a11y-e-cell-tree.h
Normal file
48
a11y/e-table/gal-a11y-e-cell-tree.h
Normal file
@ -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__ */
|
@ -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,
|
||||
|
@ -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__ */
|
||||
|
@ -52,6 +52,9 @@
|
||||
#include "tree-expanded.xpm"
|
||||
#include "tree-unexpanded.xpm"
|
||||
|
||||
#include "gal/a11y/e-table/gal-a11y-e-cell-registry.h"
|
||||
#include "gal/a11y/e-table/gal-a11y-e-cell-tree.h"
|
||||
|
||||
#define PARENT_TYPE e_cell_get_type ()
|
||||
|
||||
typedef struct {
|
||||
@ -70,6 +73,12 @@ static ECellClass *parent_class;
|
||||
|
||||
#define INDENT_AMOUNT 16
|
||||
|
||||
ECellView *
|
||||
e_cell_tree_view_get_subcell_view (ECellView *ect)
|
||||
{
|
||||
return ((ECellTreeView *)ect)->subcell_view;
|
||||
}
|
||||
|
||||
static ETreePath
|
||||
e_cell_tree_get_node (ETableModel *table_model, int row)
|
||||
{
|
||||
@ -828,6 +837,8 @@ e_cell_tree_class_init (GObjectClass *object_class)
|
||||
ecc->get_bg_color = ect_get_bg_color;
|
||||
|
||||
parent_class = g_type_class_ref (PARENT_TYPE);
|
||||
|
||||
gal_a11y_e_cell_registry_add_cell_type (NULL, E_CELL_TREE_TYPE, gal_a11y_e_cell_tree_new);
|
||||
}
|
||||
|
||||
E_MAKE_TYPE(e_cell_tree, "ECellTree", ECellTree, e_cell_tree_class_init, NULL, PARENT_TYPE)
|
||||
|
@ -41,6 +41,7 @@ G_BEGIN_DECLS
|
||||
#define E_IS_CELL_TREE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_CELL_TREE_TYPE))
|
||||
#define E_IS_CELL_TREE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_CELL_TREE_TYPE))
|
||||
|
||||
|
||||
typedef struct {
|
||||
ECell parent;
|
||||
|
||||
@ -67,6 +68,7 @@ void e_cell_tree_construct (ECellTree *ect,
|
||||
gboolean draw_lines,
|
||||
ECell *subcell);
|
||||
|
||||
ECellView *e_cell_tree_view_get_subcell_view (ECellView *ect);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Reference in New Issue
Block a user