evolution-3.6.4/calendar/gui/ea-week-view-main-item.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found ea-week-view-main-item.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found ea-week-view-main-item.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
   1 /*
   2  * Evolution Accessibility: ea-week-view-main-item.c
   3  *
   4  * This program is free software; you can redistribute it and/or
   5  * modify it under the terms of the GNU Lesser General Public
   6  * License as published by the Free Software Foundation; either
   7  * version 2 of the License, or (at your option) version 3.
   8  *
   9  * This program is distributed in the hope that it will be useful,
  10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12  * Lesser General Public License for more details.
  13  *
  14  * You should have received a copy of the GNU Lesser General Public
  15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
  16  *
  17  *
  18  * Authors:
  19  *
  20  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
  21  *
  22  */
  23 
  24 #ifdef HAVE_CONFIG_H
  25 #include <config.h>
  26 #endif
  27 
  28 #include "ea-week-view-main-item.h"
  29 #include "ea-week-view.h"
  30 #include "ea-week-view-cell.h"
  31 #include "ea-cell-table.h"
  32 #include <glib/gi18n.h>
  33 
  34 /* EaWeekViewMainItem */
  35 static void	ea_week_view_main_item_class_init
  36 						(EaWeekViewMainItemClass *class);
  37 static void	ea_week_view_main_item_finalize	(GObject *object);
  38 static const gchar *
  39 		ea_week_view_main_item_get_name	(AtkObject *accessible);
  40 static const gchar *
  41 		ea_week_view_main_item_get_description
  42 						(AtkObject *accessible);
  43 static gint	ea_week_view_main_item_get_n_children
  44 						(AtkObject *accessible);
  45 static AtkObject *
  46 		ea_week_view_main_item_ref_child (AtkObject *accessible,
  47 						 gint i);
  48 static AtkObject *
  49 		ea_week_view_main_item_get_parent
  50 						(AtkObject *accessible);
  51 static gint	ea_week_view_main_item_get_index_in_parent
  52 						(AtkObject *accessible);
  53 
  54 /* callbacks */
  55 static void	ea_week_view_main_item_dates_change_cb
  56 						(GnomeCalendar *gcal,
  57 						 gpointer data);
  58 static void	ea_week_view_main_item_time_change_cb
  59 						(EWeekView *week_view,
  60 						 gpointer data);
  61 
  62 /* component interface */
  63 static void	atk_component_interface_init	(AtkComponentIface *iface);
  64 static void	component_interface_get_extents	(AtkComponent *component,
  65 						 gint *x,
  66 						 gint *y,
  67 						 gint *width,
  68 						 gint *height,
  69 						 AtkCoordType coord_type);
  70 
  71 /* atk table interface */
  72 static void	atk_table_interface_init	(AtkTableIface *iface);
  73 static gint	table_interface_get_index_at	(AtkTable *table,
  74 						 gint row,
  75 						 gint column);
  76 static gint	table_interface_get_column_at_index
  77 						(AtkTable *table,
  78 						 gint index);
  79 static gint	table_interface_get_row_at_index (AtkTable *table,
  80 						 gint index);
  81 static AtkObject *
  82 		table_interface_ref_at		(AtkTable *table,
  83 						 gint row,
  84 						 gint column);
  85 static gint	table_interface_get_n_rows	(AtkTable *table);
  86 static gint	table_interface_get_n_columns	(AtkTable *table);
  87 static gint	table_interface_get_column_extent_at
  88 						(AtkTable *table,
  89 						 gint row,
  90 						 gint column);
  91 static gint	table_interface_get_row_extent_at
  92 						(AtkTable *table,
  93 						 gint row,
  94 						 gint column);
  95 
  96 static gboolean	table_interface_is_row_selected	(AtkTable *table,
  97 						 gint row);
  98 static gboolean	table_interface_is_column_selected
  99 						(AtkTable *table,
 100 						 gint row);
 101 static gboolean	table_interface_is_selected	(AtkTable *table,
 102 						 gint row,
 103 						 gint column);
 104 static gint	table_interface_get_selected_rows
 105 						(AtkTable *table,
 106 						 gint **rows_selected);
 107 static gint	table_interface_get_selected_columns
 108 						(AtkTable *table,
 109 						 gint **columns_selected);
 110 static gboolean	table_interface_add_row_selection
 111 						(AtkTable *table,
 112 						 gint row);
 113 static gboolean	table_interface_remove_row_selection
 114 						(AtkTable *table,
 115 						 gint row);
 116 static gboolean	table_interface_add_column_selection
 117 						(AtkTable *table,
 118 						 gint column);
 119 static gboolean	table_interface_remove_column_selection
 120 						(AtkTable *table,
 121 						 gint column);
 122 static AtkObject *
 123 		table_interface_get_row_header	(AtkTable *table,
 124 						 gint row);
 125 static AtkObject *
 126 		table_interface_get_column_header
 127 						(AtkTable *table,
 128 						 gint in_col);
 129 static AtkObject *
 130 		table_interface_get_caption	(AtkTable *table);
 131 
 132 static const gchar *
 133 		table_interface_get_column_description
 134 						(AtkTable *table,
 135 						 gint in_col);
 136 
 137 static const gchar *
 138 		table_interface_get_row_description
 139 						(AtkTable *table,
 140 						 gint row);
 141 
 142 static AtkObject *
 143 		table_interface_get_summary	(AtkTable *table);
 144 
 145 /* atk selection interface */
 146 static void atk_selection_interface_init (AtkSelectionIface *iface);
 147 static gboolean selection_interface_add_selection (AtkSelection *selection,
 148 						   gint i);
 149 static gboolean selection_interface_clear_selection (AtkSelection *selection);
 150 static AtkObject * selection_interface_ref_selection (AtkSelection *selection,
 151 						     gint i);
 152 static gint selection_interface_get_selection_count (AtkSelection *selection);
 153 static gboolean selection_interface_is_child_selected (AtkSelection *selection,
 154 						       gint i);
 155 
 156 /* helpers */
 157 static EaCellTable *
 158 		ea_week_view_main_item_get_cell_data
 159 						(EaWeekViewMainItem *ea_main_item);
 160 
 161 static void	ea_week_view_main_item_destory_cell_data
 162 						(EaWeekViewMainItem *ea_main_item);
 163 
 164 static gint	ea_week_view_main_item_get_child_index_at
 165 						(EaWeekViewMainItem *ea_main_item,
 166 						 gint row,
 167 						 gint column);
 168 static gint	ea_week_view_main_item_get_row_at_index
 169 						(EaWeekViewMainItem *ea_main_item,
 170 						 gint index);
 171 static gint	ea_week_view_main_item_get_column_at_index
 172 						(EaWeekViewMainItem *ea_main_item,
 173 						 gint index);
 174 static gint	ea_week_view_main_item_get_row_label
 175 						(EaWeekViewMainItem *ea_main_item,
 176 						 gint row,
 177 						 gchar *buffer,
 178 						 gint buffer_size);
 179 
 180 #ifdef ACC_DEBUG
 181 static gint n_ea_week_view_main_item_created = 0;
 182 static gint n_ea_week_view_main_item_destroyed = 0;
 183 #endif
 184 
 185 static gpointer parent_class = NULL;
 186 
 187 GType
 188 ea_week_view_main_item_get_type (void)
 189 {
 190 	static GType type = 0;
 191 	AtkObjectFactory *factory;
 192 	GTypeQuery query;
 193 	GType derived_atk_type;
 194 
 195 	if (!type) {
 196 		static GTypeInfo tinfo = {
 197 			sizeof (EaWeekViewMainItemClass),
 198 			(GBaseInitFunc) NULL, /* base init */
 199 			(GBaseFinalizeFunc) NULL, /* base finalize */
 200 			(GClassInitFunc) ea_week_view_main_item_class_init,
 201 			(GClassFinalizeFunc) NULL, /* class finalize */
 202 			NULL, /* class data */
 203 			sizeof (EaWeekViewMainItem), /* instance size */
 204 			0, /* nb preallocs */
 205 			(GInstanceInitFunc) NULL, /* instance init */
 206 			NULL /* value table */
 207 		};
 208 
 209 		static const GInterfaceInfo atk_component_info = {
 210 			(GInterfaceInitFunc) atk_component_interface_init,
 211 			(GInterfaceFinalizeFunc) NULL,
 212 			NULL
 213 		};
 214 
 215 		static const GInterfaceInfo atk_table_info = {
 216 			(GInterfaceInitFunc) atk_table_interface_init,
 217 			(GInterfaceFinalizeFunc) NULL,
 218 			NULL
 219 		};
 220 		static const GInterfaceInfo atk_selection_info = {
 221 			(GInterfaceInitFunc) atk_selection_interface_init,
 222 			(GInterfaceFinalizeFunc) NULL,
 223 			NULL
 224 		};
 225 
 226 		/*
 227 		 * Figure out the size of the class and instance
 228 		 * we are run-time deriving from (GailCanvasItem, in this case)
 229 		 *
 230 		 */
 231 
 232 		factory = atk_registry_get_factory (
 233 			atk_get_default_registry (),
 234 			e_week_view_main_item_get_type ());
 235 		derived_atk_type = atk_object_factory_get_accessible_type (factory);
 236 		g_type_query (derived_atk_type, &query);
 237 
 238 		tinfo.class_size = query.class_size;
 239 		tinfo.instance_size = query.instance_size;
 240 
 241 		type = g_type_register_static (
 242 			derived_atk_type,
 243 			"EaWeekViewMainItem", &tinfo, 0);
 244 		g_type_add_interface_static (
 245 			type, ATK_TYPE_COMPONENT,
 246 			&atk_component_info);
 247 		g_type_add_interface_static (
 248 			type, ATK_TYPE_TABLE,
 249 			&atk_table_info);
 250 		g_type_add_interface_static (
 251 			type, ATK_TYPE_SELECTION,
 252 			&atk_selection_info);
 253 	}
 254 
 255 	return type;
 256 }
 257 
 258 static void
 259 ea_week_view_main_item_class_init (EaWeekViewMainItemClass *klass)
 260 {
 261 	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 262 	AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
 263 
 264 	gobject_class->finalize = ea_week_view_main_item_finalize;
 265 	parent_class = g_type_class_peek_parent (klass);
 266 
 267 	class->get_name = ea_week_view_main_item_get_name;
 268 	class->get_description = ea_week_view_main_item_get_description;
 269 
 270 	class->get_n_children = ea_week_view_main_item_get_n_children;
 271 	class->ref_child = ea_week_view_main_item_ref_child;
 272 	class->get_parent = ea_week_view_main_item_get_parent;
 273 	class->get_index_in_parent = ea_week_view_main_item_get_index_in_parent;
 274 }
 275 
 276 AtkObject *
 277 ea_week_view_main_item_new (GObject *obj)
 278 {
 279 	AtkObject *accessible;
 280 	GnomeCalendar *gcal;
 281 	EWeekViewMainItem *main_item;
 282 	EWeekView *week_view;
 283 
 284 	g_return_val_if_fail (E_IS_WEEK_VIEW_MAIN_ITEM (obj), NULL);
 285 
 286 	accessible = ATK_OBJECT (
 287 		g_object_new (EA_TYPE_WEEK_VIEW_MAIN_ITEM,
 288 		NULL));
 289 
 290 	atk_object_initialize (accessible, obj);
 291 	accessible->role = ATK_ROLE_TABLE;
 292 
 293 #ifdef ACC_DEBUG
 294 	++n_ea_week_view_main_item_created;
 295 	printf (
 296 		"ACC_DEBUG: n_ea_week_view_main_item_created = %d\n",
 297 		n_ea_week_view_main_item_created);
 298 #endif
 299 
 300 	main_item = E_WEEK_VIEW_MAIN_ITEM (obj);
 301 	week_view = e_week_view_main_item_get_week_view (main_item);
 302 
 303 	g_signal_connect (
 304 		week_view, "selected_time_changed",
 305 		G_CALLBACK (ea_week_view_main_item_time_change_cb),
 306 		accessible);
 307 
 308 	/* listen for date changes of calendar */
 309 	gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (week_view));
 310 	if (gcal)
 311 		g_signal_connect (
 312 			gcal, "dates_shown_changed",
 313 			G_CALLBACK (ea_week_view_main_item_dates_change_cb),
 314 			accessible);
 315 
 316 	return accessible;
 317 }
 318 
 319 static void
 320 ea_week_view_main_item_finalize (GObject *object)
 321 {
 322 	EaWeekViewMainItem *ea_main_item;
 323 
 324 	g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (object));
 325 
 326 	ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (object);
 327 
 328 	/* Free the allocated cell data */
 329 	ea_week_view_main_item_destory_cell_data (ea_main_item);
 330 
 331 	G_OBJECT_CLASS (parent_class)->finalize (object);
 332 #ifdef ACC_DEBUG
 333 	++n_ea_week_view_main_item_destroyed;
 334 	printf (
 335 		"ACC_DEBUG: n_ea_week_view_main_item_destroyed = %d\n",
 336 		n_ea_week_view_main_item_destroyed);
 337 #endif
 338 }
 339 
 340 static const gchar *
 341 ea_week_view_main_item_get_name (AtkObject *accessible)
 342 {
 343 	AtkObject *parent;
 344 	g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL);
 345 	parent = atk_object_get_parent (accessible);
 346 	return atk_object_get_name (parent);
 347 
 348 }
 349 
 350 static const gchar *
 351 ea_week_view_main_item_get_description (AtkObject *accessible)
 352 {
 353 	return _("a table to view and select the current time range");
 354 }
 355 
 356 static gint
 357 ea_week_view_main_item_get_n_children (AtkObject *accessible)
 358 {
 359 	AtkGObjectAccessible *atk_gobj;
 360 	GObject *g_obj;
 361 	EWeekViewMainItem *main_item;
 362 	EWeekView *week_view;
 363 
 364 	g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), -1);
 365 
 366 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
 367 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 368 	if (!g_obj)
 369 		return -1;
 370 
 371 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 372 	week_view = e_week_view_main_item_get_week_view (main_item);
 373 
 374 	if (week_view->multi_week_view)
 375 		return 7 * week_view->weeks_shown;
 376 	else
 377 		return 7;
 378 }
 379 
 380 static AtkObject *
 381 ea_week_view_main_item_ref_child (AtkObject *accessible,
 382                                   gint index)
 383 {
 384 	AtkGObjectAccessible *atk_gobj;
 385 	GObject *g_obj;
 386 	EWeekViewMainItem *main_item;
 387 	EWeekView *week_view;
 388 	gint n_children;
 389 	EWeekViewCell *cell;
 390 	EaCellTable *cell_data;
 391 	EaWeekViewMainItem *ea_main_item;
 392 
 393 	g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL);
 394 
 395 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
 396 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 397 	if (!g_obj)
 398 		return NULL;
 399 
 400 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 401 	week_view = e_week_view_main_item_get_week_view (main_item);
 402 
 403 	n_children = ea_week_view_main_item_get_n_children (accessible);
 404 	if (index < 0 || index >= n_children)
 405 		return NULL;
 406 
 407 	ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (accessible);
 408 	cell_data = ea_week_view_main_item_get_cell_data (ea_main_item);
 409 	if (!cell_data)
 410 		return NULL;
 411 	cell = ea_cell_table_get_cell_at_index (cell_data, index);
 412 	if (!cell) {
 413 		gint row, column;
 414 
 415 		row = ea_week_view_main_item_get_row_at_index (ea_main_item, index);
 416 		column = ea_week_view_main_item_get_column_at_index (ea_main_item, index);
 417 		cell = e_week_view_cell_new (week_view, row, column);
 418 		ea_cell_table_set_cell_at_index (cell_data, index, cell);
 419 		g_object_unref (cell);
 420 	}
 421 
 422 	return g_object_ref (atk_gobject_accessible_for_object (G_OBJECT (cell)));
 423 }
 424 
 425 static AtkObject *
 426 ea_week_view_main_item_get_parent (AtkObject *accessible)
 427 {
 428 	AtkGObjectAccessible *atk_gobj;
 429 	GObject *g_obj;
 430 	EWeekViewMainItem *main_item;
 431 	EWeekView *week_view;
 432 
 433 	g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL);
 434 
 435 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
 436 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 437 	if (!g_obj)
 438 		return NULL;
 439 
 440 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 441 	week_view = e_week_view_main_item_get_week_view (main_item);
 442 
 443 	return gtk_widget_get_accessible (GTK_WIDGET (week_view));
 444 }
 445 
 446 static gint
 447 ea_week_view_main_item_get_index_in_parent (AtkObject *accessible)
 448 {
 449 	AtkGObjectAccessible *atk_gobj;
 450 	GObject *g_obj;
 451 
 452 	g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), -1);
 453 
 454 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible);
 455 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 456 	if (!g_obj)
 457 		return -1;
 458 
 459 	/* always the first child of ea-week-view */
 460 	return 0;
 461 }
 462 
 463 /* callbacks */
 464 
 465 static void
 466 ea_week_view_main_item_dates_change_cb (GnomeCalendar *gcal,
 467                                         gpointer data)
 468 {
 469 	EaWeekViewMainItem *ea_main_item;
 470 
 471 	g_return_if_fail (GNOME_IS_CALENDAR (gcal));
 472 	g_return_if_fail (data);
 473 	g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (data));
 474 
 475 	ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (data);
 476 
 477 #ifdef ACC_DEBUG
 478 	printf ("EvoAcc: ea_week_view_main_item update cb\n");
 479 #endif
 480 
 481 	ea_week_view_main_item_destory_cell_data (ea_main_item);
 482 }
 483 
 484 static void
 485 ea_week_view_main_item_time_change_cb (EWeekView *week_view,
 486                                        gpointer data)
 487 {
 488 	EaWeekViewMainItem *ea_main_item;
 489 	AtkObject *item_cell = NULL;
 490 
 491 	g_return_if_fail (E_IS_WEEK_VIEW (week_view));
 492 	g_return_if_fail (data);
 493 	g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (data));
 494 
 495 	ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (data);
 496 
 497 #ifdef ACC_DEBUG
 498 	printf ("EvoAcc: ea_week_view_main_item time changed cb\n");
 499 #endif
 500 	/* only deal with the first selected child, for now */
 501 	item_cell = atk_selection_ref_selection (
 502 		ATK_SELECTION (ea_main_item),
 503 		0);
 504 	if (item_cell) {
 505 		AtkStateSet *state_set;
 506 		state_set = atk_object_ref_state_set (item_cell);
 507 		atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
 508 		g_object_unref (state_set);
 509 
 510 		g_signal_emit_by_name (
 511 			ea_main_item,
 512 			"active-descendant-changed",
 513 			item_cell);
 514 		g_signal_emit_by_name (data, "selection_changed");
 515 		atk_focus_tracker_notify (item_cell);
 516 		g_object_unref (item_cell);
 517 	}
 518 }
 519 
 520 /* helpers */
 521 
 522 static gint
 523 ea_week_view_main_item_get_child_index_at (EaWeekViewMainItem *ea_main_item,
 524                                            gint row,
 525                                            gint column)
 526 {
 527 	AtkGObjectAccessible *atk_gobj;
 528 	GObject *g_obj;
 529 	EWeekViewMainItem *main_item;
 530 	EWeekView *week_view;
 531 
 532 	g_return_val_if_fail (ea_main_item, -1);
 533 
 534 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 535 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 536 	if (!g_obj)
 537 		return -1;
 538 
 539 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 540 	week_view = e_week_view_main_item_get_week_view (main_item);
 541 
 542 	if (row >= 0 && row < week_view->weeks_shown &&
 543 	    column >= 0 && column < 7)
 544 		return row * 7 + column;
 545 
 546 	return -1;
 547 }
 548 
 549 static gint
 550 ea_week_view_main_item_get_row_at_index (EaWeekViewMainItem *ea_main_item,
 551                                          gint index)
 552 {
 553 	AtkGObjectAccessible *atk_gobj;
 554 	GObject *g_obj;
 555 	gint n_children;
 556 
 557 	g_return_val_if_fail (ea_main_item, -1);
 558 
 559 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 560 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 561 	if (!g_obj)
 562 		return -1;
 563 
 564 	n_children = ea_week_view_main_item_get_n_children (ATK_OBJECT (ea_main_item));
 565 	if (index >= 0 && index < n_children)
 566 		return index / 7;
 567 	return -1;
 568 }
 569 
 570 static gint
 571 ea_week_view_main_item_get_column_at_index (EaWeekViewMainItem *ea_main_item,
 572                                             gint index)
 573 {
 574 	AtkGObjectAccessible *atk_gobj;
 575 	GObject *g_obj;
 576 	gint n_children;
 577 
 578 	g_return_val_if_fail (ea_main_item, -1);
 579 
 580 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 581 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 582 	if (!g_obj)
 583 		return -1;
 584 
 585 	n_children = ea_week_view_main_item_get_n_children (ATK_OBJECT (ea_main_item));
 586 	if (index >= 0 && index < n_children)
 587 		return index % 7;
 588 	return -1;
 589 }
 590 
 591 static gint
 592 ea_week_view_main_item_get_row_label (EaWeekViewMainItem *ea_main_item,
 593                                       gint row,
 594                                       gchar *buffer,
 595                                       gint buffer_size)
 596 {
 597 	AtkGObjectAccessible *atk_gobj;
 598 	GObject *g_obj;
 599 
 600 	g_return_val_if_fail (ea_main_item, 0);
 601 
 602 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 603 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 604 	if (!g_obj)
 605 		return 0;
 606 
 607 	return g_snprintf (
 608 		buffer, buffer_size, "the %i week",
 609 		row + 1);
 610 
 611 }
 612 
 613 static EaCellTable *
 614 ea_week_view_main_item_get_cell_data (EaWeekViewMainItem *ea_main_item)
 615 {
 616 	AtkGObjectAccessible *atk_gobj;
 617 	GObject *g_obj;
 618 	EWeekViewMainItem *main_item;
 619 	EWeekView *week_view;
 620 	EaCellTable *cell_data;
 621 
 622 	g_return_val_if_fail (ea_main_item, NULL);
 623 
 624 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 625 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 626 	if (!g_obj)
 627 		return NULL;
 628 
 629 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 630 	week_view = e_week_view_main_item_get_week_view (main_item);
 631 
 632 	cell_data = g_object_get_data (
 633 		G_OBJECT (ea_main_item),
 634 		"ea-week-view-cell-table");
 635 	if (!cell_data) {
 636 		cell_data = ea_cell_table_create (week_view->weeks_shown, 7, TRUE);
 637 		g_object_set_data (
 638 			G_OBJECT (ea_main_item),
 639 			"ea-week-view-cell-table", cell_data);
 640 	}
 641 	return cell_data;
 642 }
 643 
 644 static void
 645 ea_week_view_main_item_destory_cell_data (EaWeekViewMainItem *ea_main_item)
 646 {
 647 	EaCellTable *cell_data;
 648 
 649 	g_return_if_fail (ea_main_item);
 650 
 651 	cell_data = g_object_get_data (
 652 		G_OBJECT (ea_main_item),
 653 		"ea-week-view-cell-table");
 654 	if (cell_data) {
 655 		g_object_set_data (
 656 			G_OBJECT (ea_main_item),
 657 			"ea-week-view-cell-table", NULL);
 658 		ea_cell_table_destroy (cell_data);
 659 	}
 660 }
 661 
 662 /* Atk Component Interface */
 663 
 664 static void
 665 atk_component_interface_init (AtkComponentIface *iface)
 666 {
 667 	g_return_if_fail (iface != NULL);
 668 
 669 	iface->get_extents = component_interface_get_extents;
 670 }
 671 
 672 static void
 673 component_interface_get_extents (AtkComponent *component,
 674                                  gint *x,
 675                                  gint *y,
 676                                  gint *width,
 677                                  gint *height,
 678                                  AtkCoordType coord_type)
 679 {
 680 	GObject *g_obj;
 681 	AtkObject *ea_canvas;
 682 	EWeekViewMainItem *main_item;
 683 	EWeekView *week_view;
 684 
 685 	*x = *y = *width = *height = 0;
 686 
 687 	g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (component));
 688 
 689 	g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (component));
 690 	if (!g_obj)
 691 		/* defunct object*/
 692 		return;
 693 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 694 	week_view = e_week_view_main_item_get_week_view (main_item);
 695 
 696 	ea_canvas = gtk_widget_get_accessible (week_view->main_canvas);
 697 	atk_component_get_extents (
 698 		ATK_COMPONENT (ea_canvas), x, y,
 699 		width, height, coord_type);
 700 }
 701 
 702 /* atk table interface */
 703 
 704 static void
 705 atk_table_interface_init (AtkTableIface *iface)
 706 {
 707 	g_return_if_fail (iface != NULL);
 708 
 709 	iface->ref_at = table_interface_ref_at;
 710 
 711 	iface->get_n_rows = table_interface_get_n_rows;
 712 	iface->get_n_columns = table_interface_get_n_columns;
 713 	iface->get_index_at = table_interface_get_index_at;
 714 	iface->get_column_at_index = table_interface_get_column_at_index;
 715 	iface->get_row_at_index = table_interface_get_row_at_index;
 716 	iface->get_column_extent_at = table_interface_get_column_extent_at;
 717 	iface->get_row_extent_at = table_interface_get_row_extent_at;
 718 
 719 	iface->is_selected = table_interface_is_selected;
 720 	iface->get_selected_rows = table_interface_get_selected_rows;
 721 	iface->get_selected_columns = table_interface_get_selected_columns;
 722 	iface->is_row_selected = table_interface_is_row_selected;
 723 	iface->is_column_selected = table_interface_is_column_selected;
 724 	iface->add_row_selection = table_interface_add_row_selection;
 725 	iface->remove_row_selection = table_interface_remove_row_selection;
 726 	iface->add_column_selection = table_interface_add_column_selection;
 727 	iface->remove_column_selection = table_interface_remove_column_selection;
 728 
 729 	iface->get_row_header = table_interface_get_row_header;
 730 	iface->get_column_header = table_interface_get_column_header;
 731 	iface->get_caption = table_interface_get_caption;
 732 	iface->get_summary = table_interface_get_summary;
 733 	iface->get_row_description = table_interface_get_row_description;
 734 	iface->get_column_description = table_interface_get_column_description;
 735 }
 736 
 737 static AtkObject *
 738 table_interface_ref_at (AtkTable *table,
 739                         gint row,
 740                         gint column)
 741 {
 742 	gint index;
 743 
 744 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 745 	index = ea_week_view_main_item_get_child_index_at (
 746 		ea_main_item,
 747 		row, column);
 748 	return ea_week_view_main_item_ref_child (ATK_OBJECT (ea_main_item), index);
 749 }
 750 
 751 static gint
 752 table_interface_get_n_rows (AtkTable *table)
 753 {
 754 	AtkGObjectAccessible *atk_gobj;
 755 	GObject *g_obj;
 756 	EWeekViewMainItem *main_item;
 757 	EWeekView *week_view;
 758 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 759 
 760 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 761 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 762 	if (!g_obj)
 763 		return -1;
 764 
 765 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 766 	week_view = e_week_view_main_item_get_week_view (main_item);
 767 
 768 	return week_view->weeks_shown;
 769 }
 770 
 771 static gint
 772 table_interface_get_n_columns (AtkTable *table)
 773 {
 774 	AtkGObjectAccessible *atk_gobj;
 775 	GObject *g_obj;
 776 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 777 
 778 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 779 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 780 	if (!g_obj)
 781 		return -1;
 782 
 783 	return 7;
 784 }
 785 
 786 static gint
 787 table_interface_get_index_at (AtkTable *table,
 788                               gint row,
 789                               gint column)
 790 {
 791 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 792 	return ea_week_view_main_item_get_child_index_at (
 793 		ea_main_item,
 794 		row, column);
 795 }
 796 
 797 static gint
 798 table_interface_get_column_at_index (AtkTable *table,
 799                                      gint index)
 800 {
 801 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 802 	return ea_week_view_main_item_get_column_at_index (ea_main_item, index);
 803 }
 804 
 805 static gint
 806 table_interface_get_row_at_index (AtkTable *table,
 807                                   gint index)
 808 {
 809 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 810 	return ea_week_view_main_item_get_row_at_index (ea_main_item, index);
 811 }
 812 
 813 static gint
 814 table_interface_get_column_extent_at (AtkTable *table,
 815                                       gint row,
 816                                       gint column)
 817 {
 818 	gint index;
 819 	gint width = 0, height = 0;
 820 	AtkObject *child;
 821 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 822 
 823 	index = ea_week_view_main_item_get_child_index_at (
 824 		ea_main_item, row, column);
 825 	child = atk_object_ref_accessible_child (
 826 		ATK_OBJECT (ea_main_item), index);
 827 	if (child)
 828 		atk_component_get_size (
 829 			ATK_COMPONENT (child), &width, &height);
 830 
 831 	return width;
 832 }
 833 
 834 static gint
 835 table_interface_get_row_extent_at (AtkTable *table,
 836                                    gint row,
 837                                    gint column)
 838 {
 839 	gint index;
 840 	gint width = 0, height = 0;
 841 	AtkObject *child;
 842 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 843 
 844 	index = ea_week_view_main_item_get_child_index_at (
 845 		ea_main_item, row, column);
 846 	child = atk_object_ref_accessible_child (
 847 		ATK_OBJECT (ea_main_item), index);
 848 	if (child)
 849 		atk_component_get_size (
 850 			ATK_COMPONENT (child), &width, &height);
 851 
 852 	return height;
 853 }
 854 
 855 static gboolean
 856 table_interface_is_row_selected (AtkTable *table,
 857                                  gint row)
 858 {
 859 	AtkGObjectAccessible *atk_gobj;
 860 	GObject *g_obj;
 861 	EWeekViewMainItem *main_item;
 862 	EWeekView *week_view;
 863 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 864 
 865 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 866 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 867 	if (!g_obj)
 868 		return FALSE;
 869 
 870 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 871 	week_view = e_week_view_main_item_get_week_view (main_item);
 872 
 873 	if (week_view->selection_start_day == -1)
 874 		/* no selection */
 875 		return FALSE;
 876 	if ((row < 0) && (row + 1 > week_view->weeks_shown))
 877 		return FALSE;
 878 	if (((week_view->selection_start_day < row * 7) &&
 879 		(week_view->selection_end_day < row * 7)) ||
 880 		((week_view->selection_start_day > row * 7 + 6) &&
 881 		(week_view->selection_end_day > row * 7 + 6)))
 882 		return FALSE;
 883 	else
 884 		return TRUE;
 885 }
 886 
 887 static gboolean
 888 table_interface_is_selected (AtkTable *table,
 889                              gint row,
 890                              gint column)
 891 {
 892 	return table_interface_is_row_selected (table, row) &&
 893 		table_interface_is_column_selected (table, column);
 894 }
 895 
 896 static gboolean
 897 table_interface_is_column_selected (AtkTable *table,
 898                                     gint column)
 899 {
 900 	AtkGObjectAccessible *atk_gobj;
 901 	GObject *g_obj;
 902 	EWeekViewMainItem *main_item;
 903 	EWeekView *week_view;
 904 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 905 
 906 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 907 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 908 	if (!g_obj)
 909 		return FALSE;
 910 
 911 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 912 	week_view = e_week_view_main_item_get_week_view (main_item);
 913 
 914 	if ((column <0) || (column >6))
 915 		return FALSE;
 916 	else {
 917 		gint i;
 918 		for (i = 0; i < week_view->weeks_shown; i++)
 919 			if ((column + i *7>= week_view->selection_start_day) &&
 920 			    (column + i *7<= week_view->selection_end_day))
 921 				return TRUE;
 922 		return FALSE;
 923 	}
 924 }
 925 
 926 static gint
 927 table_interface_get_selected_rows (AtkTable *table,
 928                                    gint **rows_selected)
 929 {
 930 	AtkGObjectAccessible *atk_gobj;
 931 	GObject *g_obj;
 932 	EWeekViewMainItem *main_item;
 933 	EWeekView *week_view;
 934 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 935 	gint start_row = -1, n_rows = 0;
 936 
 937 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 938 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 939 	if (!g_obj)
 940 		return -1;
 941 
 942 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 943 	week_view = e_week_view_main_item_get_week_view (main_item);
 944 
 945 	if (week_view->selection_start_day == -1)
 946 		return 0;
 947 
 948 	start_row = week_view->selection_start_day;
 949 	n_rows = week_view->selection_end_day - start_row + 1;
 950 
 951 	if (n_rows > 0 && start_row != -1 && rows_selected) {
 952 		gint index;
 953 
 954 		*rows_selected = (gint *) g_malloc (n_rows * sizeof (gint));
 955 		for (index = 0; index < n_rows; ++index)
 956 			(*rows_selected)[index] = start_row + index;
 957 	}
 958 	return n_rows;
 959 }
 960 
 961 static gint
 962 table_interface_get_selected_columns (AtkTable *table,
 963                                       gint **columns_selected)
 964 {
 965 	AtkGObjectAccessible *atk_gobj;
 966 	GObject *g_obj;
 967 	EWeekViewMainItem *main_item;
 968 	EWeekView *week_view;
 969 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
 970 	gint start_column = -1, n_columns = 0;
 971 
 972 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
 973 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
 974 	if (!g_obj)
 975 		return -1;
 976 
 977 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
 978 	week_view = e_week_view_main_item_get_week_view (main_item);
 979 
 980 	if (week_view->selection_start_day == -1)
 981 		return 0;
 982 	if (week_view->selection_end_day - week_view->selection_start_day >= 6) {
 983 		start_column = 0;
 984 		n_columns =7;
 985 	} else {
 986 		start_column = week_view->selection_start_day % 7;
 987 		n_columns = (week_view->selection_end_day % 7) - start_column + 1;
 988 	}
 989 	if (n_columns > 0 && start_column != -1 && columns_selected) {
 990 		gint index;
 991 
 992 		*columns_selected = (gint *) g_malloc (n_columns * sizeof (gint));
 993 		for (index = 0; index < n_columns; ++index)
 994 			(*columns_selected)[index] = start_column + index;
 995 	}
 996 	return n_columns;
 997 }
 998 
 999 static gboolean
