2003-11-11  Bolian Yin <bolian.yin@sun.com>

        Fixes #50538

        * new files:
                widgets/ea-calendar-cell.[hc]

        * widgets/ea-calendar-item: impl. atk selection and atk table interface.        * widgets/Makefile.am : use shared object library (.so)

svn path=/trunk/; revision=23283
This commit is contained in:
Bolian Yin
2003-11-11 10:33:43 +00:00
committed by Bolian Yin
parent 5a6f72675e
commit 59b0ca9123
7 changed files with 1518 additions and 9 deletions

View File

@ -1,3 +1,12 @@
2003-11-11 Bolian Yin <bolian.yin@sun.com>
Fixes #50538
* new files:
widgets/ea-calendar-cell.[hc]
* widgets/ea-calendar-item: impl. atk selection and atk table interface. * widgets/Makefile.am : use shared object library (.so)
2003-11-07 JP Rosevear <jpr@ximian.com>
* calendar/Makefile.am (INCLUDES): don't include toplevel libical

View File

@ -1,5 +1,8 @@
noinst_LTLIBRARIES = libevolution-widgets-a11y.la
# for debug
#A11Y_CFLAGS += -pedantic -ansi -DACC_DEBUG -Werror
privlib_LTLIBRARIES = libevolution-widgets-a11y.la
INCLUDES = \
-DG_LOG_DOMAIN=\"evolution-a11y\" \
@ -19,5 +22,11 @@ INCLUDES = \
libevolution_widgets_a11y_la_SOURCES = \
ea-calendar-item.c \
ea-calendar-item.h \
ea-calendar-cell.c \
ea-calendar-cell.h \
ea-widgets.c \
ea-widgets.h
libevolution_widgets_a11y_la_LIBADD = \
$(top_builddir)/a11y/libevolution-a11y.la

View File

