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

No issues found

Incomplete coverage

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