1000 table_interface_add_row_selection (AtkTable *table,
1001                                    gint row)
1002 {
1003 	AtkGObjectAccessible *atk_gobj;
1004 	GObject *g_obj;
1005 	EWeekViewMainItem *main_item;
1006 	EWeekView *week_view;
1007 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
1008 
1009 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
1010 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
1011 	if (!g_obj)
1012 		return FALSE;
1013 
1014 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
1015 	week_view = e_week_view_main_item_get_week_view (main_item);
1016 
1017 	/* FIXME: we need multi-selection */
1018 
1019 	week_view->selection_start_day = row * 7;
1020 	week_view->selection_end_day = row *7 + 6;
1021 
1022 	gtk_widget_queue_draw (week_view->main_canvas);
1023 	return TRUE;
1024 }
1025 
1026 static gboolean
1027 table_interface_remove_row_selection (AtkTable *table,
1028                                       gint row)
1029 {
1030 	return FALSE;
1031 }
1032 
1033 static gboolean
1034 table_interface_add_column_selection (AtkTable *table,
1035                                       gint column)
1036 {
1037 	AtkGObjectAccessible *atk_gobj;
1038 	GObject *g_obj;
1039 	EWeekViewMainItem *main_item;
1040 	EWeekView *week_view;
1041 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
1042 
1043 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
1044 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
1045 	if (!g_obj)
1046 		return FALSE;
1047 
1048 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
1049 	week_view = e_week_view_main_item_get_week_view (main_item);
1050 
1051 	/* FIXME: we need multi-selection */
1052 
1053 	week_view->selection_start_day = column;
1054 	week_view->selection_end_day = (week_view->weeks_shown - 1) * 7 + column;
1055 
1056 	gtk_widget_queue_draw (week_view->main_canvas);
1057 	return TRUE;
1058 }
1059 
1060 static gboolean
1061 table_interface_remove_column_selection (AtkTable *table,
1062                                          gint column)
1063 {
1064 	/* FIXME: NOT IMPLEMENTED */
1065 	return FALSE;
1066 }
1067 
1068 static AtkObject *
1069 table_interface_get_row_header (AtkTable *table,
1070                                 gint row)
1071 {
1072 	/* FIXME: NOT IMPLEMENTED */
1073 	return NULL;
1074 }
1075 
1076 static AtkObject *
1077 table_interface_get_column_header (AtkTable *table,
1078                                    gint in_col)
1079 {
1080 	/* FIXME: NOT IMPLEMENTED */
1081 	return NULL;
1082 }
1083 
1084 static AtkObject *
1085 table_interface_get_caption (AtkTable *table)
1086 {
1087 	/* FIXME: NOT IMPLEMENTED */
1088 	return NULL;
1089 }
1090 
1091 static const gchar *
1092 table_interface_get_column_description (AtkTable *table,
1093                                         gint in_col)
1094 {
1095 	AtkGObjectAccessible *atk_gobj;
1096 	GObject *g_obj;
1097 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
1098 	const gchar *description;
1099 	EaCellTable *cell_data;
1100 
1101 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
1102 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
1103 	if (!g_obj)
1104 		return NULL;
1105 
1106 	if (in_col < 0 || in_col > 6)
1107 		return NULL;
1108 	cell_data = ea_week_view_main_item_get_cell_data (ea_main_item);
1109 	if (!cell_data)
1110 		return NULL;
1111 
1112 	description = ea_cell_table_get_column_label (cell_data, in_col);
1113 	if (!description) {
1114 		gchar buffer[128];
1115 
1116 		switch (in_col) {
1117 		case 0:
1118 			g_snprintf (buffer,128,"Monday");
1119 			break;
1120 		case 1:
1121 			g_snprintf (buffer,128,"Tuesday");
1122 			break;
1123 		case 2:
1124 			g_snprintf (buffer,128,"Wednesday");
1125 			break;
1126 		case 3:
1127 			g_snprintf (buffer,128,"Thursday");
1128 			break;
1129 		case 4:
1130 			g_snprintf (buffer,128,"Friday");
1131 			break;
1132 		case 5:
1133 			g_snprintf (buffer,128,"Saturday");
1134 			break;
1135 		case 6:
1136 			g_snprintf (buffer,128,"Sunday");
1137 			break;
1138 		default:
1139 			break;
1140 		}
1141 
1142 		ea_cell_table_set_column_label (cell_data, in_col, buffer);
1143 		description = ea_cell_table_get_column_label (cell_data, in_col);
1144 	}
1145 	return description;
1146 }
1147 
1148 static const gchar *
1149 table_interface_get_row_description (AtkTable *table,
1150                                      gint row)
1151 {
1152 	AtkGObjectAccessible *atk_gobj;
1153 	GObject *g_obj;
1154 	EWeekViewMainItem *main_item;
1155 	EWeekView *week_view;
1156 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table);
1157 	const gchar *description;
1158 	EaCellTable *cell_data;
1159 
1160 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
1161 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
1162 	if (!g_obj)
1163 		return NULL;
1164 
1165 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
1166 	week_view = e_week_view_main_item_get_week_view (main_item);
1167 
1168 	if (row < 0 || row >= week_view->weeks_shown)
1169 		return NULL;
1170 	cell_data = ea_week_view_main_item_get_cell_data (ea_main_item);
1171 	if (!cell_data)
1172 		return NULL;
1173 
1174 	description = ea_cell_table_get_row_label (cell_data, row);
1175 	if (!description) {
1176 		gchar buffer[128];
1177 		ea_week_view_main_item_get_row_label (
1178 			ea_main_item, row, buffer, sizeof (buffer));
1179 		ea_cell_table_set_row_label (cell_data, row, buffer);
1180 		description = ea_cell_table_get_row_label (cell_data, row);
1181 	}
1182 	return description;
1183 }
1184 
1185 static AtkObject *
1186 table_interface_get_summary (AtkTable *table)
1187 {
1188 	/* FIXME: NOT IMPLEMENTED */
1189 	return NULL;
1190 }
1191 
1192 /* atkselection interface */
1193 
1194 static void
1195 atk_selection_interface_init (AtkSelectionIface *iface)
1196 {
1197 	g_return_if_fail (iface != NULL);
1198 
1199 	iface->add_selection = selection_interface_add_selection;
1200 	iface->clear_selection = selection_interface_clear_selection;
1201 	iface->ref_selection = selection_interface_ref_selection;
1202 	iface->get_selection_count = selection_interface_get_selection_count;
1203 	iface->is_child_selected = selection_interface_is_child_selected;
1204 }
1205 
1206 static gboolean
1207 selection_interface_add_selection (AtkSelection *selection,
1208                                    gint i)
1209 {
1210 	AtkGObjectAccessible *atk_gobj;
1211 	GObject *g_obj;
1212 	EWeekViewMainItem *main_item;
1213 	EWeekView *week_view;
1214 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
1215 
1216 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
1217 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
1218 	if (!g_obj)
1219 		return FALSE;
1220 
1221 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
1222 	week_view = e_week_view_main_item_get_week_view (main_item);
1223 
1224 	if (i < 0 || i > week_view->weeks_shown * 7 -1)
1225 		return FALSE;
1226 
1227 	/*FIXME: multi-selection is needed */
1228 	week_view->selection_start_day = i;
1229 	week_view->selection_end_day = i;
1230 
1231 	gtk_widget_queue_draw (week_view->main_canvas);
1232 	return TRUE;
1233 }
1234 
1235 static gboolean
1236 selection_interface_clear_selection (AtkSelection *selection)
1237 {
1238 	AtkGObjectAccessible *atk_gobj;
1239 	GObject *g_obj;
1240 	EWeekViewMainItem *main_item;
1241 	EWeekView *week_view;
1242 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
1243 
1244 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
1245 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
1246 	if (!g_obj)
1247 		return FALSE;
1248 
1249 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
1250 	week_view = e_week_view_main_item_get_week_view (main_item);
1251 
1252 	week_view->selection_start_day = -1;
1253 	week_view->selection_end_day = -1;
1254 
1255 	gtk_widget_queue_draw (week_view->main_canvas);
1256 
1257 	return TRUE;
1258 }
1259 
1260 static AtkObject *
1261 selection_interface_ref_selection (AtkSelection *selection,
1262                                    gint i)
1263 {
1264 	gint count;
1265 	GObject *g_obj;
1266 	EWeekViewMainItem *main_item;
1267 	EWeekView *week_view;
1268 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
1269 	gint start_index;
1270 
1271 	count = selection_interface_get_selection_count (selection);
1272 	if (i < 0 || i >=count)
1273 		return NULL;
1274 
1275 	g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (ea_main_item));
1276 
1277 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
1278 	week_view = e_week_view_main_item_get_week_view (main_item);
1279 
1280 	start_index = ea_week_view_main_item_get_child_index_at (
1281 		ea_main_item,
1282 		week_view->selection_start_day / 7,
1283 		week_view->selection_start_day % 7);
1284 
1285 	return ea_week_view_main_item_ref_child (ATK_OBJECT (selection), start_index + i);
1286 }
1287 
1288 static gint
1289 selection_interface_get_selection_count (AtkSelection *selection)
1290 {
1291 	AtkGObjectAccessible *atk_gobj;
1292 	GObject *g_obj;
1293 	EWeekViewMainItem *main_item;
1294 	EWeekView *week_view;
1295 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
1296 
1297 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
1298 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
1299 	if (!g_obj)
1300 		return 0;
1301 
1302 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
1303 	week_view = e_week_view_main_item_get_week_view (main_item);
1304 
1305 	if (week_view->selection_start_day == -1 ||
1306 	    week_view->selection_end_day == -1)
1307 		return 0;
1308 
1309 	return week_view->selection_end_day - week_view->selection_start_day + 1;
1310 }
1311 
1312 static gboolean
1313 selection_interface_is_child_selected (AtkSelection *selection,
1314                                        gint i)
1315 {
1316 	AtkGObjectAccessible *atk_gobj;
1317 	GObject *g_obj;
1318 	EWeekViewMainItem *main_item;
1319 	EWeekView *week_view;
1320 	EaWeekViewMainItem * ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection);
1321 
1322 	atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item);
1323 	g_obj = atk_gobject_accessible_get_object (atk_gobj);
1324 	if (!g_obj)
1325 		return FALSE;
1326 
1327 	main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj);
1328 	week_view = e_week_view_main_item_get_week_view (main_item);
1329 
1330 	if ((week_view->selection_start_day <= i) && (week_view->selection_end_day >= i))
1331 		return TRUE;
1332 	else
1333 		return FALSE;
1334 }