@ -0,0 +1,305 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* vim:expandtab:shiftwidth=8:tabstop=8:
*/
/* Evolution Accessibility: ea-calendar-cell.c
*
* Copyright (C) 2003 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Bolian Yin <bolian.yin@sun.com> Sun Microsystem Inc., 2003
*
*/
#include "ea-calendar-cell.h"
#include "ea-calendar-item.h"
#include "ea-factory.h"
/* ECalendarCell */
static void e_calendar_cell_class_init (ECalendarCellClass *class);
EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_CELL, ea_calendar_cell, ea_calendar_cell_new)
GType
e_calendar_cell_get_type (void)
{
static GType type = 0;
if (!type) {
static GTypeInfo tinfo = {
sizeof (ECalendarCellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) e_calendar_cell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (ECalendarCell), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (G_TYPE_OBJECT,
"ECalendarCell", &tinfo, 0);
}
return type;
}
static void
e_calendar_cell_class_init (ECalendarCellClass *class)
{
EA_SET_FACTORY (e_calendar_cell_get_type (), ea_calendar_cell);
}
ECalendarCell *
e_calendar_cell_new (ECalendarItem *calitem, gint row, gint column)
{
GObject *object;
ECalendarCell *cell;
g_return_val_if_fail (E_IS_CALENDAR_ITEM (calitem), NULL);
object = g_object_new (E_TYPE_CALENDAR_CELL, NULL);
cell = E_CALENDAR_CELL (object);
cell->calitem = calitem;
cell->row = row;
cell->column = column;
#ifdef ACC_DEBUG
g_print ("EvoAcc: e_calendar_cell created %p\n", (void *)cell);
#endif
return cell;
}
/* EaCalendarCell */
static void ea_calendar_cell_class_init (EaCalendarCellClass *klass);
static G_CONST_RETURN gchar* ea_calendar_cell_get_name (AtkObject *accessible);
static G_CONST_RETURN gchar* ea_calendar_cell_get_description (AtkObject *accessible);
static AtkObject * ea_calendar_cell_get_parent (AtkObject *accessible);
/* component interface */
static void atk_component_interface_init (AtkComponentIface *iface);
static void component_interface_get_extents (AtkComponent *component,
gint *x, gint *y,
gint *width, gint *height,
AtkCoordType coord_type);
static gpointer parent_class = NULL;
#ifdef ACC_DEBUG
static gint n_ea_calendar_cell_created = 0, n_ea_calendar_cell_destroyed = 0;
static void ea_calendar_cell_finalize (GObject *object);
#endif
GType
ea_calendar_cell_get_type (void)
{
static GType type = 0;
if (!type) {
static GTypeInfo tinfo = {
sizeof (EaCalendarCellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) ea_calendar_cell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (EaCalendarCell), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_component_info = {
(GInterfaceInitFunc) atk_component_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (ATK_TYPE_GOBJECT_ACCESSIBLE,
"EaCalendarCell", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
&atk_component_info);
}
return type;
}
static void
ea_calendar_cell_class_init (EaCalendarCellClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
#ifdef ACC_DEBUG
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = ea_calendar_cell_finalize;
#endif
parent_class = g_type_class_peek_parent (klass);
class->get_name = ea_calendar_cell_get_name;
class->get_description = ea_calendar_cell_get_description;
class->get_parent = ea_calendar_cell_get_parent;
}
AtkObject*
ea_calendar_cell_new (GObject *obj)
{
gpointer object;
AtkObject *atk_object;
g_return_val_if_fail (E_IS_CALENDAR_CELL (obj), NULL);
object = g_object_new (EA_TYPE_CALENDAR_CELL, NULL);
atk_object = ATK_OBJECT (object);
atk_object_initialize (atk_object, obj);
atk_object->role = ATK_ROLE_TABLE_CELL;
#ifdef ACC_DEBUG
++n_ea_calendar_cell_created;
g_print ("ACC_DEBUG: n_ea_calendar_cell_created = %d\n",
n_ea_calendar_cell_created);
#endif
return atk_object;
}
#ifdef ACC_DEBUG
static void ea_calendar_cell_finalize (GObject *object)
{
++n_ea_calendar_cell_destroyed;
g_print ("ACC_DEBUG: n_ea_calendar_cell_destroyed = %d\n",
n_ea_calendar_cell_destroyed);
}
#endif
static G_CONST_RETURN gchar*
ea_calendar_cell_get_name (AtkObject *accessible)
{
GObject *g_obj;
g_return_val_if_fail (EA_IS_CALENDAR_CELL (accessible), NULL);
g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible));
if (!g_obj)
/* defunct object*/
return NULL;
if (!accessible->name) {
AtkObject *atk_obj;
EaCalendarItem *ea_calitem;
ECalendarCell *cell;
gint day_index;
gint year, month, day;
gchar buffer[128];
cell = E_CALENDAR_CELL (g_obj);
atk_obj = ea_calendar_cell_get_parent (accessible);
ea_calitem = EA_CALENDAR_ITEM (atk_obj);
day_index = atk_table_get_index_at (ATK_TABLE (ea_calitem),
cell->row, cell->column);
e_calendar_item_get_date_for_offset (cell->calitem, day_index,
&year, &month, &day);
g_snprintf (buffer, 128, "%d-%d-%d", year, month + 1, day);
ATK_OBJECT_CLASS (parent_class)->set_name (accessible, buffer);
}
return accessible->name;
}
static G_CONST_RETURN gchar*
ea_calendar_cell_get_description (AtkObject *accessible)
{
return ea_calendar_cell_get_name (accessible);
}
static AtkObject *
ea_calendar_cell_get_parent (AtkObject *accessible)
{
GObject *g_obj;
ECalendarCell *cell;
ECalendarItem *calitem;
g_return_val_if_fail (EA_IS_CALENDAR_CELL (accessible), NULL);
g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible));
if (!g_obj)
/* defunct object*/
return NULL;
cell = E_CALENDAR_CELL (g_obj);
calitem = cell->calitem;
return atk_gobject_accessible_for_object (G_OBJECT (calitem));
}
/* Atk Component Interface */
static void
atk_component_interface_init (AtkComponentIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_extents = component_interface_get_extents;
}
static void
component_interface_get_extents (AtkComponent *component,
gint *x, gint *y, gint *width, gint *height,
AtkCoordType coord_type)
{
GObject *g_obj;
AtkObject *atk_obj, *atk_canvas;
ECalendarCell *cell;
ECalendarItem *calitem;
EaCalendarItem *ea_calitem;
gint day_index;
gint year, month, day;
gint canvas_x, canvas_y, canvas_width, canvas_height;
*x = *y = *width = *height = 0;
g_return_if_fail (EA_IS_CALENDAR_CELL (component));
g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component));
if (!g_obj)
/* defunct object*/
return;
cell = E_CALENDAR_CELL (g_obj);
calitem = cell->calitem;
atk_obj = atk_gobject_accessible_for_object (G_OBJECT (calitem));
ea_calitem = EA_CALENDAR_ITEM (atk_obj);
day_index = atk_table_get_index_at (ATK_TABLE (ea_calitem),
cell->row, cell->column);
e_calendar_item_get_date_for_offset (calitem, day_index,
&year, &month, &day);
if (!e_calendar_item_get_day_extents (calitem,
year, month, day,
x, y, width, height))
return;
atk_canvas = atk_object_get_parent (ATK_OBJECT (ea_calitem));
atk_component_get_extents (ATK_COMPONENT (atk_canvas),
&canvas_x, &canvas_y,
&canvas_width, &canvas_height,
coord_type);
*x += canvas_x;
*y += canvas_y;
}

View File

@ -0,0 +1,92 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* vim:expandtab:shiftwidth=8:tabstop=8:
*/
/* Evolution Accessibility: ea-calendar-cell.h
*
* Copyright (C) 2003 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Bolian Yin <bolian.yin@sun.com> Sun Microsystem Inc., 2003
*
*/
#ifndef __EA_CALENDAR_CELL_H__
#define __EA_CALENDAR_CELL_H__
#include <atk/atkgobjectaccessible.h>
#include "misc/e-calendar-item.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define E_TYPE_CALENDAR_CELL (e_calendar_cell_get_type ())
#define E_CALENDAR_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CALENDAR_CELL, ECalendarCell))
#define E_CALENDAR_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CALENDAR_CELL, ECalendarCellClass))
#define E_IS_CALENDAR_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CALENDAR_CELL))
#define E_IS_CALENDAR_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CALENDAR_CELL))
#define E_CALENDAR_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_CALENDAR_CELL, ECalendarCellClass))
typedef struct _ECalendarCell ECalendarCell;
typedef struct _ECalendarCellClass ECalendarCellClass;
struct _ECalendarCell
{
GObject parent;
ECalendarItem *calitem;
gint row;
gint column;
};
GType e_calendar_cell_get_type (void);
struct _ECalendarCellClass
{
GObjectClass parent_class;
};
ECalendarCell * e_calendar_cell_new (ECalendarItem *calitem,
gint row, gint column);
#define EA_TYPE_CALENDAR_CELL (ea_calendar_cell_get_type ())
#define EA_CALENDAR_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CALENDAR_CELL, EaCalendarCell))
#define EA_CALENDAR_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CALENDAR_CELL, EaCalendarCellClass))
#define EA_IS_CALENDAR_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CALENDAR_CELL))
#define EA_IS_CALENDAR_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CALENDAR_CELL))
#define EA_CALENDAR_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CALENDAR_CELL, EaCalendarCellClass))
typedef struct _EaCalendarCell EaCalendarCell;
typedef struct _EaCalendarCellClass EaCalendarCellClass;
struct _EaCalendarCell
{
AtkGObjectAccessible parent;
};
GType ea_calendar_cell_get_type (void);
struct _EaCalendarCellClass
{
AtkGObjectAccessibleClass parent_class;
};
AtkObject* ea_calendar_cell_new (GObject *gobj);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __EA_CALENDAR_CELL_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -56,6 +56,18 @@ struct _EaCalendarItemClass
};
AtkObject *ea_calendar_item_new (GObject *obj);
gboolean e_calendar_item_get_day_extents (ECalendarItem *calitem,
gint year, gint month, gint date,
gint *x, gint *y,
gint *width, gint *height);
gboolean e_calendar_item_get_date_for_offset (ECalendarItem *calitem,
gint day_offset,
gint *year, gint *month,
gint *day);
gint e_calendar_item_get_offset_for_date (ECalendarItem *calitem,
gint year, gint month, gint day);
gint e_calendar_item_get_n_days_from_week_start (ECalendarItem *calitem,
gint year, gint month);
#ifdef __cplusplus
}

View File

@ -27,7 +27,7 @@
#include "widgets/ea-calendar-item.h"
#include "ea-widgets.h"
EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new);
EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new)
void e_calendar_item_a11y_init (void)
{