diff options
author | Milan Crha <mcrha@redhat.com> | 2009-05-20 22:50:00 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-05-20 22:50:00 +0800 |
commit | f4cf9af33ccde3142a3011e8b2dbcfb4cbc9ae81 (patch) | |
tree | 1c0228db536f5fa0efc6e0f779bb86df610989d0 /a11y | |
parent | 3acc45b10c9849aa5385a762b4d139472916dca1 (diff) | |
download | gsoc2013-evolution-f4cf9af33ccde3142a3011e8b2dbcfb4cbc9ae81.tar gsoc2013-evolution-f4cf9af33ccde3142a3011e8b2dbcfb4cbc9ae81.tar.gz gsoc2013-evolution-f4cf9af33ccde3142a3011e8b2dbcfb4cbc9ae81.tar.bz2 gsoc2013-evolution-f4cf9af33ccde3142a3011e8b2dbcfb4cbc9ae81.tar.lz gsoc2013-evolution-f4cf9af33ccde3142a3011e8b2dbcfb4cbc9ae81.tar.xz gsoc2013-evolution-f4cf9af33ccde3142a3011e8b2dbcfb4cbc9ae81.tar.zst gsoc2013-evolution-f4cf9af33ccde3142a3011e8b2dbcfb4cbc9ae81.zip |
Use -no-undefined on Linux too
There still left two things opened, search for KILL-BONOBO to find them.
One is in calendar's Makefile.am, one in composer.
Diffstat (limited to 'a11y')
80 files changed, 0 insertions, 17430 deletions
diff --git a/a11y/Makefile.am b/a11y/Makefile.am index 9fe0b07e3c..772a96937f 100644 --- a/a11y/Makefile.am +++ b/a11y/Makefile.am @@ -1,14 +1,3 @@ -# Somewhat odd looking to have "." in SUBDIRS, but apparently it works? -#SUBDIRS = e-text e-table . calendar widgets addressbook -SUBDIRS = e-text e-table . widgets addressbook - -if OS_WIN32 -WIN32_BOOTSTRAP_LIBS = \ - $(top_builddir)/win32/libemiscwidgets.la \ - $(top_builddir)/win32/libetable.la \ - $(top_builddir)/win32/libetext.la -endif - # for debug #A11Y_CFLAGS += -pedantic -ansi -DACC_DEBUG -Werror @@ -28,9 +17,6 @@ libevolution_a11y_la_SOURCES = \ libevolution_a11y_la_LDFLAGS = $(NO_UNDEFINED) libevolution_a11y_la_LIBADD = \ - $(WIN32_BOOTSTRAP_LIBS) \ - e-text/libgal-a11y-etext.la \ - e-table/libgal-a11y-etable.la \ $(top_builddir)/e-util/libeutil.la \ $(GNOME_PLATFORM_LIBS) diff --git a/a11y/addressbook/Makefile.am b/a11y/addressbook/Makefile.am deleted file mode 100644 index 81092822f4..0000000000 --- a/a11y/addressbook/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -if OS_WIN32 -WIN32_BOOTSTRAP_LIBS = \ - $(top_builddir)/win32/libemiscwidgets.la \ - $(top_builddir)/win32/libevolution-addressbook.la -endif - -privsolib_LTLIBRARIES = libevolution-addressbook-a11y.la - -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-a11y\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/a11y \ - -I$(top_srcdir)/widgets \ - -I$(top_srcdir)/shell \ - -I$(top_srcdir)/addressbook/gui/widgets \ - -DG_DISABLE_DEPRECATED \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -libevolution_addressbook_a11y_la_SOURCES = \ - ea-minicard.c \ - ea-minicard.h \ - ea-minicard-view.c \ - ea-minicard-view.h \ - ea-addressbook-view.c \ - ea-addressbook-view.h \ - ea-addressbook.c \ - ea-addressbook.h - -libevolution_addressbook_a11y_la_LDFLAGS = $(NO_UNDEFINED) - -libevolution_addressbook_a11y_la_LIBADD = \ - $(WIN32_BOOTSTRAP_LIBS) \ - $(EVOLUTION_ADDRESSBOOK_LIBS) - --include $(top_srcdir)/git.mk diff --git a/a11y/addressbook/ea-addressbook-view.c b/a11y/addressbook/ea-addressbook-view.c deleted file mode 100644 index eff7eb4044..0000000000 --- a/a11y/addressbook/ea-addressbook-view.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Leon Zhang <leon.zhang@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <glib/gi18n.h> -#include "ea-addressbook-view.h" - -static G_CONST_RETURN gchar* ea_ab_view_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_ab_view_get_description (AtkObject *accessible); - -static void ea_ab_view_class_init (EAddressbookViewClass *class); - -static gpointer parent_class = NULL; - -GType -ea_ab_view_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EAddressbookViewClass), - (GBaseInitFunc) NULL, /* base_init */ - (GBaseFinalizeFunc) NULL, /* base_finalize */ - (GClassInitFunc) ea_ab_view_class_init, - (GClassFinalizeFunc) NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EAddressbookView), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (GailWidget, in this case) */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - GTK_TYPE_EVENT_BOX); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - type = g_type_register_static (derived_atk_type, - "EaABView", &tinfo, 0); - } - - return type; -} - -static void -ea_ab_view_class_init (EAddressbookViewClass *class) -{ - AtkObjectClass *atk_object_class; - - parent_class = g_type_class_peek_parent (class); - - atk_object_class = ATK_OBJECT_CLASS (class); - atk_object_class->get_name = ea_ab_view_get_name; - atk_object_class->get_description = ea_ab_view_get_description; -} - -static G_CONST_RETURN gchar* -ea_ab_view_get_name (AtkObject *accessible) -{ - g_return_val_if_fail (EA_IS_AB_VIEW(accessible), NULL); - if (accessible->name) - return accessible->name; - - return _("evolution address book"); -} - -static G_CONST_RETURN gchar* -ea_ab_view_get_description (AtkObject *accessible) -{ - if (accessible->description) - return accessible->description; - - return _("evolution address book"); -} - -AtkObject* -ea_ab_view_new (GObject *obj) -{ - GObject *object; - AtkObject *accessible; - - g_return_val_if_fail(obj != NULL, NULL); - g_return_val_if_fail (E_IS_ADDRESSBOOK_VIEW(obj), NULL); - - object = g_object_new (EA_TYPE_AB_VIEW, NULL); - - accessible = ATK_OBJECT (object); - atk_object_initialize (accessible, obj); - accessible->role = ATK_ROLE_CANVAS; - - return accessible; -} diff --git a/a11y/addressbook/ea-addressbook-view.h b/a11y/addressbook/ea-addressbook-view.h deleted file mode 100644 index 86782ad737..0000000000 --- a/a11y/addressbook/ea-addressbook-view.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Leon Zhang <leon.zhang@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_ADDRESSBOOK_VIEW_H__ -#define __EA_ADDRESSBOOK_VIEW_H__ - -#include <gtk/gtk.h> -#include "e-addressbook-view.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define EA_TYPE_AB_VIEW (ea_ab_view_get_type ()) -#define EA_AB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_AB_VIEW, EaABView)) -#define EA_AB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_AB_VIEW, EaABViewClass)) -#define EA_IS_AB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_AB_VIEW)) -#define EA_IS_AB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EA_TYPE_AB_VIEW)) - -typedef struct _EaABView EaABView; -typedef struct _EaABViewClass EaABViewClass; - -struct _EaABView -{ - GtkAccessible parent; -}; - - -struct _EaABViewClass -{ - GtkAccessibleClass parent_class; -}; - -GType ea_ab_view_get_type (void); -AtkObject* ea_ab_view_new(GObject *obj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __EA_ADDRESSBOOK_VIEW_H__ */ diff --git a/a11y/addressbook/ea-addressbook.c b/a11y/addressbook/ea-addressbook.c deleted file mode 100644 index e94309de43..0000000000 --- a/a11y/addressbook/ea-addressbook.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Leon Zhang <leon.zhang@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <text/e-text.h> -#include "ea-factory.h" -#include "ea-addressbook.h" -#include "ea-minicard.h" -#include "ea-minicard-view.h" -#include "ea-addressbook-view.h" - -EA_FACTORY_GOBJECT (EA_TYPE_MINICARD, ea_minicard, ea_minicard_new) -EA_FACTORY_GOBJECT (EA_TYPE_MINICARD_VIEW, ea_minicard_view, ea_minicard_view_new) -EA_FACTORY_GOBJECT (EA_TYPE_AB_VIEW, ea_ab_view, ea_ab_view_new) - -static gboolean ea_addressbook_focus_watcher (GSignalInvocationHint *ihint, - guint n_param_values, - const GValue *param_values, - gpointer data); - -void e_minicard_a11y_init (void) -{ - EA_SET_FACTORY (e_minicard_get_type (), ea_minicard); -} - -void e_minicard_view_a11y_init (void) -{ - EA_SET_FACTORY (e_minicard_view_get_type (), ea_minicard_view); - - if (atk_get_root ()) { - g_signal_add_emission_hook (g_signal_lookup ("event", - e_minicard_get_type()), - 0, ea_addressbook_focus_watcher, - NULL, (GDestroyNotify) NULL); - } -} - -void eab_view_a11y_init (void) -{ - EA_SET_FACTORY (E_TYPE_ADDRESSBOOK_VIEW, ea_ab_view); -} - -static gboolean -ea_addressbook_focus_watcher (GSignalInvocationHint *ihint, - guint n_param_values, - const GValue *param_values, - gpointer data) -{ - GObject *object; - GdkEvent *event; - AtkObject *ea_event = NULL; - - object = g_value_get_object (param_values + 0); - event = g_value_get_boxed (param_values + 1); - - if (E_IS_MINICARD (object)) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (object); - ea_event = atk_gobject_accessible_for_object (object); - if (event->type == GDK_FOCUS_CHANGE) { - if ((event->focus_change.in) && (E_IS_MINICARD (item->canvas->focused_item))) - atk_focus_tracker_notify (ea_event); - } - } - - return TRUE; -} diff --git a/a11y/addressbook/ea-addressbook.h b/a11y/addressbook/ea-addressbook.h deleted file mode 100644 index 337f467760..0000000000 --- a/a11y/addressbook/ea-addressbook.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Leon Zhang <leon.zhang@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -/* Evolution Accessibility -*/ - -#ifndef _EA_ADDRESSBOOK_H__ -#define _EA_ADDRESSBOOK_H__ - -void eab_view_a11y_init (void); -void e_minicard_view_a11y_init (void); -void e_minicard_a11y_init (void); - -#endif /* _EA_ADDRESSBOOK_H__ */ diff --git a/a11y/addressbook/ea-minicard-view.c b/a11y/addressbook/ea-minicard-view.c deleted file mode 100644 index aed11ed2ac..0000000000 --- a/a11y/addressbook/ea-minicard-view.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Leon Zhang < leon.zhang@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> -#include <string.h> -#include <gtk/gtk.h> -#include <glib/gi18n.h> -#include "ea-minicard.h" -#include "ea-minicard-view.h" -#include "eab-gui-util.h" -#include "e-addressbook-view.h" - -static const char * action_name[] = { - N_("New Contact"), - N_("New Contact List") -}; - - -static G_CONST_RETURN gchar* ea_minicard_view_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_minicard_view_get_description (AtkObject *accessible); - -static void ea_minicard_view_class_init (EaMinicardViewClass *klass); - -static gint ea_minicard_view_get_n_children (AtkObject *obj); -static AtkObject *ea_minicard_view_ref_child (AtkObject *obj, gint i); - -static AtkStateSet *ea_minicard_view_ref_state_set(AtkObject *obj); - -static void atk_selection_interface_init (AtkSelectionIface *iface); -static gboolean selection_interface_add_selection (AtkSelection *selection, - gint i); -static gboolean selection_interface_clear_selection (AtkSelection *selection); -static AtkObject* selection_interface_ref_selection (AtkSelection *selection, - gint i); -static gint selection_interface_get_selection_count (AtkSelection *selection); -static gboolean selection_interface_is_child_selected (AtkSelection *selection, - gint i); - -static void atk_action_interface_init (AtkActionIface *iface); -static gboolean atk_action_interface_do_action (AtkAction *iface, gint i); -static gint atk_action_interface_get_n_action (AtkAction *iface); -static G_CONST_RETURN gchar* atk_action_interface_get_description (AtkAction *iface, gint i); -static G_CONST_RETURN gchar* atk_action_interface_get_name (AtkAction *iface, gint i); - -static gpointer parent_class = NULL; - -GType -ea_minicard_view_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaMinicardViewClass), - (GBaseInitFunc) NULL, /* base_init */ - (GBaseFinalizeFunc) NULL, /* base_finalize */ - (GClassInitFunc) ea_minicard_view_class_init, - (GClassFinalizeFunc) NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EaMinicardView), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - static const GInterfaceInfo atk_selection_info = { - (GInterfaceInitFunc) atk_selection_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - static const GInterfaceInfo atk_action_info = { - (GInterfaceInitFunc) atk_action_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (GailWidget, in this case) */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - GNOME_TYPE_CANVAS_GROUP); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - type = g_type_register_static (derived_atk_type, - "EaMinicardView", &tinfo, 0); - g_type_add_interface_static (type, ATK_TYPE_SELECTION, - &atk_selection_info); - g_type_add_interface_static (type, ATK_TYPE_ACTION, - &atk_action_info); - - } - - return type; -} - -static void -ea_minicard_view_class_init (EaMinicardViewClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_minicard_view_get_name; - class->get_description = ea_minicard_view_get_description; - class->ref_state_set = ea_minicard_view_ref_state_set; - class->get_n_children = ea_minicard_view_get_n_children; - class->ref_child = ea_minicard_view_ref_child; -} - -static G_CONST_RETURN gchar* -ea_minicard_view_get_name (AtkObject *accessible) -{ - EReflow *reflow; - gchar *string; - EMinicardView *card_view; - EBook *book = NULL; - const gchar *source_name; - - g_return_val_if_fail (EA_IS_MINICARD_VIEW (accessible), NULL); - - reflow = E_REFLOW(atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); - - if (!reflow) - return NULL; - - /* Get the current name of minicard view*/ - card_view = E_MINICARD_VIEW (reflow); - g_object_get (card_view->adapter, "book", &book, NULL); - g_return_val_if_fail (E_IS_BOOK (book), NULL); - source_name = e_source_peek_name (e_book_get_source (book)); - if (!source_name) - source_name=""; - - string = g_strdup_printf (ngettext ("current address book folder %s has %d card", - "current address book folder %s has %d cards", - reflow->count), source_name, reflow->count); - - ATK_OBJECT_CLASS (parent_class)->set_name (accessible, string); - g_free (string); - g_object_unref(book); - return accessible->name; -} - -static G_CONST_RETURN gchar* -ea_minicard_view_get_description (AtkObject *accessible) -{ - g_return_val_if_fail (EA_IS_MINICARD_VIEW(accessible), NULL); - if (accessible->description) - return accessible->description; - - return _("evolution address book"); -} - -AtkObject* -ea_minicard_view_new (GObject *obj) -{ - GObject *object; - AtkObject *accessible; - - g_return_val_if_fail (E_IS_MINICARD_VIEW(obj), NULL); - object = g_object_new (EA_TYPE_MINICARD_VIEW, NULL); - accessible = ATK_OBJECT (object); - atk_object_initialize (accessible, obj); - accessible->role = ATK_ROLE_PANEL; - return accessible; -} - -static gint -ea_minicard_view_get_n_children (AtkObject *accessible) -{ - EReflow *reflow; - - gint child_num = 0; - - g_return_val_if_fail (EA_IS_MINICARD_VIEW (accessible), -1); - - reflow = E_REFLOW (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible))); - - if (!reflow) - return -1; - - child_num = reflow->count; - - return child_num; -} - -static AtkStateSet *ea_minicard_view_ref_state_set (AtkObject *obj) -{ - AtkStateSet *state_set = NULL; - GObject *gobj = NULL; - - state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj); - if( !state_set ) - state_set = atk_state_set_new (); - - gobj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (obj)); - if( !gobj ) - return state_set; - - atk_state_set_add_state (state_set, ATK_STATE_ENABLED); - atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE); - atk_state_set_add_state (state_set, ATK_STATE_SHOWING); - - return state_set; -} - -static AtkObject * -ea_minicard_view_ref_child (AtkObject *accessible, gint index) -{ - EReflow *reflow; - gint child_num; - AtkObject *atk_object = NULL; - EMinicard *card = NULL; - - g_return_val_if_fail (EA_IS_MINICARD_VIEW (accessible), NULL); - - child_num = atk_object_get_n_accessible_children (accessible); - if (child_num <= 0 || index < 0 || index >= child_num) - return NULL; - - reflow = E_REFLOW (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); - if (!reflow) - return NULL; - if (!reflow->items ) - return NULL; - /* a minicard */ - if (index < child_num) { - card = E_MINICARD (reflow->items[index]); - atk_object = atk_gobject_accessible_for_object (G_OBJECT (card)); - } else { - return NULL; - } - - g_object_ref (atk_object); - return atk_object; -} - -/* atkselection interface */ - -static void -atk_selection_interface_init (AtkSelectionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->add_selection = selection_interface_add_selection; - iface->clear_selection = selection_interface_clear_selection; - iface->ref_selection = selection_interface_ref_selection; - iface->get_selection_count = selection_interface_get_selection_count; - iface->is_child_selected = selection_interface_is_child_selected; -} - -static gboolean -selection_interface_add_selection (AtkSelection *selection, gint i) -{ - AtkGObjectAccessible *atk_gobj= NULL; - EReflow *reflow = NULL; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (selection); - reflow = E_REFLOW (atk_gobject_accessible_get_object (atk_gobj)); - - if (!reflow) - return FALSE; - - selection_interface_clear_selection (selection); - e_selection_model_select_single_row (reflow->selection, i); - - return TRUE; -} - -static gboolean -selection_interface_clear_selection (AtkSelection *selection) -{ - AtkGObjectAccessible *atk_gobj = NULL; - EReflow *reflow = NULL; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (selection); - reflow = E_REFLOW(atk_gobject_accessible_get_object (atk_gobj)); - - if( !reflow ) - return FALSE; - - e_selection_model_clear (reflow->selection); - - return TRUE; -} - -static AtkObject* -selection_interface_ref_selection (AtkSelection *selection, gint i) -{ - return ea_minicard_view_ref_child (ATK_OBJECT (selection), i); -} - -static gint -selection_interface_get_selection_count (AtkSelection *selection) -{ - AtkGObjectAccessible *atk_gobj = NULL; - EReflow *reflow = NULL; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (selection); - reflow = E_REFLOW (atk_gobject_accessible_get_object (atk_gobj)); - - if (!reflow ) - return FALSE; - - return e_selection_model_selected_count (reflow->selection); -} - -static gboolean -selection_interface_is_child_selected (AtkSelection *selection, gint i) -{ - AtkGObjectAccessible *atk_gobj = NULL; - EReflow *reflow = NULL; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (selection); - reflow = E_REFLOW(atk_gobject_accessible_get_object (atk_gobj)); - - if( !reflow ) - return FALSE; - - return e_selection_model_is_row_selected (reflow->selection, i); -} - -static void atk_action_interface_init (AtkActionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->do_action = atk_action_interface_do_action; - iface->get_n_actions = atk_action_interface_get_n_action; - iface->get_description = atk_action_interface_get_description; - iface->get_name = atk_action_interface_get_name; -} - -static gboolean atk_action_interface_do_action (AtkAction *action, gint i) -{ - gboolean return_value = TRUE; - EMinicardView *card_view; - - AtkGObjectAccessible *atk_gobj= NULL; - EReflow *reflow = NULL; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (action); - reflow = E_REFLOW (atk_gobject_accessible_get_object (atk_gobj)); - - if (reflow == NULL) - return FALSE; - - card_view = E_MINICARD_VIEW (reflow); - - switch (i) { - case 0: - /* New Contact */ - e_minicard_view_create_contact (card_view); - break; - case 1: - /* New Contact List */ - e_minicard_view_create_contact_list (card_view); - break; - default: - return_value = FALSE; - break; - } - - return return_value; -} - -static gint atk_action_interface_get_n_action (AtkAction *iface) -{ - return G_N_ELEMENTS (action_name); -} - -static G_CONST_RETURN gchar* -atk_action_interface_get_description (AtkAction *iface, gint i) -{ - return atk_action_interface_get_name (iface, i); -} - -static G_CONST_RETURN gchar* -atk_action_interface_get_name (AtkAction *iface, gint i) -{ - if( i >= G_N_ELEMENTS (action_name) || i < 0) - return NULL; - - return action_name[i]; -} - diff --git a/a11y/addressbook/ea-minicard-view.h b/a11y/addressbook/ea-minicard-view.h deleted file mode 100644 index 922941cb7b..0000000000 --- a/a11y/addressbook/ea-minicard-view.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Leon Zhang <leon.zhang@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_MINICARD_VIEW_H__ -#define __EA_MINICARD_VIEW_H__ - -#include <atk/atkgobjectaccessible.h> -#include "e-minicard-view.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define EA_TYPE_MINICARD_VIEW (ea_minicard_view_get_type ()) -#define EA_MINICARD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_MINICARD_VIEW, EaMinicardView)) -#define EA_MINICARD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_MINICARD_VIEW, EaMiniCardViewClass)) -#define EA_IS_MINICARD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_MINICARD_VIEW)) -#define EA_IS_MINICARD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EA_TYPE_MINICARD_VIEW)) - - -typedef struct _EaMinicardView EaMinicardView; -typedef struct _EaMinicardViewClass EaMinicardViewClass; - -struct _EaMinicardView -{ - AtkGObjectAccessible parent; -}; - - -struct _EaMinicardViewClass -{ - AtkGObjectAccessibleClass parent_class; -}; - -GType ea_minicard_view_get_type (void); - -AtkObject* ea_minicard_view_new(GObject *obj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __EA_MINICARD_VIEW_H__ */ diff --git a/a11y/addressbook/ea-minicard.c b/a11y/addressbook/ea-minicard.c deleted file mode 100644 index d0219e03b5..0000000000 --- a/a11y/addressbook/ea-minicard.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Leon Zhang <leon.zhang@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> -#include <string.h> -#include <glib/gi18n.h> -#include "ea-minicard.h" -#include "ea-minicard-view.h" -#include "e-minicard.h" - -static const char * action_name[] = { - N_("Open") -}; - -static G_CONST_RETURN gchar* ea_minicard_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_minicard_get_description (AtkObject *accessible); - -static void ea_minicard_class_init (EaMinicardClass *klass); - -static gint ea_minicard_get_n_children (AtkObject *obj); -static AtkObject* ea_minicard_ref_child(AtkObject *obj, gint i); - -static AtkStateSet *ea_minicard_ref_state_set (AtkObject *obj); - -static void atk_action_interface_init (AtkActionIface *iface); -static gboolean atk_action_interface_do_action (AtkAction *iface, gint i); -static gint atk_action_interface_get_n_action (AtkAction *iface); -static G_CONST_RETURN gchar* atk_action_interface_get_description (AtkAction *iface, gint i); -static G_CONST_RETURN gchar* atk_action_interface_get_name (AtkAction *iface, gint i); - -static gpointer parent_class = NULL; - -GType -ea_minicard_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaMinicardClass), - (GBaseInitFunc) NULL, /* base_init */ - (GBaseFinalizeFunc) NULL, /* base_finalize */ - (GClassInitFunc) ea_minicard_class_init, - (GClassFinalizeFunc) NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EaMinicard), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - static const GInterfaceInfo atk_action_info = { - (GInterfaceInitFunc) atk_action_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (GailWidget, in this case) - */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - GNOME_TYPE_CANVAS_GROUP); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - type = g_type_register_static ( derived_atk_type, - "EaMinicard", &tinfo, 0); - g_type_add_interface_static (type, ATK_TYPE_ACTION, - &atk_action_info); - } - - return type; -} - -static void -ea_minicard_class_init (EaMinicardClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_minicard_get_name; - class->get_description = ea_minicard_get_description; - class->ref_state_set = ea_minicard_ref_state_set; - class->get_n_children = ea_minicard_get_n_children; - class->ref_child = ea_minicard_ref_child; -} - -/* - * we access the main content of current minicard, including - * header text, label(field, field name) - */ -static G_CONST_RETURN gchar* -ea_minicard_get_name (AtkObject *accessible) -{ -#define BUFFERSIZE 500 - - static gchar name[BUFFERSIZE]; - GString *new_str = g_string_new (NULL); - gchar *string; - EMinicard *card; - - g_return_val_if_fail (EA_IS_MINICARD(accessible), NULL); - memset (name, '\0', BUFFERSIZE); - - card = E_MINICARD(atk_gobject_accessible_get_object - (ATK_GOBJECT_ACCESSIBLE(accessible))); - if (!card) - return NULL; - - g_object_get (card->header_text, "text", &string, NULL); - - if (e_contact_get (card->contact, E_CONTACT_IS_LIST)) - g_string_append (new_str, _("Contact List: ")); - else g_string_append (new_str, _("Contact: ")); - - /* get header of current card */ - g_string_append (new_str, string); - g_free (string); - - /* if there exist no enough space for remain info, return */ - if (new_str->len >= BUFFERSIZE) { - strncpy (name, new_str->str, BUFFERSIZE); - return name; - } - - strcpy (name, new_str->str); - g_string_free (new_str, TRUE); - - ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name); - - return accessible->name; -} - -static G_CONST_RETURN gchar* -ea_minicard_get_description (AtkObject *accessible) -{ - if (accessible->description) - return accessible->description; - - return _("evolution minicard"); -} - -AtkObject* -ea_minicard_new (GObject *obj) -{ - GObject *object; - AtkObject *accessible; - - g_return_val_if_fail(obj != NULL, NULL); - g_return_val_if_fail (E_IS_MINICARD(obj), NULL); - - object = g_object_new (EA_TYPE_MINICARD, NULL); - accessible = ATK_OBJECT (object); - atk_object_initialize (accessible, obj); - - accessible->role = ATK_ROLE_PANEL; - return accessible; -} - -static AtkStateSet *ea_minicard_ref_state_set (AtkObject *obj) -{ - AtkStateSet *state_set = NULL; - GObject *gobj = NULL; - - state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj); - if( !state_set ) - state_set = atk_state_set_new (); - - gobj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (obj)); - if( !gobj ) - return state_set; - - atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE); - atk_state_set_add_state (state_set, ATK_STATE_ENABLED); - atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE); - atk_state_set_add_state (state_set, ATK_STATE_SHOWING); - - return state_set; -} - -static gint -ea_minicard_get_n_children (AtkObject *accessible) -{ - return 0; -} - -static AtkObject * -ea_minicard_ref_child (AtkObject *accessible, gint index) -{ - return NULL; -} - -static void atk_action_interface_init (AtkActionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->do_action = atk_action_interface_do_action; - iface->get_n_actions = atk_action_interface_get_n_action; - iface->get_description = atk_action_interface_get_description; - iface->get_name = atk_action_interface_get_name; -} - -static gboolean atk_action_interface_do_action (AtkAction *iface, gint i) -{ - EMinicard *minicard = NULL; - - minicard = E_MINICARD (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (iface))); - if( minicard == NULL ) - return FALSE; - - if( i >= G_N_ELEMENTS (action_name) || i < 0 ) - return FALSE; - - switch (i) { - // open card - case 0: - e_minicard_activate_editor (minicard); - break; - default: - return FALSE; - } - - return TRUE; -} - -static gint atk_action_interface_get_n_action (AtkAction *iface) -{ - return G_N_ELEMENTS (action_name); -} - -static G_CONST_RETURN gchar* -atk_action_interface_get_description (AtkAction *iface, gint i) -{ - return atk_action_interface_get_name (iface, i); -} - -static G_CONST_RETURN gchar* -atk_action_interface_get_name (AtkAction *iface, gint i) -{ - if( i >= G_N_ELEMENTS (action_name) || i < 0) - return NULL; - - return action_name[i]; -} - diff --git a/a11y/addressbook/ea-minicard.h b/a11y/addressbook/ea-minicard.h deleted file mode 100644 index 9c0c8a2b56..0000000000 --- a/a11y/addressbook/ea-minicard.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Leon Zhang <leon.zhang@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_MINICARD_H__ -#define __EA_MINICARD_H__ - -#include <atk/atkgobjectaccessible.h> -#include "e-minicard.h" -#include "e-minicard-label.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define EA_TYPE_MINICARD (ea_minicard_get_type ()) -#define EA_MINICARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_MINICARD, EaMinicard)) -#define EA_MINICARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_MINICARD, EaMiniCardClass)) -#define EA_IS_MINICARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_MINICARD)) -#define EA_IS_MINICARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EA_TYPE_MINICARD)) - -typedef struct _EaMinicard EaMinicard; -typedef struct _EaMinicardClass EaMinicardClass; - -struct _EaMinicard -{ - AtkGObjectAccessible parent; -}; - - -struct _EaMinicardClass -{ - AtkGObjectAccessibleClass parent_class; -}; - -GType ea_minicard_get_type (void); -AtkObject* ea_minicard_new(GObject *obj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __EA_MINICARD_H__ */ diff --git a/a11y/calendar/Makefile.am b/a11y/calendar/Makefile.am deleted file mode 100644 index 1bd53787c9..0000000000 --- a/a11y/calendar/Makefile.am +++ /dev/null @@ -1,56 +0,0 @@ -# Calendar IDL files - -# for debug -#A11Y_CFLAGS += -pedantic -ansi -DACC_DEBUG -Werror - -if OS_WIN32 -WIN32_BOOTSTRAP_LIBS = \ - $(top_builddir)/win32/libetext.la \ - $(top_builddir)/win32/libevolution-calendar.la -endif - -privsolib_LTLIBRARIES = libevolution-calendar-a11y.la - -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-a11y\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar/gui \ - -I$(top_srcdir)/widgets \ - -I$(top_srcdir)/widgets/misc \ - -I$(top_srcdir)/a11y \ - $(EVOLUTION_CALENDAR_CFLAGS) - -libevolution_calendar_a11y_la_SOURCES = \ - ea-calendar.c \ - ea-calendar.h \ - ea-calendar-helpers.c \ - ea-calendar-helpers.h \ - ea-cal-view.c \ - ea-cal-view.h \ - ea-cal-view-event.c \ - ea-cal-view-event.h \ - ea-day-view.c \ - ea-day-view.h \ - ea-day-view-main-item.c \ - ea-day-view-main-item.h \ - ea-day-view-cell.c \ - ea-day-view-cell.h \ - ea-week-view.c \ - ea-week-view.h \ - ea-week-view-main-item.c \ - ea-week-view-main-item.h \ - ea-week-view-cell.c \ - ea-week-view-cell.h \ - ea-jump-button.c \ - ea-jump-button.h \ - ea-gnome-calendar.c \ - ea-gnome-calendar.h - -libevolution_calendar_a11y_la_LDFLAGS = $(NO_UNDEFINED) - -libevolution_calendar_a11y_la_LIBADD = \ - $(WIN32_BOOTSTRAP_LIBS) \ - $(top_builddir)/a11y/libevolution-a11y.la \ - $(EVOLUTION_CALENDAR_LIBS) - --include $(top_srcdir)/git.mk diff --git a/a11y/calendar/ea-cal-view-event.c b/a11y/calendar/ea-cal-view-event.c deleted file mode 100644 index 49cf525511..0000000000 --- a/a11y/calendar/ea-cal-view-event.c +++ /dev/null @@ -1,570 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-cal-view-event.h" -#include "ea-calendar-helpers.h" -#include "ea-day-view.h" -#include "ea-week-view.h" -#include <text/e-text.h> -#include <glib/gi18n.h> - -static void ea_cal_view_event_class_init (EaCalViewEventClass *klass); -static void ea_cal_view_event_init (EaCalViewEvent *a11y); - -static void ea_cal_view_event_dispose (GObject *object); -static G_CONST_RETURN gchar* ea_cal_view_event_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_cal_view_event_get_description (AtkObject *accessible); -static AtkObject* ea_cal_view_event_get_parent (AtkObject *accessible); -static gint ea_cal_view_event_get_index_in_parent (AtkObject *accessible); -static AtkStateSet *ea_cal_view_event_ref_state_set (AtkObject *accessible); - -/* component interface */ -static void atk_component_interface_init (AtkComponentIface *iface); -static void ea_cal_view_get_extents (AtkComponent *component, - gint *x, gint *y, gint *width, gint *height, - AtkCoordType coord_type); -/* action interface */ -static void atk_action_interface_init (AtkActionIface *iface); -static gboolean ea_cal_view_event_do_action (AtkAction *action, gint i); -static gint ea_cal_view_event_get_n_actions (AtkAction *action); -static G_CONST_RETURN gchar* ea_cal_view_event_action_get_name (AtkAction *action, gint i); - - -#ifdef ACC_DEBUG -static gint n_ea_cal_view_event_created = 0, n_ea_cal_view_event_destroyed = 0; -static void ea_cal_view_finalize (GObject *object); -#endif - -static gpointer parent_class = NULL; - -GType -ea_cal_view_event_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaCalViewEventClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_cal_view_event_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaCalViewEvent), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) ea_cal_view_event_init, /* instance init */ - NULL /* value table */ - }; - - static const GInterfaceInfo atk_component_info = { - (GInterfaceInitFunc) atk_component_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - static const GInterfaceInfo atk_action_info = { - (GInterfaceInitFunc) atk_action_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (atk object for E_TEXT, in this case) - */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - E_TYPE_TEXT); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - /* we inherit the component, text and other interfaces from E_TEXT */ - type = g_type_register_static (derived_atk_type, - "EaCalViewEvent", &tinfo, 0); - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, - &atk_component_info); - g_type_add_interface_static (type, ATK_TYPE_ACTION, - &atk_action_info); - - - } - - return type; -} - -static void -ea_cal_view_event_class_init (EaCalViewEventClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); -#ifdef ACC_DEBUG - gobject_class->finalize = ea_cal_view_finalize; -#endif - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->dispose = ea_cal_view_event_dispose; - - class->get_name = ea_cal_view_event_get_name; - class->get_description = ea_cal_view_event_get_description; - class->get_parent = ea_cal_view_event_get_parent; - class->get_index_in_parent = ea_cal_view_event_get_index_in_parent; - class->ref_state_set = ea_cal_view_event_ref_state_set; - -} - -static void -ea_cal_view_event_init (EaCalViewEvent *a11y) -{ - a11y->state_set = atk_state_set_new (); - atk_state_set_add_state (a11y->state_set, ATK_STATE_TRANSIENT); - atk_state_set_add_state (a11y->state_set, ATK_STATE_ENABLED); - atk_state_set_add_state (a11y->state_set, ATK_STATE_SENSITIVE); - atk_state_set_add_state (a11y->state_set, ATK_STATE_SELECTABLE); - atk_state_set_add_state (a11y->state_set, ATK_STATE_SHOWING); - atk_state_set_add_state (a11y->state_set, ATK_STATE_FOCUSABLE); -} - -#ifdef ACC_DEBUG -static void ea_cal_view_finalize (GObject *object) -{ - G_OBJECT_CLASS (parent_class)->finalize (object); - - ++n_ea_cal_view_event_destroyed; - printf ("ACC_DEBUG: n_ea_cal_view_event_destroyed = %d\n", - n_ea_cal_view_event_destroyed); -} -#endif - -AtkObject* -ea_cal_view_event_new (GObject *obj) -{ - AtkObject *atk_obj = NULL; - GObject *target_obj; - ECalendarView *cal_view; - - g_return_val_if_fail (E_IS_TEXT (obj), NULL); - cal_view = ea_calendar_helpers_get_cal_view_from (GNOME_CANVAS_ITEM (obj)); - if (!cal_view) - return NULL; - - if (E_IS_WEEK_VIEW (cal_view)) { - gint event_num, span_num; - EWeekViewEvent *week_view_event; - EWeekViewEventSpan *event_span; - EWeekView *week_view = E_WEEK_VIEW (cal_view); - - /* for week view, we need to check if a atkobject exists for - * the first span of the same event - */ - if (!e_week_view_find_event_from_item (week_view, - GNOME_CANVAS_ITEM (obj), - &event_num, - &span_num)) - return NULL; - week_view_event = &g_array_index (week_view->events, - EWeekViewEvent, - event_num); - /* get the first span */ - event_span = &g_array_index (week_view->spans, - EWeekViewEventSpan, - week_view_event->spans_index); - target_obj = G_OBJECT (event_span->text_item); - atk_obj = g_object_get_data (target_obj, "accessible-object"); - - } - else - target_obj = obj; - - if (!atk_obj) { - static AtkRole event_role = ATK_ROLE_INVALID; - atk_obj = ATK_OBJECT (g_object_new (EA_TYPE_CAL_VIEW_EVENT, - NULL)); - atk_object_initialize (atk_obj, target_obj); - if (event_role == ATK_ROLE_INVALID) - event_role = atk_role_register ("Calendar Event"); - atk_obj->role = event_role; -#ifdef ACC_DEBUG - ++n_ea_cal_view_event_created; - printf ("ACC_DEBUG: n_ea_cal_view_event_created = %d\n", - n_ea_cal_view_event_created); -#endif - } - - /* the registered factory for E_TEXT is cannot create a EaCalViewEvent, - * we should save the EaCalViewEvent object in it. - */ - g_object_set_data (obj, "accessible-object", atk_obj); - - return atk_obj; -} - -static void -ea_cal_view_event_dispose (GObject *object) -{ - EaCalViewEvent *a11y = EA_CAL_VIEW_EVENT (object); - - if (a11y->state_set) { - g_object_unref (a11y->state_set); - a11y->state_set = NULL; - } - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose (object); -} - -static G_CONST_RETURN gchar* -ea_cal_view_event_get_name (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - ECalendarViewEvent *event; - gchar *name_string; - gchar *alarm_string, *recur_string, *meeting_string, *summary_string; - const char *summary; - - - g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj || !E_IS_TEXT (g_obj)) - return NULL; - event = ea_calendar_helpers_get_cal_view_event_from (GNOME_CANVAS_ITEM(g_obj)); - - alarm_string = recur_string = meeting_string = ""; - if (event && event->comp_data) { - if (e_cal_util_component_has_alarms (event->comp_data->icalcomp)) - alarm_string = _("It has alarms."); - - if (e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) - recur_string = _("It has recurrences."); - - if (e_cal_util_component_has_organizer (event->comp_data->icalcomp)) - meeting_string = _("It is a meeting."); - - } - - summary = icalcomponent_get_summary (event->comp_data->icalcomp); - if (summary) - summary_string = g_strdup_printf (_("Calendar Event: Summary is %s."), summary); - else - summary_string = g_strdup (_("Calendar Event: It has no summary.")); - - name_string = g_strdup_printf ("%s %s %s %s", summary_string, alarm_string, recur_string, meeting_string); - g_free (summary_string); - - ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name_string); -#ifdef ACC_DEBUG - printf("EvoAcc: name for event accobj=%p, is %s\n", - (void *)accessible, new_name); -#endif - g_free (name_string); - return accessible->name; -} - -static G_CONST_RETURN gchar* -ea_cal_view_event_get_description (AtkObject *accessible) -{ - if (accessible->description) - return accessible->description; - - return _("calendar view event"); -} - -static AtkObject * -ea_cal_view_event_get_parent (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - GnomeCanvasItem *canvas_item; - ECalendarView *cal_view; - - g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), NULL); - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (g_obj == NULL) - /* Object is defunct */ - return NULL; - canvas_item = GNOME_CANVAS_ITEM (g_obj); - - cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item); - - if (!cal_view) - return NULL; - - return gtk_widget_get_accessible (GTK_WIDGET (cal_view)); -} - -static gint -ea_cal_view_event_get_index_in_parent (AtkObject *accessible) -{ - GObject *g_obj; - GnomeCanvasItem *canvas_item; - ECalendarView *cal_view; - ECalendarViewEvent *cal_view_event; - - g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), -1); - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible)); - if (!g_obj) - /* defunct object*/ - return -1; - - canvas_item = GNOME_CANVAS_ITEM (g_obj); - cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item); - if (!cal_view) - return -1; - - cal_view_event = ea_calendar_helpers_get_cal_view_event_from (canvas_item); - if (!cal_view_event) - return -1; - - if (E_IS_DAY_VIEW (cal_view)) { - gint day, event_num, num_before; - EDayViewEvent *day_view_event; - EDayView *day_view = E_DAY_VIEW (cal_view); - - /* the long event comes first in the order */ - for (event_num = day_view->long_events->len - 1; event_num >= 0; - --event_num) { - day_view_event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - if (cal_view_event == (ECalendarViewEvent*)day_view_event) - return event_num; - - } - num_before = day_view->long_events->len; - - for (day = 0; day < day_view->days_shown; ++day) { - for (event_num = day_view->events[day]->len - 1; event_num >= 0; - --event_num) { - day_view_event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - if (cal_view_event == (ECalendarViewEvent*)day_view_event) - return num_before + event_num; - } - num_before += day_view->events[day]->len; - } - } - else if (E_IS_WEEK_VIEW (cal_view)) { - AtkObject *atk_parent, *atk_child; - gint index = 0; - - atk_parent = atk_object_get_parent (accessible); - while ((atk_child = atk_object_ref_accessible_child (atk_parent, - index)) != NULL) { - if (atk_child == accessible) { - g_object_unref (atk_child); - return index; - } - g_object_unref (atk_child); - ++index; - } - } - else { - g_return_val_if_reached (-1); - } - return -1; -} - -static AtkStateSet * -ea_cal_view_event_ref_state_set (AtkObject *accessible) -{ - EaCalViewEvent *atk_event = EA_CAL_VIEW_EVENT (accessible); - - g_return_val_if_fail (atk_event->state_set, NULL); - - g_object_ref (atk_event->state_set); - - return atk_event->state_set; -} - -/* Atk Component Interface */ - -static void -atk_component_interface_init (AtkComponentIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->get_extents = ea_cal_view_get_extents; -} - -static void -ea_cal_view_get_extents (AtkComponent *component, - gint *x, - gint *y, - gint *width, - gint *height, - AtkCoordType coord_type) -{ - GObject *g_obj; - GnomeCanvasItem *canvas_item; - gint x_window, y_window; - gint scroll_x, scroll_y; - ECalendarView *cal_view; - gint item_x, item_y, item_w, item_h; - GtkWidget *canvas = NULL; - - g_return_if_fail (EA_IS_CAL_VIEW_EVENT (component)); - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component)); - if (!g_obj) - /* defunct object*/ - return; - g_return_if_fail (E_IS_TEXT (g_obj)); - - canvas_item = GNOME_CANVAS_ITEM (g_obj); - cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item); - if (!cal_view) - return; - - if (E_IS_DAY_VIEW (cal_view)) { - gint day, event_num; - - if (!e_day_view_find_event_from_item (E_DAY_VIEW (cal_view), - canvas_item, - &day, &event_num)) - return; - if (day == E_DAY_VIEW_LONG_EVENT) { - gint start_day, end_day; - if (!e_day_view_get_long_event_position (E_DAY_VIEW (cal_view), - event_num, - &start_day, - &end_day, - &item_x, - &item_y, - &item_w, - &item_h)) - return; - canvas = E_DAY_VIEW (cal_view)->top_canvas; - } - else { - if (!e_day_view_get_event_position (E_DAY_VIEW (cal_view), day, - event_num, - &item_x, &item_y, - &item_w, &item_h)) - - return; - canvas = E_DAY_VIEW (cal_view)->main_canvas; - } - } - else if (E_IS_WEEK_VIEW (cal_view)) { - gint event_num, span_num; - if (!e_week_view_find_event_from_item (E_WEEK_VIEW (cal_view), - canvas_item, &event_num, - &span_num)) - return; - - if (!e_week_view_get_span_position (E_WEEK_VIEW (cal_view), - event_num, span_num, - &item_x, &item_y, &item_w)) - return; - item_h = E_WEEK_VIEW_ICON_HEIGHT; - canvas = E_WEEK_VIEW (cal_view)->main_canvas; - } - else - return; - - if (!canvas) - return; - - gdk_window_get_origin (canvas->window, - &x_window, &y_window); - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (canvas), &scroll_x, &scroll_y); - - *x = item_x + x_window - scroll_x; - *y = item_y + y_window - scroll_y; - *width = item_w; - *height = item_h; - - if (coord_type == ATK_XY_WINDOW) { - GdkWindow *window; - gint x_toplevel, y_toplevel; - - window = gdk_window_get_toplevel (GTK_WIDGET (cal_view)->window); - gdk_window_get_origin (window, &x_toplevel, &y_toplevel); - - *x -= x_toplevel; - *y -= y_toplevel; - } - -#ifdef ACC_DEBUG - printf ("Event Bounds (%d, %d, %d, %d)\n", *x, *y, *width, *height); -#endif -} - -#define CAL_VIEW_EVENT_ACTION_NUM 1 - -static const char * action_name [CAL_VIEW_EVENT_ACTION_NUM] = { - N_("Grab Focus") -}; - -static void -atk_action_interface_init (AtkActionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->do_action = ea_cal_view_event_do_action; - iface->get_n_actions = ea_cal_view_event_get_n_actions; - iface->get_name = ea_cal_view_event_action_get_name; -} - -static gboolean -ea_cal_view_event_do_action (AtkAction *action, gint i) -{ - AtkGObjectAccessible *atk_gobj; - AtkComponent *atk_comp; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (action); - - if (i == 0) { - atk_comp = (AtkComponent *)atk_gobj; - return atk_component_grab_focus (atk_comp); - } - - return FALSE; - -} - -static gint -ea_cal_view_event_get_n_actions (AtkAction *action) -{ - return CAL_VIEW_EVENT_ACTION_NUM; -} - -static G_CONST_RETURN gchar* -ea_cal_view_event_action_get_name (AtkAction *action, gint i) -{ - if (i >= 0 && i < CAL_VIEW_EVENT_ACTION_NUM) - return action_name [i]; - return NULL; -} - diff --git a/a11y/calendar/ea-cal-view-event.h b/a11y/calendar/ea-cal-view-event.h deleted file mode 100644 index c5000095f6..0000000000 --- a/a11y/calendar/ea-cal-view-event.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_CAL_VIEW_EVENT_H__ -#define __EA_CAL_VIEW_EVENT_H__ - -#include <atk/atkgobjectaccessible.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define EA_TYPE_CAL_VIEW_EVENT (ea_cal_view_event_get_type ()) -#define EA_CAL_VIEW_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CAL_VIEW_EVENT, EaCalViewEvent)) -#define EA_CAL_VIEW_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CAL_VIEW_EVENT, EaCalViewEventClass)) -#define EA_IS_CAL_VIEW_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CAL_VIEW_EVENT)) -#define EA_IS_CAL_VIEW_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CAL_VIEW_EVENT)) -#define EA_CAL_VIEW_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CAL_VIEW_EVENT, EaCalViewEventClass)) - -typedef struct _EaCalViewEvent EaCalViewEvent; -typedef struct _EaCalViewEventClass EaCalViewEventClass; - -struct _EaCalViewEvent -{ - AtkGObjectAccessible parent; - AtkStateSet *state_set; -}; - -GType ea_cal_view_event_get_type (void); - -struct _EaCalViewEventClass -{ - AtkGObjectAccessibleClass parent_class; -}; - -AtkObject *ea_cal_view_event_new (GObject *obj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __EA_CAL_VIEW_EVENT_H__ */ diff --git a/a11y/calendar/ea-cal-view.c b/a11y/calendar/ea-cal-view.c deleted file mode 100644 index e184b919b9..0000000000 --- a/a11y/calendar/ea-cal-view.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-cal-view.h" -#include "ea-calendar-helpers.h" -#include "e-day-view.h" -#include "e-week-view.h" -#include "calendar-commands.h" -#include "goto.h" -#include <glib.h> -#include <glib/gi18n.h> - -static void ea_cal_view_class_init (EaCalViewClass *klass); - -static AtkObject* ea_cal_view_get_parent (AtkObject *accessible); -static void ea_cal_view_real_initialize (AtkObject *accessible, gpointer data); - -static void ea_cal_view_event_changed_cb (ECalendarView *cal_view, - ECalendarViewEvent *event, gpointer data); -static void ea_cal_view_event_added_cb (ECalendarView *cal_view, - ECalendarViewEvent *event, gpointer data); - -static gboolean idle_dates_changed (gpointer data); -static void ea_cal_view_dates_change_cb (GnomeCalendar *gcal, gpointer data); - -static void atk_action_interface_init (AtkActionIface *iface); -static gboolean action_interface_do_action (AtkAction *action, gint i); -static gint action_interface_get_n_actions (AtkAction *action); -static G_CONST_RETURN gchar* -action_interface_get_description(AtkAction *action, gint i); -static G_CONST_RETURN gchar* -action_interface_get_keybinding (AtkAction *action, gint i); -static G_CONST_RETURN gchar* -action_interface_action_get_name(AtkAction *action, gint i); - -static gpointer parent_class = NULL; - -GType -ea_cal_view_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaCalViewClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_cal_view_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaCalView), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - static const GInterfaceInfo atk_action_info = { - (GInterfaceInitFunc) atk_action_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (GailWidget, in this case) - */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - GTK_TYPE_WIDGET); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - type = g_type_register_static (derived_atk_type, - "EaCalView", &tinfo, 0); - g_type_add_interface_static (type, ATK_TYPE_ACTION, - &atk_action_info); - } - - return type; -} - -static void -ea_cal_view_class_init (EaCalViewClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - class->get_parent = ea_cal_view_get_parent; - class->initialize = ea_cal_view_real_initialize; -} - -AtkObject* -ea_cal_view_new (GtkWidget *widget) -{ - GObject *object; - AtkObject *accessible; - - g_return_val_if_fail (E_IS_CALENDAR_VIEW (widget), NULL); - - object = g_object_new (EA_TYPE_CAL_VIEW, NULL); - - accessible = ATK_OBJECT (object); - atk_object_initialize (accessible, widget); - - return accessible; -} - -static void -ea_cal_view_real_initialize (AtkObject *accessible, gpointer data) -{ - ECalendarView *cal_view; - GnomeCalendar *gcal; - static AtkRole role = ATK_ROLE_INVALID; - - g_return_if_fail (EA_IS_CAL_VIEW (accessible)); - g_return_if_fail (E_IS_CALENDAR_VIEW (data)); - - ATK_OBJECT_CLASS (parent_class)->initialize (accessible, data); - if (role == ATK_ROLE_INVALID) - role = atk_role_register ("Calendar View"); - accessible->role = role; - cal_view = E_CALENDAR_VIEW (data); - - /* add listener for event_changed, event_added - * we don't need to listen on event_removed. When the e_text - * of the event is removed, the cal_view_event will go to the state - * of "defunct" (changed by weak ref callback of atkgobjectaccessible - */ - g_signal_connect (G_OBJECT(cal_view), "event_changed", - G_CALLBACK (ea_cal_view_event_changed_cb), NULL); - g_signal_connect (G_OBJECT(cal_view), "event_added", - G_CALLBACK (ea_cal_view_event_added_cb), NULL); - - /* listen for date changes of calendar */ - gcal = e_calendar_view_get_calendar (cal_view); - - if (gcal) - g_signal_connect (gcal, "dates_shown_changed", - G_CALLBACK (ea_cal_view_dates_change_cb), - accessible); -} - -static AtkObject* -ea_cal_view_get_parent (AtkObject *accessible) -{ - ECalendarView *cal_view; - GnomeCalendar *gnomeCalendar; - - g_return_val_if_fail (EA_IS_CAL_VIEW (accessible), NULL); - - if (!GTK_ACCESSIBLE (accessible)->widget) - return NULL; - cal_view = E_CALENDAR_VIEW (GTK_ACCESSIBLE (accessible)->widget); - - gnomeCalendar = e_calendar_view_get_calendar (cal_view); - - return gtk_widget_get_accessible (GTK_WIDGET(gnomeCalendar)); -} - -static void -ea_cal_view_event_changed_cb (ECalendarView *cal_view, ECalendarViewEvent *event, - gpointer data) -{ - AtkObject *atk_obj; - AtkObject *event_atk_obj = NULL; - - g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - - atk_obj = gtk_widget_get_accessible (GTK_WIDGET(cal_view)); - if (!EA_IS_CAL_VIEW (atk_obj)) - return; - - if ((E_IS_DAY_VIEW (cal_view)) && event && event->canvas_item) { - event_atk_obj = - ea_calendar_helpers_get_accessible_for (event->canvas_item); - } - else if ((E_IS_WEEK_VIEW (cal_view)) && event) { - EWeekViewEventSpan *span; - EWeekViewEvent *week_view_event = (EWeekViewEvent *)event; - EWeekView *week_view = E_WEEK_VIEW (cal_view); - /* get the first span of the event */ - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - week_view_event->spans_index); - if (span && span->text_item) - event_atk_obj = ea_calendar_helpers_get_accessible_for (span->text_item); - } - if (event_atk_obj) { -#ifdef ACC_DEBUG - printf ("AccDebug: event=%p changed\n", (void *)event); -#endif - g_object_notify (G_OBJECT(event_atk_obj), "accessible-name"); - g_signal_emit_by_name (event_atk_obj, "visible_data_changed"); - } - -} - -static void -ea_cal_view_event_added_cb (ECalendarView *cal_view, ECalendarViewEvent *event, - gpointer data) -{ - AtkObject *atk_obj; - AtkObject *event_atk_obj = NULL; - gint index; - - g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - - atk_obj = gtk_widget_get_accessible (GTK_WIDGET(cal_view)); - if (!EA_IS_CAL_VIEW (atk_obj)) - return; - - if ((E_IS_DAY_VIEW (cal_view)) && event && event->canvas_item) { - event_atk_obj = - ea_calendar_helpers_get_accessible_for (event->canvas_item); - } - else if ((E_IS_WEEK_VIEW (cal_view)) && event) { - EWeekViewEventSpan *span; - EWeekViewEvent *week_view_event = (EWeekViewEvent *)event; - EWeekView *week_view = E_WEEK_VIEW (cal_view); - /* get the first span of the event */ - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - week_view_event->spans_index); - if (span && span->text_item) - event_atk_obj = ea_calendar_helpers_get_accessible_for (span->text_item); - - } - if (event_atk_obj) { - index = atk_object_get_index_in_parent (event_atk_obj); - if (index < 0) - return; -#ifdef ACC_DEBUG - printf ("AccDebug: event=%p added\n", (void *)event); -#endif - g_signal_emit_by_name (atk_obj, "children_changed::add", - index, event_atk_obj, NULL); - } -} - -static gboolean -idle_dates_changed (gpointer data) -{ - AtkObject *ea_cal_view; - - g_return_val_if_fail (data, FALSE); - g_return_val_if_fail (EA_IS_CAL_VIEW (data), FALSE); - - ea_cal_view = ATK_OBJECT(data); - - if (ea_cal_view->name) { - g_free (ea_cal_view->name); - ea_cal_view->name = NULL; - } - g_object_notify (G_OBJECT (ea_cal_view), "accessible-name"); - g_signal_emit_by_name (ea_cal_view, "visible_data_changed"); - g_signal_emit_by_name (ea_cal_view, "children_changed", NULL, NULL, NULL); -#ifdef ACC_DEBUG - printf ("AccDebug: cal view date changed\n"); -#endif - - return FALSE; -} - -static void -ea_cal_view_dates_change_cb (GnomeCalendar *gcal, gpointer data) -{ - g_idle_add (idle_dates_changed, data); -} - -/* atk action interface */ - -#define CAL_VIEW_ACTION_NUM 5 - -static const char * action_name [CAL_VIEW_ACTION_NUM] = { - N_("New Appointment"), - N_("New All Day Event"), - N_("New Meeting"), - N_("Go to Today"), - N_("Go to Date") -}; - -static void -atk_action_interface_init (AtkActionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->do_action = action_interface_do_action; - iface->get_n_actions = action_interface_get_n_actions; - iface->get_description = action_interface_get_description; - iface->get_keybinding = action_interface_get_keybinding; - iface->get_name = action_interface_action_get_name; -} - -static gboolean -action_interface_do_action (AtkAction *action, gint index) -{ - GtkWidget *widget; - gboolean return_value = TRUE; - time_t dtstart, dtend; - ECalendarView *cal_view; - - widget = GTK_ACCESSIBLE (action)->widget; - if (widget == NULL) - /* - * State is defunct - */ - return FALSE; - - if (!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget)) - return FALSE; - - cal_view = E_CALENDAR_VIEW (widget); - switch (index) { - case 0: - /* New Appointment */ - e_calendar_view_new_appointment (cal_view); - break; - case 1: - /* New All Day Event */ - e_calendar_view_get_selected_time_range (cal_view, - &dtstart, &dtend); - e_calendar_view_new_appointment_for (cal_view, - dtstart, dtend, TRUE, FALSE); - break; - case 2: - /* New Meeting */ - e_calendar_view_get_selected_time_range (cal_view, - &dtstart, &dtend); - e_calendar_view_new_appointment_for (cal_view, - dtstart, dtend, FALSE, TRUE); - break; - case 3: - /* Go to today */ - break; - calendar_goto_today (e_calendar_view_get_calendar (cal_view)); - case 4: - /* Go to date */ - goto_dialog (e_calendar_view_get_calendar (cal_view)); - break; - default: - return_value = FALSE; - break; - } - return return_value; -} - -static gint -action_interface_get_n_actions (AtkAction *action) -{ - return CAL_VIEW_ACTION_NUM; -} - -static G_CONST_RETURN gchar* -action_interface_get_description(AtkAction *action, gint index) -{ - return action_interface_action_get_name (action, index); -} - -static G_CONST_RETURN gchar* -action_interface_get_keybinding (AtkAction *action, gint index) -{ - GtkWidget *widget; - - widget = GTK_ACCESSIBLE (action)->widget; - if (widget == NULL) - /* - * State is defunct - */ - return NULL; - - if (!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget)) - return NULL; - - switch (index) { - case 0: - /* New Appointment */ - return "<Alt>fna;<Control>n"; - case 1: - /* New Event */ - return "<Alt>fnd;<Shift><Control>d"; - case 2: - /* New Meeting */ - return "<Alt>fne;<Shift><Control>e"; - case 3: - /* Go to today */ - return "<Alt>vt;<Alt><Control>t"; - case 4: - /* Go to date */ - return "<Alt>vd;<Alt><Control>g"; - default: - break; - } - return NULL; -} - -static G_CONST_RETURN gchar* -action_interface_action_get_name(AtkAction *action, gint i) -{ - if (i >= 0 && i < CAL_VIEW_ACTION_NUM) - return action_name [i]; - return NULL; -} diff --git a/a11y/calendar/ea-cal-view.h b/a11y/calendar/ea-cal-view.h deleted file mode 100644 index e8ebb9eb37..0000000000 --- a/a11y/calendar/ea-cal-view.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_CAL_VIEW_H__ -#define __EA_CAL_VIEW_H__ - -#include <gtk/gtk.h> -#include "e-calendar-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define EA_TYPE_CAL_VIEW (ea_cal_view_get_type ()) -#define EA_CAL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CAL_VIEW, EaCalView)) -#define EA_CAL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CAL_VIEW, EaCalViewClass)) -#define EA_IS_CAL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CAL_VIEW)) -#define EA_IS_CAL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CAL_VIEW)) -#define EA_CAL_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CAL_VIEW, EaCalViewClass)) - -typedef struct _EaCalView EaCalView; -typedef struct _EaCalViewClass EaCalViewClass; - -struct _EaCalView -{ - GtkAccessible parent; -}; - -GType ea_cal_view_get_type (void); - -struct _EaCalViewClass -{ - GtkAccessibleClass parent_class; -}; - -AtkObject* ea_cal_view_new (GtkWidget *widget); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EA_CAL_VIEW_H__ */ diff --git a/a11y/calendar/ea-calendar-helpers.c b/a11y/calendar/ea-calendar-helpers.c deleted file mode 100644 index cc9474c0bc..0000000000 --- a/a11y/calendar/ea-calendar-helpers.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-calendar-helpers.h" -#include "ea-cal-view-event.h" -#include "ea-jump-button.h" -#include "e-day-view.h" -#include "e-week-view.h" - -#include <text/e-text.h> -#include <libgnomecanvas/gnome-canvas-pixbuf.h> - -/** - * ea_calendar_helpers_get_accessible_for - * @canvas_item: the canvas item for a event or a jump button - * @returns: the atk object for the canvas_item - * - **/ -AtkObject * -ea_calendar_helpers_get_accessible_for (GnomeCanvasItem *canvas_item) -{ - AtkObject *atk_obj = NULL; - GObject *g_obj; - - g_return_val_if_fail ((E_IS_TEXT (canvas_item)) || (GNOME_IS_CANVAS_ITEM (canvas_item)), NULL);; - - g_obj = G_OBJECT (canvas_item); - /* we cannot use atk_gobject_accessible_for_object here, - * EaDayViewEvent/EaWeekViewEvent cannot be created by the - * registered facotry of E_TEXT - */ - atk_obj = g_object_get_data (g_obj, "accessible-object"); - if (!atk_obj) { - if (E_IS_TEXT (canvas_item)) { - atk_obj = ea_cal_view_event_new (g_obj); - } - else if (GNOME_IS_CANVAS_PIXBUF(canvas_item)) { - atk_obj = ea_jump_button_new (g_obj); - } - else - return NULL; - } - return atk_obj; -} - -/** - * ea_calendar_helpers_get_view_widget_from: - * @canvas_item: the canvas item for a event or a jump button - * @returns: the cal view widget if exists - * - * Get the cal view widget contains the canvas_item. - * - **/ -ECalendarView * -ea_calendar_helpers_get_cal_view_from (GnomeCanvasItem *canvas_item) -{ - GnomeCanvas *canvas; - GtkWidget *view_widget = NULL; - - g_return_val_if_fail (canvas_item, NULL); - g_return_val_if_fail ((E_IS_TEXT (canvas_item)) || (GNOME_IS_CANVAS_ITEM (canvas_item)), NULL); - - /* canvas_item is the e_text for the event */ - /* canvas_item->canvas is the ECanvas for day view */ - /* parent of canvas_item->canvas is the EDayView or EWeekView widget */ - canvas = canvas_item->canvas; - view_widget = gtk_widget_get_parent (GTK_WIDGET(canvas)); - if (!view_widget || !E_IS_CALENDAR_VIEW (view_widget)) - return NULL; - - return E_CALENDAR_VIEW (view_widget); -} - -/** - * ea_calendar_helpers_get_cal_view_event_from - * @canvas_item: the cavas_item (e_text) for the event - * @returns: the ECalendarViewEvent - * - * Get the ECalendarViewEvent for the canvas_item. - * - **/ -ECalendarViewEvent * -ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item) -{ - ECalendarView *cal_view; - gboolean event_found; - ECalendarViewEvent *cal_view_event; - - g_return_val_if_fail (E_IS_TEXT (canvas_item), NULL); - - cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item); - - if (!cal_view) - return NULL; - - if (E_IS_DAY_VIEW (cal_view)) { - gint event_day, event_num; - EDayViewEvent *day_view_event; - EDayView *day_view = E_DAY_VIEW (cal_view); - event_found = e_day_view_find_event_from_item (day_view, canvas_item, - &event_day, &event_num); - if (!event_found) - return NULL; - if (event_day == E_DAY_VIEW_LONG_EVENT) { - /* a long event */ - day_view_event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - } - else { - /* a main canvas event */ - day_view_event = &g_array_index (day_view->events[event_day], - EDayViewEvent, event_num); - } - cal_view_event = (ECalendarViewEvent *) day_view_event; - } - else if (E_IS_WEEK_VIEW (cal_view)) { - gint event_num, span_num; - EWeekViewEvent *week_view_event; - EWeekView *week_view = E_WEEK_VIEW (cal_view); - event_found = e_week_view_find_event_from_item (week_view, - canvas_item, - &event_num, - &span_num); - if (!event_found) - return NULL; - - week_view_event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - - cal_view_event = (ECalendarViewEvent *)week_view_event; - } - else { - g_return_val_if_reached (NULL); - } - return cal_view_event; -} diff --git a/a11y/calendar/ea-calendar-helpers.h b/a11y/calendar/ea-calendar-helpers.h deleted file mode 100644 index 3c980f2911..0000000000 --- a/a11y/calendar/ea-calendar-helpers.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -/* Evolution Accessibility - */ - -#ifndef _EA_CALENDAR_HELPERS_H__ -#define _EA_CALENDAR_HELPERS_H__ - -#include "ea-cal-view.h" - -AtkObject * -ea_calendar_helpers_get_accessible_for (GnomeCanvasItem *canvas_item); - -ECalendarView * -ea_calendar_helpers_get_cal_view_from (GnomeCanvasItem *canvas_item); - -ECalendarViewEvent * -ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item); - -#endif /* _EA_CALENDAR_HELPERS_H__ */ diff --git a/a11y/calendar/ea-calendar.c b/a11y/calendar/ea-calendar.c deleted file mode 100644 index bc37ab3079..0000000000 --- a/a11y/calendar/ea-calendar.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <text/e-text.h> -#include <libgnomecanvas/gnome-canvas-pixbuf.h> -#include "ea-calendar-helpers.h" -#include "ea-factory.h" -#include "ea-calendar.h" - -#include "calendar/ea-cal-view.h" -#include "calendar/ea-cal-view-event.h" -#include "calendar/ea-day-view.h" -#include "calendar/ea-day-view-main-item.h" -#include "calendar/ea-week-view.h" -#include "calendar/ea-week-view-main-item.h" -#include "calendar/ea-gnome-calendar.h" - - -EA_FACTORY (EA_TYPE_CAL_VIEW, ea_cal_view, ea_cal_view_new) -EA_FACTORY (EA_TYPE_DAY_VIEW, ea_day_view, ea_day_view_new) -EA_FACTORY_GOBJECT (EA_TYPE_DAY_VIEW_MAIN_ITEM, ea_day_view_main_item, ea_day_view_main_item_new) -EA_FACTORY (EA_TYPE_WEEK_VIEW, ea_week_view, ea_week_view_new) -EA_FACTORY_GOBJECT (EA_TYPE_WEEK_VIEW_MAIN_ITEM, ea_week_view_main_item, ea_week_view_main_item_new) -EA_FACTORY (EA_TYPE_GNOME_CALENDAR, ea_gnome_calendar, ea_gnome_calendar_new) - -static gboolean ea_calendar_focus_watcher (GSignalInvocationHint *ihint, - guint n_param_values, - const GValue *param_values, - gpointer data); - -static gpointer e_text_type, pixbuf_type, e_day_view_type, e_week_view_type; -static gpointer e_day_view_main_item_type, e_week_view_main_item_type; - -void -gnome_calendar_a11y_init (void) -{ - /* we only add focus watcher when accessibility is enabled - */ - if (atk_get_root ()) { - EA_SET_FACTORY (gnome_calendar_get_type(), ea_gnome_calendar); - - /* force loading some types */ - e_text_type = g_type_class_ref (E_TYPE_TEXT); - pixbuf_type = g_type_class_ref (GNOME_TYPE_CANVAS_PIXBUF); - e_day_view_type = g_type_class_ref (e_day_view_get_type ()); - e_week_view_type = g_type_class_ref (e_week_view_get_type ()); - e_day_view_main_item_type = g_type_class_ref (e_day_view_main_item_get_type ()); - e_week_view_main_item_type = g_type_class_ref (e_week_view_main_item_get_type ()); - - g_signal_add_emission_hook (g_signal_lookup ("event", E_TYPE_TEXT), - 0, ea_calendar_focus_watcher, - NULL, (GDestroyNotify) NULL); - g_signal_add_emission_hook (g_signal_lookup ("event", GNOME_TYPE_CANVAS_PIXBUF), - 0, ea_calendar_focus_watcher, - NULL, (GDestroyNotify) NULL); - g_signal_add_emission_hook (g_signal_lookup ("event-after", - e_day_view_get_type()), - 0, ea_calendar_focus_watcher, - NULL, (GDestroyNotify) NULL); - g_signal_add_emission_hook (g_signal_lookup ("event", - e_day_view_main_item_get_type()), - 0, ea_calendar_focus_watcher, - NULL, (GDestroyNotify) NULL); - g_signal_add_emission_hook (g_signal_lookup ("event-after", - e_week_view_get_type()), - 0, ea_calendar_focus_watcher, - NULL, (GDestroyNotify) NULL); - g_signal_add_emission_hook (g_signal_lookup ("event", - e_week_view_main_item_get_type()), - 0, ea_calendar_focus_watcher, - NULL, (GDestroyNotify) NULL); - - } -} - -void -e_cal_view_a11y_init (void) -{ - EA_SET_FACTORY (e_calendar_view_get_type(), ea_cal_view); -} - -void -e_day_view_a11y_init (void) -{ - EA_SET_FACTORY (e_day_view_get_type(), ea_day_view); -} - -void -e_day_view_main_item_a11y_init (void) -{ - EA_SET_FACTORY (e_day_view_main_item_get_type (), ea_day_view_main_item); -} - -void -e_week_view_a11y_init (void) -{ - EA_SET_FACTORY (e_week_view_get_type(), ea_week_view); -} - -void -e_week_view_main_item_a11y_init (void) -{ - EA_SET_FACTORY (e_week_view_main_item_get_type (), ea_week_view_main_item); -} - -static gboolean -ea_calendar_focus_watcher (GSignalInvocationHint *ihint, - guint n_param_values, - const GValue *param_values, - gpointer data) -{ - GObject *object; - GdkEvent *event; - AtkObject *ea_event = NULL; - - object = g_value_get_object (param_values + 0); - event = g_value_get_boxed (param_values + 1); - - if ((E_IS_TEXT (object)) || (GNOME_IS_CANVAS_PIXBUF (object))) { - /* "event" signal on canvas item - */ - GnomeCanvasItem *canvas_item; - - canvas_item = GNOME_CANVAS_ITEM (object); - if (event->type == GDK_FOCUS_CHANGE) { - if (event->focus_change.in) { - ea_event = - ea_calendar_helpers_get_accessible_for (canvas_item); - if (!ea_event) - /* not canvas item we want */ - return TRUE; - - } - atk_focus_tracker_notify (ea_event); - } - } - else if (E_IS_DAY_VIEW (object)) { - EDayView *day_view = E_DAY_VIEW (object); - if (event->type == GDK_FOCUS_CHANGE) { - if (event->focus_change.in) { - /* give main item chance to emit focus */ - gnome_canvas_item_grab_focus (day_view->main_canvas_item); - } - } - } - else if (E_IS_DAY_VIEW_MAIN_ITEM (object)) { - if (event->type == GDK_FOCUS_CHANGE) { - if (event->focus_change.in) { - /* we should emit focus on main item */ - ea_event = atk_gobject_accessible_for_object (object); - } - else - /* focus out */ - ea_event = NULL; -#ifdef ACC_DEBUG - printf ("EvoAcc: focus notify on day main item %p\n", (void *)object); -#endif - atk_focus_tracker_notify (ea_event); - } - } else if (E_IS_WEEK_VIEW (object)) { - EWeekView *week_view = E_WEEK_VIEW (object); - if (event->type == GDK_FOCUS_CHANGE) { - if (event->focus_change.in) { - /* give main item chance to emit focus */ - gnome_canvas_item_grab_focus (week_view->main_canvas_item); - } - } - } - else if (E_IS_WEEK_VIEW_MAIN_ITEM (object)) { - if (event->type == GDK_FOCUS_CHANGE) { - if (event->focus_change.in) { - /* we should emit focus on main item */ - ea_event = atk_gobject_accessible_for_object (object); - } - else - /* focus out */ - ea_event = NULL; -#ifdef ACC_DEBUG - printf ("EvoAcc: focus notify on week main item %p\n", (void *)object); -#endif - atk_focus_tracker_notify (ea_event); - } - } - return TRUE; -} diff --git a/a11y/calendar/ea-calendar.h b/a11y/calendar/ea-calendar.h deleted file mode 100644 index 36ef7d5ea0..0000000000 --- a/a11y/calendar/ea-calendar.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -/* Evolution Accessibility -*/ - -#ifndef _EA_CALENDAR_H__ -#define _EA_CALENDAR_H__ - -void gnome_calendar_a11y_init (void); -void e_cal_view_a11y_init (void); -void e_day_view_a11y_init (void); -void e_day_view_main_item_a11y_init (void); -void e_week_view_a11y_init (void); -void e_week_view_main_item_a11y_init (void); - -#endif /* _EA_CALENDAR_H__ */ diff --git a/a11y/calendar/ea-day-view-cell.c b/a11y/calendar/ea-day-view-cell.c deleted file mode 100644 index 1b8e111e97..0000000000 --- a/a11y/calendar/ea-day-view-cell.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-day-view-cell.h" -#include "ea-day-view-main-item.h" -#include "ea-day-view.h" -#include "ea-factory.h" - -/* EDayViewCell */ - -static void e_day_view_cell_class_init (EDayViewCellClass *class); - -EA_FACTORY_GOBJECT (EA_TYPE_DAY_VIEW_CELL, ea_day_view_cell, ea_day_view_cell_new) - -GType -e_day_view_cell_get_type (void) -{ - static GType type = 0; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EDayViewCellClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) e_day_view_cell_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EDayViewCell), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - type = g_type_register_static (G_TYPE_OBJECT, - "EDayViewCell", &tinfo, 0); - } - - return type; -} - -static void -e_day_view_cell_class_init (EDayViewCellClass *class) -{ - EA_SET_FACTORY (e_day_view_cell_get_type (), ea_day_view_cell); -} - -EDayViewCell * -e_day_view_cell_new (EDayView *day_view, gint row, gint column) -{ - GObject *object; - EDayViewCell *cell; - - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), NULL); - - object = g_object_new (E_TYPE_DAY_VIEW_CELL, NULL); - cell = E_DAY_VIEW_CELL (object); - cell->day_view = day_view; - cell->row = row; - cell->column = column; - -#ifdef ACC_DEBUG - printf ("EvoAcc: e_day_view_cell created %p\n", (void *)cell); -#endif - - return cell; -} - -/* EaDayViewCell */ - -static void ea_day_view_cell_class_init (EaDayViewCellClass *klass); - -static G_CONST_RETURN gchar* ea_day_view_cell_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_day_view_cell_get_description (AtkObject *accessible); -static AtkStateSet* ea_day_view_cell_ref_state_set (AtkObject *obj); -static AtkObject * ea_day_view_cell_get_parent (AtkObject *accessible); -static gint ea_day_view_cell_get_index_in_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 gboolean component_interface_grab_focus (AtkComponent *component); - -static gpointer parent_class = NULL; - -#ifdef ACC_DEBUG -static gint n_ea_day_view_cell_created = 0, n_ea_day_view_cell_destroyed = 0; -static void ea_day_view_cell_finalize (GObject *object); -#endif - -GType -ea_day_view_cell_get_type (void) -{ - static GType type = 0; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaDayViewCellClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_day_view_cell_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaDayViewCell), /* 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, - "EaDayViewCell", &tinfo, 0); - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, - &atk_component_info); - } - - return type; -} - -static void -ea_day_view_cell_class_init (EaDayViewCellClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - -#ifdef ACC_DEBUG - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - gobject_class->finalize = ea_day_view_cell_finalize; -#endif - - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_day_view_cell_get_name; - class->get_description = ea_day_view_cell_get_description; - class->ref_state_set = ea_day_view_cell_ref_state_set; - - class->get_parent = ea_day_view_cell_get_parent; - class->get_index_in_parent = ea_day_view_cell_get_index_in_parent; -} - -AtkObject* -ea_day_view_cell_new (GObject *obj) -{ - gpointer object; - AtkObject *atk_object; - - g_return_val_if_fail (E_IS_DAY_VIEW_CELL (obj), NULL); - - object = g_object_new (EA_TYPE_DAY_VIEW_CELL, NULL); - atk_object = ATK_OBJECT (object); - atk_object_initialize (atk_object, obj); - atk_object->role = ATK_ROLE_UNKNOWN; - -#ifdef ACC_DEBUG - ++n_ea_day_view_cell_created; - printf ("ACC_DEBUG: n_ea_day_view_cell_created = %d\n", - n_ea_day_view_cell_created); -#endif - return atk_object; -} - -#ifdef ACC_DEBUG -static void ea_day_view_cell_finalize (GObject *object) -{ - G_OBJECT_CLASS (parent_class)->finalize (object); - - ++n_ea_day_view_cell_destroyed; - printf ("ACC_DEBUG: n_ea_day_view_cell_destroyed = %d\n", - n_ea_day_view_cell_destroyed); -} -#endif - -static G_CONST_RETURN gchar* -ea_day_view_cell_get_name (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewCell *cell; - - g_return_val_if_fail (EA_IS_DAY_VIEW_CELL (accessible), NULL); - - if (!accessible->name) { - AtkObject *ea_main_item; - GnomeCanvasItem *main_item; - gchar *new_name = g_strdup (""); - const gchar *row_label, *column_label; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - cell = E_DAY_VIEW_CELL (g_obj); - main_item = cell->day_view->main_canvas_item; - ea_main_item = atk_gobject_accessible_for_object (G_OBJECT (main_item)); - column_label = atk_table_get_column_description (ATK_TABLE (ea_main_item), - cell->column); - row_label = atk_table_get_row_description (ATK_TABLE (ea_main_item), - cell->row); - new_name = g_strconcat (column_label, " ", row_label, NULL); - ATK_OBJECT_CLASS (parent_class)->set_name (accessible, new_name); - g_free (new_name); - } - return accessible->name; -} - -static G_CONST_RETURN gchar* -ea_day_view_cell_get_description (AtkObject *accessible) -{ - return ea_day_view_cell_get_name (accessible); -} - -static AtkStateSet* -ea_day_view_cell_ref_state_set (AtkObject *obj) -{ - AtkStateSet *state_set; - GObject *g_obj; - AtkObject *parent; - gint x, y, width, height; - gint parent_x, parent_y, parent_width, parent_height; - - state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj); - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(obj)); - if (!g_obj) - return state_set; - - atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE); - - parent = atk_object_get_parent (obj); - atk_component_get_extents (ATK_COMPONENT (obj), &x, &y, - &width, &height, ATK_XY_WINDOW); - atk_component_get_extents (ATK_COMPONENT (parent), &parent_x, &parent_y, - &parent_width, &parent_height, ATK_XY_WINDOW); - - - if (x + width < parent_x || x > parent_x + parent_width || - y + height < parent_y || y > parent_y + parent_height) - /* the cell is out of the main canvas */ - ; - else - atk_state_set_add_state (state_set, ATK_STATE_VISIBLE); - - return state_set; -} - -static AtkObject * -ea_day_view_cell_get_parent (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewCell *cell; - - g_return_val_if_fail (EA_IS_DAY_VIEW_CELL (accessible), NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - cell = E_DAY_VIEW_CELL (g_obj); - return atk_gobject_accessible_for_object (G_OBJECT (cell->day_view->main_canvas_item)); -} - -static gint -ea_day_view_cell_get_index_in_parent (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewCell *cell; - AtkObject *parent; - - g_return_val_if_fail (EA_IS_DAY_VIEW_CELL (accessible), -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - cell = E_DAY_VIEW_CELL (g_obj); - parent = atk_object_get_parent (accessible); - return atk_table_get_index_at (ATK_TABLE (parent), - cell->row, cell->column); -} - -/* Atk Component Interface */ - -static void -atk_component_interface_init (AtkComponentIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->get_extents = component_interface_get_extents; - iface->grab_focus = component_interface_grab_focus; -} - -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; - EDayViewCell *cell; - EDayView *day_view; - GtkWidget *main_canvas; - gint day_view_width, day_view_height; - gint scroll_x, scroll_y; - - *x = *y = *width = *height = 0; - - g_return_if_fail (EA_IS_DAY_VIEW_CELL (component)); - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component)); - if (!g_obj) - /* defunct object*/ - return; - - cell = E_DAY_VIEW_CELL (g_obj); - day_view = cell->day_view; - main_canvas = cell->day_view->main_canvas; - - atk_obj = atk_gobject_accessible_for_object (G_OBJECT (main_canvas)); - atk_component_get_extents (ATK_COMPONENT (atk_obj), - x, y, - &day_view_width, &day_view_height, - coord_type); - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (day_view->main_canvas), - &scroll_x, &scroll_y); - *x += day_view->day_offsets[cell->column] - scroll_x; - *y += day_view->row_height * cell->row - - scroll_y; - *width = day_view->day_widths[cell->column]; - *height = day_view->row_height; -} - -static gboolean -component_interface_grab_focus (AtkComponent *comp) -{ - GObject *g_obj; - EDayViewCell *cell; - EDayView *day_view; - GtkWidget *toplevel; - - g_return_val_if_fail (EA_IS_DAY_VIEW_CELL (comp), FALSE); - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (comp)); - if (!g_obj) - return FALSE; - - cell = E_DAY_VIEW_CELL (g_obj); - day_view = cell->day_view; - - day_view->selection_start_day = cell->column; - day_view->selection_end_day = cell->column; - day_view->selection_start_row = cell->row; - day_view->selection_end_row = cell->row; - - e_day_view_ensure_rows_visible (day_view, - day_view->selection_start_row, - day_view->selection_end_row); - e_day_view_update_calendar_selection_time (day_view); - gtk_widget_queue_draw (day_view->main_canvas); - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (day_view)); - if (GTK_WIDGET_TOPLEVEL (toplevel)) - gtk_window_present (GTK_WINDOW (toplevel)); - - return TRUE; -} - diff --git a/a11y/calendar/ea-day-view-cell.h b/a11y/calendar/ea-day-view-cell.h deleted file mode 100644 index ca674e2451..0000000000 --- a/a11y/calendar/ea-day-view-cell.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_DAY_VIEW_CELL_H__ -#define __EA_DAY_VIEW_CELL_H__ - -#include <atk/atkgobjectaccessible.h> -#include "e-day-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define E_TYPE_DAY_VIEW_CELL (e_day_view_cell_get_type ()) -#define E_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_DAY_VIEW_CELL, EDayViewCell)) -#define E_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_DAY_VIEW_CELL, EDayViewCellClass)) -#define E_IS_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_DAY_VIEW_CELL)) -#define E_IS_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_DAY_VIEW_CELL)) -#define E_DAY_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_DAY_VIEW_CELL, EDayViewCellClass)) - -typedef struct _EDayViewCell EDayViewCell; -typedef struct _EDayViewCellClass EDayViewCellClass; - -struct _EDayViewCell -{ - GObject parent; - EDayView *day_view; - gint row; - gint column; -}; - -GType e_day_view_cell_get_type (void); - -struct _EDayViewCellClass -{ - GObjectClass parent_class; -}; - -EDayViewCell * e_day_view_cell_new (EDayView *day_view, gint row, gint column); - -#define EA_TYPE_DAY_VIEW_CELL (ea_day_view_cell_get_type ()) -#define EA_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_DAY_VIEW_CELL, EaDayViewCell)) -#define EA_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_DAY_VIEW_CELL, EaDayViewCellClass)) -#define EA_IS_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_DAY_VIEW_CELL)) -#define EA_IS_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_DAY_VIEW_CELL)) -#define EA_DAY_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_DAY_VIEW_CELL, EaDayViewCellClass)) - -typedef struct _EaDayViewCell EaDayViewCell; -typedef struct _EaDayViewCellClass EaDayViewCellClass; - -struct _EaDayViewCell -{ - AtkGObjectAccessible parent; -}; - -GType ea_day_view_cell_get_type (void); - -struct _EaDayViewCellClass -{ - AtkGObjectAccessibleClass parent_class; -}; - -AtkObject* ea_day_view_cell_new (GObject *gobj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EA_DAY_VIEW_CELL_H__ */ diff --git a/a11y/calendar/ea-day-view-main-item.c b/a11y/calendar/ea-day-view-main-item.c deleted file mode 100644 index 55602e5d92..0000000000 --- a/a11y/calendar/ea-day-view-main-item.c +++ /dev/null @@ -1,1289 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-day-view-main-item.h" -#include "e-day-view-top-item.h" -#include "ea-day-view.h" -#include "ea-day-view-cell.h" -#include "ea-cell-table.h" -#include <glib/gi18n.h> - -/* EaDayViewMainItem */ -static void ea_day_view_main_item_class_init (EaDayViewMainItemClass *klass); - -static void ea_day_view_main_item_finalize (GObject *object); -static G_CONST_RETURN gchar* ea_day_view_main_item_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_day_view_main_item_get_description (AtkObject *accessible); - -static gint ea_day_view_main_item_get_n_children (AtkObject *obj); -static AtkObject* ea_day_view_main_item_ref_child (AtkObject *obj, - gint i); -static AtkObject * ea_day_view_main_item_get_parent (AtkObject *accessible); -static gint ea_day_view_main_item_get_index_in_parent (AtkObject *accessible); - -/* callbacks */ -static void ea_day_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data); -static void ea_day_view_main_item_time_change_cb (EDayView *day_view, gpointer data); - -/* 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); -/* atk table interface */ -static void atk_table_interface_init (AtkTableIface *iface); -static gint table_interface_get_index_at (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_column_at_index (AtkTable *table, - gint index); -static gint table_interface_get_row_at_index (AtkTable *table, - gint index); -static AtkObject* table_interface_ref_at (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_n_rows (AtkTable *table); -static gint table_interface_get_n_columns (AtkTable *table); -static gint table_interface_get_column_extent_at (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_row_extent_at (AtkTable *table, - gint row, - gint column); - -static gboolean table_interface_is_row_selected (AtkTable *table, - gint row); -static gboolean table_interface_is_column_selected (AtkTable *table, - gint row); -static gboolean table_interface_is_selected (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_selected_rows (AtkTable *table, - gint **rows_selected); -static gint table_interface_get_selected_columns (AtkTable *table, - gint **columns_selected); -static gboolean table_interface_add_row_selection (AtkTable *table, gint row); -static gboolean table_interface_remove_row_selection (AtkTable *table, - gint row); -static gboolean table_interface_add_column_selection (AtkTable *table, - gint column); -static gboolean table_interface_remove_column_selection (AtkTable *table, - gint column); -static AtkObject* table_interface_get_row_header (AtkTable *table, gint row); -static AtkObject* table_interface_get_column_header (AtkTable *table, - gint in_col); -static AtkObject* table_interface_get_caption (AtkTable *table); - -static G_CONST_RETURN gchar* -table_interface_get_column_description (AtkTable *table, gint in_col); - -static G_CONST_RETURN gchar* -table_interface_get_row_description (AtkTable *table, gint row); - -static AtkObject* table_interface_get_summary (AtkTable *table); - -/* atk selection interface */ -static void atk_selection_interface_init (AtkSelectionIface *iface); -static gboolean selection_interface_add_selection (AtkSelection *selection, - gint i); -static gboolean selection_interface_clear_selection (AtkSelection *selection); -static AtkObject* selection_interface_ref_selection (AtkSelection *selection, - gint i); -static gint selection_interface_get_selection_count (AtkSelection *selection); -static gboolean selection_interface_is_child_selected (AtkSelection *selection, - gint i); - -/* helpers */ -static EaCellTable * -ea_day_view_main_item_get_cell_data (EaDayViewMainItem *ea_main_item); - -static void -ea_day_view_main_item_destory_cell_data (EaDayViewMainItem *ea_main_item); - -static gint -ea_day_view_main_item_get_child_index_at (EaDayViewMainItem *ea_main_item, - gint row, gint column); -static gint -ea_day_view_main_item_get_row_at_index (EaDayViewMainItem *ea_main_item, - gint index); -static gint -ea_day_view_main_item_get_column_at_index (EaDayViewMainItem *ea_main_item, - gint index); -static gint -ea_day_view_main_item_get_row_label (EaDayViewMainItem *ea_main_item, - gint row, gchar *buffer, - gint buffer_size); - -#ifdef ACC_DEBUG -static gint n_ea_day_view_main_item_created = 0; -static gint n_ea_day_view_main_item_destroyed = 0; -#endif - -static gpointer parent_class = NULL; - -GType -ea_day_view_main_item_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaDayViewMainItemClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_day_view_main_item_class_init, - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaDayViewMainItem), /* 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 - }; - - static const GInterfaceInfo atk_table_info = { - (GInterfaceInitFunc) atk_table_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - static const GInterfaceInfo atk_selection_info = { - (GInterfaceInitFunc) atk_selection_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (GailCanvasItem, in this case) - * - */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - e_day_view_main_item_get_type()); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - type = g_type_register_static (derived_atk_type, - "EaDayViewMainItem", &tinfo, 0); - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, - &atk_component_info); - g_type_add_interface_static (type, ATK_TYPE_TABLE, - &atk_table_info); - g_type_add_interface_static (type, ATK_TYPE_SELECTION, - &atk_selection_info); - } - - return type; -} - -static void -ea_day_view_main_item_class_init (EaDayViewMainItemClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - - gobject_class->finalize = ea_day_view_main_item_finalize; - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_day_view_main_item_get_name; - class->get_description = ea_day_view_main_item_get_description; - - class->get_n_children = ea_day_view_main_item_get_n_children; - class->ref_child = ea_day_view_main_item_ref_child; - class->get_parent = ea_day_view_main_item_get_parent; - class->get_index_in_parent = ea_day_view_main_item_get_index_in_parent; -} - -AtkObject* -ea_day_view_main_item_new (GObject *obj) -{ - AtkObject *accessible; - GnomeCalendar *gcal; - EDayViewMainItem *main_item; - - g_return_val_if_fail (E_IS_DAY_VIEW_MAIN_ITEM (obj), NULL); - - accessible = ATK_OBJECT (g_object_new (EA_TYPE_DAY_VIEW_MAIN_ITEM, - NULL)); - - atk_object_initialize (accessible, obj); - accessible->role = ATK_ROLE_TABLE; - -#ifdef ACC_DEBUG - ++n_ea_day_view_main_item_created; - printf ("ACC_DEBUG: n_ea_day_view_main_item_created = %d\n", - n_ea_day_view_main_item_created); -#endif - main_item = E_DAY_VIEW_MAIN_ITEM (obj); - g_signal_connect (main_item->day_view, "selected_time_changed", - G_CALLBACK (ea_day_view_main_item_time_change_cb), - accessible); - - /* listen for date changes of calendar */ - gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (main_item->day_view)); - if (gcal) - g_signal_connect (gcal, "dates_shown_changed", - G_CALLBACK (ea_day_view_main_item_dates_change_cb), - accessible); - - return accessible; -} - -static void -ea_day_view_main_item_finalize (GObject *object) -{ - EaDayViewMainItem *ea_main_item; - - g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (object)); - - ea_main_item = EA_DAY_VIEW_MAIN_ITEM (object); - - /* Free the allocated cell data */ - ea_day_view_main_item_destory_cell_data (ea_main_item); - - G_OBJECT_CLASS (parent_class)->finalize (object); -#ifdef ACC_DEBUG - ++n_ea_day_view_main_item_destroyed; - printf ("ACC_DEBUG: n_ea_day_view_main_item_destroyed = %d\n", - n_ea_day_view_main_item_destroyed); -#endif -} - -static G_CONST_RETURN gchar* -ea_day_view_main_item_get_name (AtkObject *accessible) -{ - AtkObject *parent; - g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), NULL); - parent = atk_object_get_parent (accessible); - - if (!parent) - return NULL; - - return atk_object_get_name (parent); -} - -static G_CONST_RETURN gchar* -ea_day_view_main_item_get_description (AtkObject *accessible) -{ - return _("a table to view and select the current time range"); -} - -static gint -ea_day_view_main_item_get_n_children (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - - g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - return day_view->rows * day_view->days_shown; -} - -static AtkObject * -ea_day_view_main_item_ref_child (AtkObject *accessible, gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - gint n_children; - EDayViewCell *cell; - EaCellTable *cell_data; - EaDayViewMainItem *ea_main_item; - - g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - n_children = ea_day_view_main_item_get_n_children (accessible); - if (index < 0 || index >= n_children) - return NULL; - - ea_main_item = EA_DAY_VIEW_MAIN_ITEM (accessible); - cell_data = ea_day_view_main_item_get_cell_data (ea_main_item); - if (!cell_data) - return NULL; - - cell = ea_cell_table_get_cell_at_index (cell_data, index); - if (!cell) { - gint row, column; - - row = ea_day_view_main_item_get_row_at_index (ea_main_item, index); - column = ea_day_view_main_item_get_column_at_index (ea_main_item, index); - cell = e_day_view_cell_new (day_view, row, column); - ea_cell_table_set_cell_at_index (cell_data, index, cell); - g_object_unref (cell); - } - return g_object_ref (atk_gobject_accessible_for_object (G_OBJECT(cell))); -} - -static AtkObject * -ea_day_view_main_item_get_parent (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - - g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - return gtk_widget_get_accessible (GTK_WIDGET (main_item->day_view)); -} - -static gint -ea_day_view_main_item_get_index_in_parent (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - - g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - /* always the first child of ea-day-view */ - return 0; -} - -/* callbacks */ - -static void -ea_day_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data) -{ - EaDayViewMainItem *ea_main_item; - - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (data); - g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (data)); - - ea_main_item = EA_DAY_VIEW_MAIN_ITEM (data); - -#ifdef ACC_DEBUG - printf ("EvoAcc: ea_day_view_main_item update cb\n"); -#endif - - ea_day_view_main_item_destory_cell_data (ea_main_item); -} - -static void -ea_day_view_main_item_time_change_cb (EDayView *day_view, gpointer data) -{ - EaDayViewMainItem *ea_main_item; - AtkObject *item_cell = NULL; - - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - g_return_if_fail (data); - g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (data)); - - ea_main_item = EA_DAY_VIEW_MAIN_ITEM (data); - -#ifdef ACC_DEBUG - printf ("EvoAcc: ea_day_view_main_item time changed cb\n"); -#endif - /* only deal with the first selected child, for now */ - item_cell = atk_selection_ref_selection (ATK_SELECTION (ea_main_item), - 0); - if (item_cell) { - AtkStateSet *state_set; - state_set = atk_object_ref_state_set (item_cell); - atk_state_set_add_state (state_set, ATK_STATE_FOCUSED); - g_object_unref (state_set); - - g_signal_emit_by_name (ea_main_item, - "active-descendant-changed", - item_cell); - g_signal_emit_by_name (data, "selection_changed"); - - atk_focus_tracker_notify (item_cell); - g_object_unref (item_cell); - } - -} - -/* helpers */ - -static gint -ea_day_view_main_item_get_child_index_at (EaDayViewMainItem *ea_main_item, - gint row, gint column) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - - g_return_val_if_fail (ea_main_item, -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - if (row >= 0 && row < day_view->rows && - column >= 0 && column < day_view->days_shown) - return column * day_view->rows + row; - return -1; -} - -static gint -ea_day_view_main_item_get_row_at_index (EaDayViewMainItem *ea_main_item, - gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - gint n_children; - - g_return_val_if_fail (ea_main_item, -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - n_children = ea_day_view_main_item_get_n_children (ATK_OBJECT (ea_main_item)); - if (index >= 0 && index < n_children) - return index % day_view->rows; - return -1; -} - -static gint -ea_day_view_main_item_get_column_at_index (EaDayViewMainItem *ea_main_item, - gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - gint n_children; - - g_return_val_if_fail (ea_main_item, -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - n_children = ea_day_view_main_item_get_n_children (ATK_OBJECT (ea_main_item)); - if (index >= 0 && index < n_children) - return index / day_view->rows; - return -1; -} - -static gint -ea_day_view_main_item_get_row_label (EaDayViewMainItem *ea_main_item, - gint row, gchar *buffer, gint buffer_size) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - gchar *suffix; - gint hour, minute, suffix_width; - - g_return_val_if_fail (ea_main_item, 0); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return 0 ; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - hour = day_view->first_hour_shown; - minute = day_view->first_minute_shown; - minute += row * day_view->mins_per_row; - hour = (hour + minute / 60) % 24; - minute %= 60; - - e_day_view_convert_time_to_display (day_view, hour, &hour, - &suffix, &suffix_width); - return g_snprintf (buffer, buffer_size, "%i:%02i %s", - hour, minute, suffix); -} - -static EaCellTable * -ea_day_view_main_item_get_cell_data (EaDayViewMainItem *ea_main_item) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaCellTable *cell_data; - - g_return_val_if_fail (ea_main_item, NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - cell_data = g_object_get_data (G_OBJECT(ea_main_item), - "ea-day-view-cell-table"); - if (!cell_data) { - cell_data = ea_cell_table_create (day_view->rows, - day_view->days_shown, TRUE); - g_object_set_data (G_OBJECT(ea_main_item), - "ea-day-view-cell-table", cell_data); - } - return cell_data; -} - -static void -ea_day_view_main_item_destory_cell_data (EaDayViewMainItem *ea_main_item) -{ - EaCellTable *cell_data; - - g_return_if_fail (ea_main_item); - - cell_data = g_object_get_data (G_OBJECT(ea_main_item), - "ea-day-view-cell-table"); - if (cell_data) { - g_object_set_data (G_OBJECT(ea_main_item), - "ea-day-view-cell-table", NULL); - ea_cell_table_destroy (cell_data); - } -} - -/* 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 *ea_canvas; - EDayViewMainItem *main_item; - EDayView *day_view; - - *x = *y = *width = *height = 0; - - g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (component)); - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component)); - if (!g_obj) - /* defunct object*/ - return; - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - ea_canvas = gtk_widget_get_accessible (day_view->main_canvas); - atk_component_get_extents (ATK_COMPONENT (ea_canvas), x, y, - width, height, coord_type); -} - -/* atk table interface */ - -static void -atk_table_interface_init (AtkTableIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->ref_at = table_interface_ref_at; - - iface->get_n_rows = table_interface_get_n_rows; - iface->get_n_columns = table_interface_get_n_columns; - iface->get_index_at = table_interface_get_index_at; - iface->get_column_at_index = table_interface_get_column_at_index; - iface->get_row_at_index = table_interface_get_row_at_index; - iface->get_column_extent_at = table_interface_get_column_extent_at; - iface->get_row_extent_at = table_interface_get_row_extent_at; - - iface->is_selected = table_interface_is_selected; - iface->get_selected_rows = table_interface_get_selected_rows; - iface->get_selected_columns = table_interface_get_selected_columns; - iface->is_row_selected = table_interface_is_row_selected; - iface->is_column_selected = table_interface_is_column_selected; - iface->add_row_selection = table_interface_add_row_selection; - iface->remove_row_selection = table_interface_remove_row_selection; - iface->add_column_selection = table_interface_add_column_selection; - iface->remove_column_selection = table_interface_remove_column_selection; - - iface->get_row_header = table_interface_get_row_header; - iface->get_column_header = table_interface_get_column_header; - iface->get_caption = table_interface_get_caption; - iface->get_summary = table_interface_get_summary; - iface->get_row_description = table_interface_get_row_description; - iface->get_column_description = table_interface_get_column_description; -} - -static AtkObject* -table_interface_ref_at (AtkTable *table, - gint row, - gint column) -{ - gint index; - - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - index = ea_day_view_main_item_get_child_index_at (ea_main_item, - row, column); - return ea_day_view_main_item_ref_child (ATK_OBJECT (ea_main_item), index); -} - -static gint -table_interface_get_n_rows (AtkTable *table) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - return day_view->rows; -} - -static gint -table_interface_get_n_columns (AtkTable *table) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - return day_view->days_shown; -} - -static gint -table_interface_get_index_at (AtkTable *table, - gint row, - gint column) -{ - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - return ea_day_view_main_item_get_child_index_at (ea_main_item, - row, column); -} - -static gint -table_interface_get_column_at_index (AtkTable *table, - gint index) -{ - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - return ea_day_view_main_item_get_column_at_index (ea_main_item, index); -} - -static gint -table_interface_get_row_at_index (AtkTable *table, - gint index) -{ - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - return ea_day_view_main_item_get_row_at_index (ea_main_item, index); -} - -static gint -table_interface_get_column_extent_at (AtkTable *table, - gint row, - gint column) -{ - gint index; - gint width = 0, height = 0; - AtkObject *child; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - - index = ea_day_view_main_item_get_child_index_at (ea_main_item, - row, column); - child = atk_object_ref_accessible_child (ATK_OBJECT (ea_main_item), - index); - if (child) - atk_component_get_size (ATK_COMPONENT (child), - &width, &height); - - return width; -} - -static gint -table_interface_get_row_extent_at (AtkTable *table, - gint row, - gint column) -{ - gint index; - gint width = 0, height = 0; - AtkObject *child; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - - index = ea_day_view_main_item_get_child_index_at (ea_main_item, - row, column); - child = atk_object_ref_accessible_child (ATK_OBJECT (ea_main_item), - index); - if (child) - atk_component_get_size (ATK_COMPONENT (child), - &width, &height); - - return height; -} - -static gboolean -table_interface_is_row_selected (AtkTable *table, - gint row) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - if (day_view->selection_start_day == -1) - /* no selection */ - return FALSE; - if (day_view->selection_start_day != day_view->selection_end_day) - /* all row is selected */ - return TRUE; - if (row >= day_view->selection_start_row && - row <= day_view->selection_end_row) - return TRUE; - return FALSE; -} - -static gboolean -table_interface_is_selected (AtkTable *table, - gint row, - gint column) -{ - return table_interface_is_row_selected (table, row) && - table_interface_is_column_selected (table, column); -} - -static gboolean -table_interface_is_column_selected (AtkTable *table, - gint column) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - if (column >= day_view->selection_start_day && - column <= day_view->selection_end_day) - return TRUE; - return FALSE; -} - -static gint -table_interface_get_selected_rows (AtkTable *table, - gint **rows_selected) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - gint start_row = -1, n_rows = 0; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - if (day_view->selection_start_day == -1) - return 0; - - if (day_view->selection_start_day != day_view->selection_end_day) { - /* all the rows should be selected */ - n_rows = day_view->rows; - start_row = 0; - } - else if (day_view->selection_start_row != -1) { - start_row = day_view->selection_start_row; - n_rows = day_view->selection_end_row - start_row + 1; - } - if (n_rows > 0 && start_row != -1 && rows_selected) { - gint index; - - *rows_selected = (gint *) g_malloc (n_rows * sizeof (gint)); - for (index = 0; index < n_rows; ++index) - (*rows_selected)[index] = start_row + index; - } - return n_rows; -} - -static gint -table_interface_get_selected_columns (AtkTable *table, - gint **columns_selected) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - gint start_column = -1, n_columns = 0; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - if (day_view->selection_start_day == -1) - return 0; - - start_column = day_view->selection_start_day; - n_columns = day_view->selection_end_day - start_column + 1; - if (n_columns > 0 && start_column != -1 && columns_selected) { - gint index; - - *columns_selected = (gint *) g_malloc (n_columns * sizeof (gint)); - for (index = 0; index < n_columns; ++index) - (*columns_selected)[index] = start_column + index; - } - return n_columns; -} - -static gboolean -table_interface_add_row_selection (AtkTable *table, - gint row) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - /* FIXME: we need multi-selection */ - - day_view->selection_start_day = 0; - day_view->selection_end_day = 0; - day_view->selection_start_row = row; - day_view->selection_end_row = row; - - e_day_view_ensure_rows_visible (day_view, - day_view->selection_start_row, - day_view->selection_end_row); - e_day_view_update_calendar_selection_time (day_view); - gtk_widget_queue_draw (day_view->main_canvas); - return TRUE; -} - -static gboolean -table_interface_remove_row_selection (AtkTable *table, - gint row) -{ - return FALSE; -} - -static gboolean -table_interface_add_column_selection (AtkTable *table, - gint column) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - /* FIXME: we need multi-selection */ - - day_view->selection_start_day = column; - day_view->selection_end_day = column; - day_view->selection_start_row = 0; - day_view->selection_end_row = day_view->rows; - - e_day_view_update_calendar_selection_time (day_view); - gtk_widget_queue_draw (day_view->main_canvas); - return TRUE; -} - -static gboolean -table_interface_remove_column_selection (AtkTable *table, - gint column) -{ - /* FIXME: NOT IMPLEMENTED */ - return FALSE; -} - -static AtkObject* -table_interface_get_row_header (AtkTable *table, - gint row) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -static AtkObject* -table_interface_get_column_header (AtkTable *table, - gint in_col) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -static AtkObject* -table_interface_get_caption (AtkTable *table) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -static G_CONST_RETURN gchar* -table_interface_get_column_description (AtkTable *table, - gint in_col) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - const gchar *description; - EaCellTable *cell_data; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - if (in_col < 0 || in_col >= day_view->days_shown) - return NULL; - cell_data = ea_day_view_main_item_get_cell_data (ea_main_item); - if (!cell_data) - return NULL; - - description = ea_cell_table_get_column_label (cell_data, in_col); - if (!description) { - gchar buffer[128]; - e_day_view_top_item_get_day_label (day_view, in_col, buffer, 128); - ea_cell_table_set_column_label (cell_data, in_col, buffer); - description = ea_cell_table_get_column_label (cell_data, in_col); - } - return description; -} - -static G_CONST_RETURN gchar* -table_interface_get_row_description (AtkTable *table, - gint row) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); - const gchar *description; - EaCellTable *cell_data; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - if (row < 0 || row >= 12 * 24) - return NULL; - cell_data = ea_day_view_main_item_get_cell_data (ea_main_item); - if (!cell_data) - return NULL; - - description = ea_cell_table_get_row_label (cell_data, row); - if (!description) { - gchar buffer[128]; - ea_day_view_main_item_get_row_label (ea_main_item, row, buffer, sizeof (buffer)); - ea_cell_table_set_row_label (cell_data, row, buffer); - description = ea_cell_table_get_row_label (cell_data, - row); - } - return description; -} - -static AtkObject* -table_interface_get_summary (AtkTable *table) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -/* atkselection interface */ - -static void -atk_selection_interface_init (AtkSelectionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->add_selection = selection_interface_add_selection; - iface->clear_selection = selection_interface_clear_selection; - iface->ref_selection = selection_interface_ref_selection; - iface->get_selection_count = selection_interface_get_selection_count; - iface->is_child_selected = selection_interface_is_child_selected; -} - -static gboolean -selection_interface_add_selection (AtkSelection *selection, gint i) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection); - gint column, row; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - row = ea_day_view_main_item_get_row_at_index (ea_main_item, i); - column = ea_day_view_main_item_get_column_at_index (ea_main_item, i); - - if (row == -1 || column == -1) - return FALSE; - - /*FIXME: multi-selection is needed */ - day_view->selection_start_day = column; - day_view->selection_end_day = column; - day_view->selection_start_row = row; - day_view->selection_end_row = row; - - e_day_view_ensure_rows_visible (day_view, - day_view->selection_start_row, - day_view->selection_end_row); - e_day_view_update_calendar_selection_time (day_view); - gtk_widget_queue_draw (day_view->main_canvas); - return TRUE; -} - -static gboolean -selection_interface_clear_selection (AtkSelection *selection) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - day_view->selection_start_row = -1; - day_view->selection_start_day = -1; - day_view->selection_end_row = -1; - day_view->selection_end_day = -1; - - e_day_view_update_calendar_selection_time (day_view); - gtk_widget_queue_draw (day_view->main_canvas); - - return TRUE; -} - -static AtkObject* -selection_interface_ref_selection (AtkSelection *selection, gint i) -{ - gint count; - GObject *g_obj; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection); - gint start_index; - - count = selection_interface_get_selection_count (selection); - if (i < 0 || i >=count) - return NULL; - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (ea_main_item)); - day_view = E_DAY_VIEW_MAIN_ITEM (g_obj)->day_view; - start_index = ea_day_view_main_item_get_child_index_at (ea_main_item, - day_view->selection_start_row, - day_view->selection_start_day); - - return ea_day_view_main_item_ref_child (ATK_OBJECT (selection), start_index + i); -} - -static gint -selection_interface_get_selection_count (AtkSelection *selection) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection); - gint start_index, end_index; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return 0; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - if (day_view->selection_start_day == -1 || - day_view->selection_start_row == -1) - return 0; - start_index = ea_day_view_main_item_get_child_index_at (ea_main_item, - day_view->selection_start_row, - day_view->selection_start_day); - end_index = ea_day_view_main_item_get_child_index_at (ea_main_item, - day_view->selection_end_row, - day_view->selection_end_day); - - return end_index - start_index + 1; -} - -static gboolean -selection_interface_is_child_selected (AtkSelection *selection, gint i) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EDayViewMainItem *main_item; - EDayView *day_view; - EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection); - gint column, row; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); - day_view = main_item->day_view; - - row = ea_day_view_main_item_get_row_at_index (ea_main_item, i); - column = ea_day_view_main_item_get_column_at_index (ea_main_item, i); - - if (column < day_view->selection_start_day || - column > day_view->selection_end_day) - return FALSE; - - if ((column == day_view->selection_start_day || - column == day_view->selection_end_day) && - (row < day_view->selection_start_row || - row > day_view->selection_end_row)) - return FALSE; - - /* if comes here, the cell is selected */ - return TRUE; -} diff --git a/a11y/calendar/ea-day-view-main-item.h b/a11y/calendar/ea-day-view-main-item.h deleted file mode 100644 index 79b166f39a..0000000000 --- a/a11y/calendar/ea-day-view-main-item.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_DAY_VIEW_MAIN_ITEM_H__ -#define __EA_DAY_VIEW_MAIN_ITEM_H__ - -#include <atk/atkgobjectaccessible.h> -#include "e-day-view-main-item.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define EA_TYPE_DAY_VIEW_MAIN_ITEM (ea_day_view_main_item_get_type ()) -#define EA_DAY_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_DAY_VIEW_MAIN_ITEM, EaDayViewMainItem)) -#define EA_DAY_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_DAY_VIEW_MAIN_ITEM, EaDayViewMainItemClass)) -#define EA_IS_DAY_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_DAY_VIEW_MAIN_ITEM)) -#define EA_IS_DAY_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_DAY_VIEW_MAIN_ITEM)) -#define EA_DAY_VIEW_MAIN_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_DAY_VIEW_MAIN_ITEM, EaDayViewMainItemClass)) - -typedef struct _EaDayViewMainItem EaDayViewMainItem; -typedef struct _EaDayViewMainItemClass EaDayViewMainItemClass; - -struct _EaDayViewMainItem -{ - AtkGObjectAccessible parent; -}; - -GType ea_day_view_main_item_get_type (void); - -struct _EaDayViewMainItemClass -{ - AtkGObjectAccessibleClass parent_class; -}; - -AtkObject* ea_day_view_main_item_new (GObject *obj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EA_DAY_VIEW_MAIN_ITEM_H__ */ diff --git a/a11y/calendar/ea-day-view.c b/a11y/calendar/ea-day-view.c deleted file mode 100644 index b43ddbe56f..0000000000 --- a/a11y/calendar/ea-day-view.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-day-view.h" -#include "ea-cal-view-event.h" - -#include "ea-calendar-helpers.h" -#include "ea-gnome-calendar.h" -#include "calendar-commands.h" -#include <glib.h> -#include <glib/gi18n.h> - -static void ea_day_view_class_init (EaDayViewClass *klass); - -static G_CONST_RETURN gchar* ea_day_view_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_day_view_get_description (AtkObject *accessible); -static gint ea_day_view_get_n_children (AtkObject *obj); -static AtkObject* ea_day_view_ref_child (AtkObject *obj, - gint i); -static gpointer parent_class = NULL; - -GType -ea_day_view_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaDayViewClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_day_view_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaDayView), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (EaCalView, in this case) - * - * Note: we must still use run-time deriving here, because - * our parent class EaCalView is run-time deriving. - */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - e_calendar_view_get_type()); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - type = g_type_register_static (derived_atk_type, - "EaDayView", &tinfo, 0); - } - - return type; -} - -static void -ea_day_view_class_init (EaDayViewClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_day_view_get_name; - class->get_description = ea_day_view_get_description; - - class->get_n_children = ea_day_view_get_n_children; - class->ref_child = ea_day_view_ref_child; -} - -AtkObject* -ea_day_view_new (GtkWidget *widget) -{ - GObject *object; - AtkObject *accessible; - - g_return_val_if_fail (E_IS_DAY_VIEW (widget), NULL); - - object = g_object_new (EA_TYPE_DAY_VIEW, NULL); - - accessible = ATK_OBJECT (object); - atk_object_initialize (accessible, widget); - -#ifdef ACC_DEBUG - printf ("EvoAcc: ea_day_view created %p\n", (void *)accessible); -#endif - - return accessible; -} - -static G_CONST_RETURN gchar* -ea_day_view_get_name (AtkObject *accessible) -{ - EDayView *day_view; - GnomeCalendar *gcal; - const gchar *label_text; - GnomeCalendarViewType view_type; - gint n_events; - gchar *event_str, *name_str; - - g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), NULL); - - if (!GTK_ACCESSIBLE (accessible)->widget) - return NULL; - - day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget); - gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view)); - if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (gcal))) - return NULL; - - label_text = ea_gnome_calendar_get_label_description (gcal); - - n_events = atk_object_get_n_accessible_children (accessible); - /* the child main item is always there */ - --n_events; - if (n_events >= 1) - /* To translators: Here, "It" is either like "Work Week View: July - 10th - July 14th, 2006." or "Day View: Thursday July 13th, 2006." */ - event_str = g_strdup_printf (ngettext ("It has %d event.", "It has %d events.", n_events), n_events); - else - /* To translators: Here, "It" is either like "Work Week View: July - 10th - July 14th, 2006." or "Day View: Thursday July 13th, 2006." */ - event_str = g_strdup (_("It has no events.")); - - view_type = gnome_calendar_get_view (gcal); - if (view_type == GNOME_CAL_WORK_WEEK_VIEW) - /* To translators: First %s is the week, for example "July 10th - - July 14th, 2006". Second %s is the number of events in this work - week, for example "It has %d event/events." or "It has no events." */ - name_str = g_strdup_printf (_("Work Week View: %s. %s"), - label_text, event_str); - else - /* To translators: First %s is the day, for example "Thursday July - 13th, 2006". Second %s is the number of events on this day, for - example "It has %d event/events." or "It has no events." */ - name_str = g_strdup_printf (_("Day View: %s. %s"), - label_text, event_str); - - ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name_str); - g_free (name_str); - g_free (event_str); - - return accessible->name; -} - -static G_CONST_RETURN gchar* -ea_day_view_get_description (AtkObject *accessible) -{ - EDayView *day_view; - - g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), NULL); - - if (!GTK_ACCESSIBLE (accessible)->widget) - return NULL; - day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget); - - if (accessible->description) - return accessible->description; - else { - GnomeCalendar *gcal; - GnomeCalendarViewType view_type; - - gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view)); - view_type = gnome_calendar_get_view (gcal); - - if (view_type == GNOME_CAL_WORK_WEEK_VIEW) - return _("calendar view for a work week"); - else - return _("calendar view for one or more days"); - } -} - -static gint -ea_day_view_get_n_children (AtkObject *accessible) -{ - EDayView *day_view; - gint day; - gint child_num = 0; - - g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), -1); - - if (!GTK_ACCESSIBLE (accessible)->widget) - return -1; - - day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget); - - child_num += day_view->long_events->len; - - for (day = 0; day < day_view->days_shown; day++) { - child_num += day_view->events[day]->len; - } - - /* "+1" for the main item */ - return child_num + 1; -} - -static AtkObject * -ea_day_view_ref_child (AtkObject *accessible, gint index) -{ - EDayView *day_view; - gint child_num; - gint day; - AtkObject *atk_object = NULL; - EDayViewEvent *event = NULL; - - g_return_val_if_fail (EA_IS_DAY_VIEW (accessible), NULL); - - child_num = atk_object_get_n_accessible_children (accessible); - if (child_num <= 0 || index < 0 || index >= child_num) - return NULL; - - if (!GTK_ACCESSIBLE (accessible)->widget) - return NULL; - day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget); - - if (index == 0) { - /* index == 0 is the main item */ - atk_object = atk_gobject_accessible_for_object (G_OBJECT (day_view->main_canvas_item)); - g_object_ref (atk_object); - } - else { - --index; - /* a long event */ - if (index < day_view->long_events->len) { - event = &g_array_index (day_view->long_events, - EDayViewEvent, index); - } - else { - index -= day_view->long_events->len; - day = 0; - while (index >= day_view->events[day]->len) { - index -= day_view->events[day]->len; - ++day; - } - - event = &g_array_index (day_view->events[day], - EDayViewEvent, index); - } - if (event && event->canvas_item) { - /* Not use atk_gobject_accessible_for_object here, - * we need to do special thing here - */ - atk_object = ea_calendar_helpers_get_accessible_for (event->canvas_item); - g_object_ref (atk_object); - } - } - return atk_object; -} diff --git a/a11y/calendar/ea-day-view.h b/a11y/calendar/ea-day-view.h deleted file mode 100644 index 5c4773d048..0000000000 --- a/a11y/calendar/ea-day-view.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_DAY_VIEW_H__ -#define __EA_DAY_VIEW_H__ - -#include "ea-cal-view.h" -#include "e-day-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define EA_TYPE_DAY_VIEW (ea_day_view_get_type ()) -#define EA_DAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_DAY_VIEW, EaDayView)) -#define EA_DAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_DAY_VIEW, EaDayViewClass)) -#define EA_IS_DAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_DAY_VIEW)) -#define EA_IS_DAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_DAY_VIEW)) -#define EA_DAY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_DAY_VIEW, EaDayViewClass)) - -typedef struct _EaDayView EaDayView; -typedef struct _EaDayViewClass EaDayViewClass; - -struct _EaDayView -{ - EaCalView parent; -}; - -GType ea_day_view_get_type (void); - -struct _EaDayViewClass -{ - EaCalViewClass parent_class; -}; - -AtkObject* ea_day_view_new (GtkWidget *widget); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EA_DAY_VIEW_H__ */ diff --git a/a11y/calendar/ea-gnome-calendar.c b/a11y/calendar/ea-gnome-calendar.c deleted file mode 100644 index b6eee2699c..0000000000 --- a/a11y/calendar/ea-gnome-calendar.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-gnome-calendar.h" -#include "calendar-commands.h" -#include <string.h> -#include <gtk/gtk.h> -#include <libecal/e-cal-time-util.h> -#include <libedataserver/e-data-server-util.h> -#include <glib/gi18n.h> - -static void ea_gnome_calendar_class_init (EaGnomeCalendarClass *klass); - -static G_CONST_RETURN gchar* ea_gnome_calendar_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_gnome_calendar_get_description (AtkObject *accessible); -static gint ea_gnome_calendar_get_n_children (AtkObject* obj); -static AtkObject * ea_gnome_calendar_ref_child (AtkObject *obj, gint i); - -static void ea_gcal_switch_view_cb (GtkNotebook *widget, GtkNotebookPage *page, - guint index, gpointer data); -static void ea_gcal_dates_change_cb (GnomeCalendar *gcal, gpointer data); - -static gpointer parent_class = NULL; - -GType -ea_gnome_calendar_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaGnomeCalendarClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_gnome_calendar_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaGnomeCalendar), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (GailWidget, in this case) - */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - GTK_TYPE_WIDGET); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - type = g_type_register_static (derived_atk_type, - "EaGnomeCalendar", &tinfo, 0); - - } - - return type; -} - -static void -ea_gnome_calendar_class_init (EaGnomeCalendarClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_gnome_calendar_get_name; - class->get_description = ea_gnome_calendar_get_description; - - class->get_n_children = ea_gnome_calendar_get_n_children; - class->ref_child = ea_gnome_calendar_ref_child; -} - -AtkObject* -ea_gnome_calendar_new (GtkWidget *widget) -{ - GObject *object; - AtkObject *accessible; - GnomeCalendar *gcal; - GtkWidget *notebook; - - g_return_val_if_fail (GNOME_IS_CALENDAR (widget), NULL); - - object = g_object_new (EA_TYPE_GNOME_CALENDAR, NULL); - - accessible = ATK_OBJECT (object); - atk_object_initialize (accessible, widget); - - accessible->role = ATK_ROLE_FILLER; - - gcal = GNOME_CALENDAR (widget); - - /* listen on view type change - */ - g_signal_connect (widget, "dates_shown_changed", - G_CALLBACK (ea_gcal_dates_change_cb), - accessible); - notebook = gnome_calendar_get_view_notebook_widget (gcal); - if (notebook) { - g_signal_connect (notebook, "switch_page", - G_CALLBACK (ea_gcal_switch_view_cb), - accessible); - } - -#ifdef ACC_DEBUG - printf ("EvoAcc: ea-gnome-calendar created: %p\n", (void *)accessible); -#endif - - return accessible; -} - -const gchar * -ea_gnome_calendar_get_label_description (GnomeCalendar *gcal) -{ - icaltimezone *zone; - struct icaltimetype start_tt, end_tt; - time_t start_time, end_time; - struct tm start_tm, end_tm; - static char buffer[512]; - char end_buffer[256]; - GnomeCalendarViewType view; - - gnome_calendar_get_visible_time_range (gcal, &start_time, &end_time); - zone = gnome_calendar_get_timezone (gcal); - - start_tt = icaltime_from_timet_with_zone (start_time, FALSE, zone); - start_tm.tm_year = start_tt.year - 1900; - start_tm.tm_mon = start_tt.month - 1; - start_tm.tm_mday = start_tt.day; - start_tm.tm_hour = start_tt.hour; - start_tm.tm_min = start_tt.minute; - start_tm.tm_sec = start_tt.second; - start_tm.tm_isdst = -1; - start_tm.tm_wday = time_day_of_week (start_tt.day, start_tt.month - 1, - start_tt.year); - - /* Take one off end_time so we don't get an extra day. */ - end_tt = icaltime_from_timet_with_zone (end_time - 1, FALSE, zone); - end_tm.tm_year = end_tt.year - 1900; - end_tm.tm_mon = end_tt.month - 1; - end_tm.tm_mday = end_tt.day; - end_tm.tm_hour = end_tt.hour; - end_tm.tm_min = end_tt.minute; - end_tm.tm_sec = end_tt.second; - end_tm.tm_isdst = -1; - end_tm.tm_wday = time_day_of_week (end_tt.day, end_tt.month - 1, - end_tt.year); - - view = gnome_calendar_get_view (gcal); - - switch (view) { - case GNOME_CAL_DAY_VIEW: - case GNOME_CAL_WORK_WEEK_VIEW: - case GNOME_CAL_WEEK_VIEW: - if (start_tm.tm_year == end_tm.tm_year - && start_tm.tm_mon == end_tm.tm_mon - && start_tm.tm_mday == end_tm.tm_mday) { - e_utf8_strftime (buffer, sizeof (buffer), - _("%A %d %b %Y"), &start_tm); - } else if (start_tm.tm_year == end_tm.tm_year) { - e_utf8_strftime (buffer, sizeof (buffer), - _("%a %d %b"), &start_tm); - e_utf8_strftime (end_buffer, sizeof (end_buffer), - _("%a %d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } else { - e_utf8_strftime (buffer, sizeof (buffer), - _("%a %d %b %Y"), &start_tm); - e_utf8_strftime (end_buffer, sizeof (end_buffer), - _("%a %d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - break; - case GNOME_CAL_MONTH_VIEW: - case GNOME_CAL_LIST_VIEW: - if (start_tm.tm_year == end_tm.tm_year) { - if (start_tm.tm_mon == end_tm.tm_mon) { - if (start_tm.tm_mday == end_tm.tm_mday) { - buffer [0] = '\0'; - } else { - e_utf8_strftime (buffer, sizeof (buffer), - "%d", &start_tm); - strcat (buffer, " - "); - } - e_utf8_strftime (end_buffer, sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, end_buffer); - } else { - e_utf8_strftime (buffer, sizeof (buffer), - _("%d %b"), &start_tm); - e_utf8_strftime (end_buffer, sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - } else { - e_utf8_strftime (buffer, sizeof (buffer), - _("%d %b %Y"), &start_tm); - e_utf8_strftime (end_buffer, sizeof (end_buffer), - _("%d %b %Y"), &end_tm); - strcat (buffer, " - "); - strcat (buffer, end_buffer); - } - break; - default: - g_return_val_if_reached (NULL); - } - return buffer; -} - -static G_CONST_RETURN gchar* -ea_gnome_calendar_get_name (AtkObject *accessible) -{ - if (accessible->name) - return accessible->name; - return _("Gnome Calendar"); -} - -static G_CONST_RETURN gchar* -ea_gnome_calendar_get_description (AtkObject *accessible) -{ - if (accessible->description) - return accessible->description; - return _("Gnome Calendar"); -} - -static gint -ea_gnome_calendar_get_n_children (AtkObject* obj) -{ - g_return_val_if_fail (EA_IS_GNOME_CALENDAR (obj), 0); - - if (!GTK_ACCESSIBLE (obj)->widget) - return -1; - return 4; -} - -static AtkObject * -ea_gnome_calendar_ref_child (AtkObject *obj, gint i) -{ - AtkObject * child = NULL; - GnomeCalendar * calendarWidget; - GtkWidget *childWidget; - - g_return_val_if_fail (EA_IS_GNOME_CALENDAR (obj), NULL); - /* valid child index range is [0-3] */ - if (i < 0 || i >3 ) - return NULL; - - if (!GTK_ACCESSIBLE (obj)->widget) - return NULL; - calendarWidget = GNOME_CALENDAR (GTK_ACCESSIBLE (obj)->widget); - - switch (i) { - case 0: - /* for the search bar */ - childWidget = gnome_calendar_get_search_bar_widget (calendarWidget); - child = gtk_widget_get_accessible (childWidget); - atk_object_set_parent (child, obj); - atk_object_set_name (child, _("search bar")); - atk_object_set_description (child, _("evolution calendar search bar")); - break; - case 1: - /* for the day/week view */ - childWidget = gnome_calendar_get_current_view_widget (calendarWidget); - child = gtk_widget_get_accessible (childWidget); - atk_object_set_parent (child, obj); - break; - case 2: - /* for calendar */ - childWidget = gnome_calendar_get_e_calendar_widget (calendarWidget); - child = gtk_widget_get_accessible (childWidget); - break; - case 3: - /* for todo list */ - childWidget = GTK_WIDGET (gnome_calendar_get_task_pad (calendarWidget)); - child = gtk_widget_get_accessible (childWidget); - break; - default: - break; - } - if (child) - g_object_ref(child); - return child; -} - -static void -ea_gcal_switch_view_cb (GtkNotebook *widget, GtkNotebookPage *page, - guint index, gpointer data) -{ - GtkWidget *new_widget; - - new_widget = gtk_notebook_get_nth_page (widget, index); - - /* views are always the second child in gnome calendar - */ - if (new_widget) - g_signal_emit_by_name (G_OBJECT(data), "children_changed::add", - 1, gtk_widget_get_accessible (new_widget), NULL); - -#ifdef ACC_DEBUG - printf ("AccDebug: view switch to widget %p (index=%d) \n", - (void *)new_widget, index); -#endif -} - -static void -ea_gcal_dates_change_cb (GnomeCalendar *gcal, gpointer data) -{ - const gchar *new_name; - - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (data); - g_return_if_fail (EA_IS_GNOME_CALENDAR (data)); - - new_name = ea_gnome_calendar_get_label_description (gcal); - atk_object_set_name (ATK_OBJECT(data), new_name); - g_signal_emit_by_name (data, "visible_data_changed"); - -#ifdef ACC_DEBUG - printf ("AccDebug: calendar dates changed, label=%s\n", new_name); -#endif -} diff --git a/a11y/calendar/ea-gnome-calendar.h b/a11y/calendar/ea-gnome-calendar.h deleted file mode 100644 index 50c43072af..0000000000 --- a/a11y/calendar/ea-gnome-calendar.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_GNOME_CALENDAR_H__ -#define __EA_GNOME_CALENDAR_H__ - -#include <gtk/gtk.h> -#include "gnome-cal.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define EA_TYPE_GNOME_CALENDAR (ea_gnome_calendar_get_type ()) -#define EA_GNOME_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_GNOME_CALENDAR, EaGnomeCalendar)) -#define EA_GNOME_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_GNOME_CALENDAR, EaGnomeCalendarClass)) -#define EA_IS_GNOME_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_GNOME_CALENDAR)) -#define EA_IS_GNOME_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_GNOME_CALENDAR)) -#define EA_GNOME_CALENDAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_GNOME_CALENDAR, EaGnomeCalendarClass)) - -typedef struct _EaGnomeCalendar EaGnomeCalendar; -typedef struct _EaGnomeCalendarClass EaGnomeCalendarClass; - -struct _EaGnomeCalendar -{ - GtkAccessible parent; -}; - -GType ea_gnome_calendar_get_type (void); - -struct _EaGnomeCalendarClass -{ - GtkAccessibleClass parent_class; -}; - -AtkObject* ea_gnome_calendar_new (GtkWidget *widget); - -const gchar * ea_gnome_calendar_get_label_description (GnomeCalendar *gcal); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __EA_GNOME_CALENDAR_H__ */ diff --git a/a11y/calendar/ea-jump-button.c b/a11y/calendar/ea-jump-button.c deleted file mode 100644 index cfe8e32cbb..0000000000 --- a/a11y/calendar/ea-jump-button.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yang Wu <yang.wu@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-jump-button.h" -#include "ea-calendar-helpers.h" -#include "ea-week-view.h" -#include "e-week-view.h" -#include <libgnomecanvas/gnome-canvas.h> -#include <glib/gi18n.h> - -static void ea_jump_button_class_init (EaJumpButtonClass *klass); - -static G_CONST_RETURN gchar* ea_jump_button_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_jump_button_get_description (AtkObject *accessible); - -/* action interface */ -static void atk_action_interface_init (AtkActionIface *iface); -static gboolean jump_button_do_action (AtkAction *action, - gint i); -static gint jump_button_get_n_actions (AtkAction *action); -static G_CONST_RETURN gchar* jump_button_get_keybinding (AtkAction *action, - gint i); - -static gpointer parent_class = NULL; - -GType -ea_jump_button_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaJumpButtonClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_jump_button_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaJumpButton), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - static const GInterfaceInfo atk_action_info = - { - (GInterfaceInitFunc) atk_action_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (atk object for GNOME_TYPE_CANVAS_ITEM, in this case) - */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - GNOME_TYPE_CANVAS_ITEM); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - /* we inherit the component and other interfaces from GNOME_TYPE_CANVAS_ITEM */ - type = g_type_register_static (derived_atk_type, - "EaJumpButton", &tinfo, 0); - - g_type_add_interface_static (type, ATK_TYPE_ACTION, - &atk_action_info); - } - - return type; -} - -static void -ea_jump_button_class_init (EaJumpButtonClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_jump_button_get_name; - class->get_description = ea_jump_button_get_description; -} - -AtkObject* -ea_jump_button_new (GObject *obj) -{ - AtkObject *atk_obj = NULL; - GObject *target_obj; - - g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (obj), NULL); - - target_obj = obj; - atk_obj = g_object_get_data (target_obj, "accessible-object"); - - if (!atk_obj) { - static AtkRole event_role = ATK_ROLE_INVALID; - atk_obj = ATK_OBJECT (g_object_new (EA_TYPE_JUMP_BUTTON, - NULL)); - atk_object_initialize (atk_obj, target_obj); - if (event_role == ATK_ROLE_INVALID) - event_role = atk_role_register ("Jump Button"); - atk_obj->role = event_role; - } - - /* the registered factory for GNOME_TYPE_CANVAS_ITEM is cannot create a EaJumpbutton, - * we should save the EaJumpbutton object in it. - */ - g_object_set_data (obj, "accessible-object", atk_obj); - - return atk_obj; -} - -static G_CONST_RETURN gchar* -ea_jump_button_get_name (AtkObject *accessible) -{ - g_return_val_if_fail (EA_IS_JUMP_BUTTON (accessible), NULL); - - if (accessible->name) - return accessible->name; - return _("Jump button"); -} - -static G_CONST_RETURN gchar* -ea_jump_button_get_description (AtkObject *accessible) -{ - if (accessible->description) - return accessible->description; - - return _("Click here, you can find more events."); -} - -static void -atk_action_interface_init (AtkActionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->do_action = jump_button_do_action; - iface->get_n_actions = jump_button_get_n_actions; - iface->get_keybinding = jump_button_get_keybinding; -} - -static gboolean -jump_button_do_action (AtkAction *action, - gint i) -{ - gboolean return_value = TRUE; - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - GnomeCanvasItem *item; - ECalendarView *cal_view; - EWeekView *week_view; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (action); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - item = GNOME_CANVAS_ITEM (g_obj); - cal_view = ea_calendar_helpers_get_cal_view_from (GNOME_CANVAS_ITEM (item)); - week_view = E_WEEK_VIEW (cal_view); - - switch (i) - { - case 0: - e_week_view_jump_to_button_item (week_view, GNOME_CANVAS_ITEM (item)); - break; - default: - return_value = FALSE; - break; - } - return return_value; -} - -static gint -jump_button_get_n_actions (AtkAction *action) -{ - return 1; -} - -static G_CONST_RETURN gchar* -jump_button_get_keybinding (AtkAction *action, - gint i) -{ - gchar *return_value = NULL; - - switch (i) - { - case 0: - { - return_value = "space or enter"; - break; - } - default: - break; - } - return return_value; -} diff --git a/a11y/calendar/ea-jump-button.h b/a11y/calendar/ea-jump-button.h deleted file mode 100644 index 4fbd92022f..0000000000 --- a/a11y/calendar/ea-jump-button.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yang Wu <yang.wu@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_JUMP_BUTTON_H__ -#define __EA_JUMP_BUTTON_H__ - -#include <atk/atkgobjectaccessible.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define EA_TYPE_JUMP_BUTTON (ea_jump_button_get_type ()) -#define EA_JUMP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_JUMP_BUTTON, EaJumpButton)) -#define EA_JUMP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_JUMP_BUTTON, EaJumpButtonClass)) -#define EA_IS_JUMP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_JUMP_BUTTON)) -#define EA_IS_JUMP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_JUMP_BUTTON)) -#define EA_JUMP_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_JUMP_BUTTON, EaJumpButtonClass)) - -typedef struct _EaJumpButton EaJumpButton; -typedef struct _EaJumpButtonClass EaJumpButtonClass; - -struct _EaJumpButton -{ - AtkGObjectAccessible parent; -}; - -GType ea_jump_button_get_type (void); - -struct _EaJumpButtonClass -{ - AtkGObjectAccessibleClass parent_class; -}; - -AtkObject *ea_jump_button_new (GObject *obj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __EA_JUMP_BUTTON_H__ */ diff --git a/a11y/calendar/ea-week-view-cell.c b/a11y/calendar/ea-week-view-cell.c deleted file mode 100644 index 1d1b4d004f..0000000000 --- a/a11y/calendar/ea-week-view-cell.c +++ /dev/null @@ -1,478 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * Yang Wu <Yang.Wu@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-week-view-cell.h" -#include "ea-week-view-main-item.h" -#include "ea-factory.h" - -/* EWeekViewCell */ - -static void e_week_view_cell_class_init (EWeekViewCellClass *class); - -EA_FACTORY_GOBJECT (EA_TYPE_WEEK_VIEW_CELL, ea_week_view_cell, ea_week_view_cell_new) - -GType -e_week_view_cell_get_type (void) -{ - static GType type = 0; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EWeekViewCellClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) e_week_view_cell_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EWeekViewCell), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - type = g_type_register_static (G_TYPE_OBJECT, - "EWeekViewCell", &tinfo, 0); - } - - return type; -} - -static void -e_week_view_cell_class_init (EWeekViewCellClass *class) -{ - EA_SET_FACTORY (e_week_view_cell_get_type (), ea_week_view_cell); -} - -EWeekViewCell * -e_week_view_cell_new (EWeekView *week_view, gint row, gint column) -{ - GObject *object; - EWeekViewCell *cell; - - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), NULL); - - object = g_object_new (E_TYPE_WEEK_VIEW_CELL, NULL); - cell = E_WEEK_VIEW_CELL (object); - cell->week_view = week_view; - cell->row = row; - cell->column = column; - -#ifdef ACC_DEBUG - printf ("EvoAcc: e_week_view_cell created %p\n", (void *)cell); -#endif - - return cell; -} - -/* EaWeekViewCell */ - -static void ea_week_view_cell_class_init (EaWeekViewCellClass *klass); - -static G_CONST_RETURN gchar* ea_week_view_cell_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_week_view_cell_get_description (AtkObject *accessible); -static AtkStateSet* ea_week_view_cell_ref_state_set (AtkObject *obj); -static AtkObject * ea_week_view_cell_get_parent (AtkObject *accessible); -static gint ea_week_view_cell_get_index_in_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 gboolean component_interface_grab_focus (AtkComponent *component); - -static gpointer parent_class = NULL; - -#ifdef ACC_DEBUG -static gint n_ea_week_view_cell_created = 0, n_ea_week_view_cell_destroyed = 0; -static void ea_week_view_cell_finalize (GObject *object); -#endif - -GType -ea_week_view_cell_get_type (void) -{ - static GType type = 0; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaWeekViewCellClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_week_view_cell_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaWeekViewCell), /* 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, - "EaWeekViewCell", &tinfo, 0); - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, - &atk_component_info); - - } - - return type; -} - -static void -ea_week_view_cell_class_init (EaWeekViewCellClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - -#ifdef ACC_DEBUG - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - gobject_class->finalize = ea_week_view_cell_finalize; -#endif - - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_week_view_cell_get_name; - class->get_description = ea_week_view_cell_get_description; - class->ref_state_set = ea_week_view_cell_ref_state_set; - - class->get_parent = ea_week_view_cell_get_parent; - class->get_index_in_parent = ea_week_view_cell_get_index_in_parent; - -} - -AtkObject* -ea_week_view_cell_new (GObject *obj) -{ - gpointer object; - AtkObject *atk_object; - - g_return_val_if_fail (E_IS_WEEK_VIEW_CELL (obj), NULL); - object = g_object_new (EA_TYPE_WEEK_VIEW_CELL, NULL); - atk_object = ATK_OBJECT (object); - atk_object_initialize (atk_object, obj); - atk_object->role = ATK_ROLE_UNKNOWN; - -#ifdef ACC_DEBUG - ++n_ea_week_view_cell_created; - printf ("ACC_DEBUG: n_ea_week_view_cell_created = %d\n", - n_ea_week_view_cell_created); -#endif - return atk_object; -} - -#ifdef ACC_DEBUG -static void ea_week_view_cell_finalize (GObject *object) -{ - G_OBJECT_CLASS (parent_class)->finalize (object); - - ++n_ea_week_view_cell_destroyed; - printf ("ACC_DEBUG: n_ea_week_view_cell_destroyed = %d\n", - n_ea_week_view_cell_destroyed); -} -#endif - -static G_CONST_RETURN gchar* -ea_week_view_cell_get_name (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewCell *cell; - - g_return_val_if_fail (EA_IS_WEEK_VIEW_CELL (accessible), NULL); - - if (!accessible->name) { - AtkObject *ea_main_item; - GnomeCanvasItem *main_item; - gchar *new_name = g_strdup (""); - const gchar *row_label, *column_label; - gint new_column, new_row; - gint start_day; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - cell = E_WEEK_VIEW_CELL (g_obj); - main_item = cell->week_view->main_canvas_item; - ea_main_item = atk_gobject_accessible_for_object (G_OBJECT (main_item)); - - start_day = cell->week_view->display_start_day; - if (cell->column + start_day >= 7) { - new_column = cell->column + start_day - 7; - new_row = cell->row + 1; - } else { - new_column = cell->column + start_day; - new_row = cell->row; - } - - column_label = atk_table_get_column_description (ATK_TABLE (ea_main_item), - new_column); - row_label = atk_table_get_row_description (ATK_TABLE (ea_main_item), - new_row); - new_name = g_strconcat (column_label, " ", row_label, NULL); - ATK_OBJECT_CLASS (parent_class)->set_name (accessible, new_name); - g_free (new_name); - } - return accessible->name; -} - -static G_CONST_RETURN gchar* -ea_week_view_cell_get_description (AtkObject *accessible) -{ - return ea_week_view_cell_get_name (accessible); -} - -static AtkStateSet* -ea_week_view_cell_ref_state_set (AtkObject *obj) -{ - AtkStateSet *state_set; - GObject *g_obj; - AtkObject *parent; - gint x, y, width, height; - gint parent_x, parent_y, parent_width, parent_height; - - state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj); - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(obj)); - if (!g_obj) - return state_set; - - atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE); - - parent = atk_object_get_parent (obj); - atk_component_get_extents (ATK_COMPONENT (obj), &x, &y, - &width, &height, ATK_XY_WINDOW); - atk_component_get_extents (ATK_COMPONENT (parent), &parent_x, &parent_y, - &parent_width, &parent_height, ATK_XY_WINDOW); - - - if (x + width < parent_x || x > parent_x + parent_width || - y + height < parent_y || y > parent_y + parent_height) - /* the cell is out of the main canvas */ - ; - else - atk_state_set_add_state (state_set, ATK_STATE_VISIBLE); - - return state_set; -} - -static AtkObject * -ea_week_view_cell_get_parent (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewCell *cell; - - g_return_val_if_fail (EA_IS_WEEK_VIEW_CELL (accessible), NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - cell = E_WEEK_VIEW_CELL (g_obj); - return atk_gobject_accessible_for_object (G_OBJECT (cell->week_view->main_canvas_item)); -} - -static gint -ea_week_view_cell_get_index_in_parent (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewCell *cell; - AtkObject *parent; - - g_return_val_if_fail (EA_IS_WEEK_VIEW_CELL (accessible), -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - cell = E_WEEK_VIEW_CELL (g_obj); - parent = atk_object_get_parent (accessible); - return atk_table_get_index_at (ATK_TABLE (parent), - cell->row, cell->column); -} - -/* Atk Component Interface */ - -static void -atk_component_interface_init (AtkComponentIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->get_extents = component_interface_get_extents; - iface->grab_focus = component_interface_grab_focus; -} - -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; - EWeekViewCell *cell; - EWeekView *week_view; - GtkWidget *main_canvas; - gint week_view_width, week_view_height; - gint scroll_x, scroll_y; - gint start_day; - - *x = *y = *width = *height = 0; - - g_return_if_fail (EA_IS_WEEK_VIEW_CELL (component)); - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component)); - if (!g_obj) - /* defunct object*/ - return; - - cell = E_WEEK_VIEW_CELL (g_obj); - week_view = cell->week_view; - main_canvas = cell->week_view->main_canvas; - - atk_obj = atk_gobject_accessible_for_object (G_OBJECT (main_canvas)); - atk_component_get_extents (ATK_COMPONENT (atk_obj), - x, y, - &week_view_width, &week_view_height, - coord_type); - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (week_view->main_canvas), - &scroll_x, &scroll_y); - start_day = week_view->display_start_day; - if (week_view->multi_week_view) { - if (week_view->compress_weekend && (cell->column == (5 - start_day))) { - *height = week_view->row_heights[cell->row*2]; - *width = week_view->col_widths[cell->column]; - *x += week_view->col_offsets[cell->column] - scroll_x; - *y += week_view->row_offsets[cell->row*2]- scroll_y; - } else if (week_view->compress_weekend && (cell->column == (6 - start_day))) { - *height = week_view->row_heights[cell->row*2]; - *width = week_view->col_widths[cell->column - 1]; - *x += week_view->col_offsets[cell->column - 1]- scroll_x; - *y += week_view->row_offsets[cell->row*2 + 1]- scroll_y; - } else if (week_view->compress_weekend && (cell->column > (6 - start_day))){ - *height = week_view->row_heights[cell->row*2]*2; - *width = week_view->col_widths[cell->column - 1]; - *x += week_view->col_offsets[cell->column - 1] - scroll_x; - *y += week_view->row_offsets[cell->row*2]- scroll_y; - } else { - *height = week_view->row_heights[cell->row*2]*2; - *width = week_view->col_widths[cell->column]; - *x += week_view->col_offsets[cell->column] - scroll_x; - *y += week_view->row_offsets[cell->row*2]- scroll_y; - } - } else { - if (start_day < 3) { - if (cell->column < 3) { - *height = week_view->row_heights[cell->column*2]*2; - *width = week_view->col_widths[0]; - *x += week_view->col_offsets[0] - scroll_x; - *y += week_view->row_offsets[cell->column*2]- scroll_y; - } else { - if (cell->column == 5 - start_day) { - *height = week_view->row_heights[(cell->column - 3)*2]; - *width = week_view->col_widths[1]; - *x += week_view->col_offsets[1] - scroll_x; - *y += week_view->row_offsets[(cell->column - 3)*2]- scroll_y; - } else if (cell->column == 6 - start_day) { - *height = week_view->row_heights[(cell->column - 4)*2]; - *width = week_view->col_widths[1]; - *x += week_view->col_offsets[1] - scroll_x; - *y += week_view->row_offsets[(cell->column - 3)*2 - 1]- scroll_y; - } else if (cell->column > 6 - start_day) { - *height = week_view->row_heights[(cell->column - 4)*2]*2; - *width = week_view->col_widths[1]; - *x += week_view->col_offsets[1] - scroll_x; - *y += week_view->row_offsets[(cell->column - 4)*2]- scroll_y; - } else { - *height = week_view->row_heights[(cell->column - 3)*2]*2; - *width = week_view->col_widths[1]; - *x += week_view->col_offsets[1] - scroll_x; - *y += week_view->row_offsets[(cell->column - 3)*2]- scroll_y; - } - } - } else if (cell->column < 4) { - if (cell->column == 5 - start_day) { - *height = week_view->row_heights[cell->column*2]; - *width = week_view->col_widths[0]; - *x += week_view->col_offsets[0] - scroll_x; - *y += week_view->row_offsets[cell->column*2]- scroll_y; - } else if (cell->column == 6 - start_day) { - *height = week_view->row_heights[(cell->column - 1)*2]; - *width = week_view->col_widths[0]; - *x += week_view->col_offsets[0] - scroll_x; - *y += week_view->row_offsets[cell->column*2 - 1]- scroll_y; - } else if (cell->column > 6 - start_day) { - *height = week_view->row_heights[(cell->column - 1)*2]*2; - *width = week_view->col_widths[0]; - *x += week_view->col_offsets[0] - scroll_x; - *y += week_view->row_offsets[(cell->column - 1)*2]- scroll_y; - } else { - *height = week_view->row_heights[(cell->column)*2]*2; - *width = week_view->col_widths[0]; - *x += week_view->col_offsets[0] - scroll_x; - *y += week_view->row_offsets[cell->column*2]- scroll_y; - } - } else { - *height = week_view->row_heights[(cell->column - 4)*2]*2; - *width = week_view->col_widths[1]; - *x += week_view->col_offsets[1] - scroll_x; - *y += week_view->row_offsets[(cell->column - 4)*2]- scroll_y; - } - } -} - -static gboolean -component_interface_grab_focus (AtkComponent *comp) -{ - GObject *g_obj; - EWeekViewCell *cell; - EWeekView *week_view; - GtkWidget *toplevel; - - g_return_val_if_fail (EA_IS_WEEK_VIEW_CELL (comp), FALSE); - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (comp)); - if (!g_obj) - return FALSE; - - cell = E_WEEK_VIEW_CELL (g_obj); - week_view = cell->week_view; - - week_view->selection_start_day = cell->row * 7 + cell->column; - week_view->selection_end_day = cell->row * 7 + cell->column; - gtk_widget_queue_draw (week_view->main_canvas); - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (week_view)); - if (GTK_WIDGET_TOPLEVEL (toplevel)) - gtk_window_present (GTK_WINDOW (toplevel)); - - return TRUE; -} diff --git a/a11y/calendar/ea-week-view-cell.h b/a11y/calendar/ea-week-view-cell.h deleted file mode 100644 index b09d7d1789..0000000000 --- a/a11y/calendar/ea-week-view-cell.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * Yang Wu <yang.wu@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_WEEK_VIEW_CELL_H__ -#define __EA_WEEK_VIEW_CELL_H__ - -#include <atk/atkgobjectaccessible.h> -#include "e-week-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define E_TYPE_WEEK_VIEW_CELL (e_week_view_cell_get_type ()) -#define E_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_WEEK_VIEW_CELL, EWeekViewCell)) -#define E_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_WEEK_VIEW_CELL, EWeekViewCellClass)) -#define E_IS_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_WEEK_VIEW_CELL)) -#define E_IS_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_WEEK_VIEW_CELL)) -#define E_WEEK_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_WEEK_VIEW_CELL, EWeekViewCellClass)) - -typedef struct _EWeekViewCell EWeekViewCell; -typedef struct _EWeekViewCellClass EWeekViewCellClass; - -struct _EWeekViewCell -{ - GObject parent; - EWeekView *week_view; - gint row; - gint column; -}; - -GType e_week_view_cell_get_type (void); - -struct _EWeekViewCellClass -{ - GObjectClass parent_class; -}; - -EWeekViewCell * e_week_view_cell_new (EWeekView *week_view, gint row, gint column); - -#define EA_TYPE_WEEK_VIEW_CELL (ea_week_view_cell_get_type ()) -#define EA_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_WEEK_VIEW_CELL, EaWeekViewCell)) -#define EA_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_WEEK_VIEW_CELL, EaWeekViewCellClass)) -#define EA_IS_WEEK_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_WEEK_VIEW_CELL)) -#define EA_IS_WEEK_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_WEEK_VIEW_CELL)) -#define EA_WEEK_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_WEEK_VIEW_CELL, EaWeekViewCellClass)) - -typedef struct _EaWeekViewCell EaWeekViewCell; -typedef struct _EaWeekViewCellClass EaWeekViewCellClass; - -struct _EaWeekViewCell -{ - AtkGObjectAccessible parent; -}; - -GType ea_week_view_cell_get_type (void); - -struct _EaWeekViewCellClass -{ - AtkGObjectAccessibleClass parent_class; -}; - -AtkObject* ea_week_view_cell_new (GObject *gobj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EA_WEEK_VIEW_CELL_H__ */ diff --git a/a11y/calendar/ea-week-view-main-item.c b/a11y/calendar/ea-week-view-main-item.c deleted file mode 100644 index 5bfb73306b..0000000000 --- a/a11y/calendar/ea-week-view-main-item.c +++ /dev/null @@ -1,1247 +0,0 @@ -/* - * Evolution Accessibility: ea-week-view-main-item.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-week-view-main-item.h" -#include "ea-week-view.h" -#include "ea-week-view-cell.h" -#include "ea-cell-table.h" -#include <glib/gi18n.h> - -/* EaWeekViewMainItem */ -static void ea_week_view_main_item_class_init (EaWeekViewMainItemClass *klass); - -static void ea_week_view_main_item_finalize (GObject *object); -static G_CONST_RETURN gchar* ea_week_view_main_item_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_week_view_main_item_get_description (AtkObject *accessible); - -static gint ea_week_view_main_item_get_n_children (AtkObject *obj); -static AtkObject* ea_week_view_main_item_ref_child (AtkObject *obj, - gint i); -static AtkObject * ea_week_view_main_item_get_parent (AtkObject *accessible); -static gint ea_week_view_main_item_get_index_in_parent (AtkObject *accessible); - -/* callbacks */ -static void ea_week_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data); -static void ea_week_view_main_item_time_change_cb (EWeekView *week_view, gpointer data); - -/* 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); - -/* atk table interface */ -static void atk_table_interface_init (AtkTableIface *iface); -static gint table_interface_get_index_at (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_column_at_index (AtkTable *table, - gint index); -static gint table_interface_get_row_at_index (AtkTable *table, - gint index); -static AtkObject* table_interface_ref_at (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_n_rows (AtkTable *table); -static gint table_interface_get_n_columns (AtkTable *table); -static gint table_interface_get_column_extent_at (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_row_extent_at (AtkTable *table, - gint row, - gint column); - -static gboolean table_interface_is_row_selected (AtkTable *table, - gint row); -static gboolean table_interface_is_column_selected (AtkTable *table, - gint row); -static gboolean table_interface_is_selected (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_selected_rows (AtkTable *table, - gint **rows_selected); -static gint table_interface_get_selected_columns (AtkTable *table, - gint **columns_selected); -static gboolean table_interface_add_row_selection (AtkTable *table, gint row); -static gboolean table_interface_remove_row_selection (AtkTable *table, - gint row); -static gboolean table_interface_add_column_selection (AtkTable *table, - gint column); -static gboolean table_interface_remove_column_selection (AtkTable *table, - gint column); -static AtkObject* table_interface_get_row_header (AtkTable *table, gint row); -static AtkObject* table_interface_get_column_header (AtkTable *table, - gint in_col); -static AtkObject* table_interface_get_caption (AtkTable *table); - -static G_CONST_RETURN gchar* -table_interface_get_column_description (AtkTable *table, gint in_col); - -static G_CONST_RETURN gchar* -table_interface_get_row_description (AtkTable *table, gint row); - -static AtkObject* table_interface_get_summary (AtkTable *table); - -/* atk selection interface */ -static void atk_selection_interface_init (AtkSelectionIface *iface); -static gboolean selection_interface_add_selection (AtkSelection *selection, - gint i); -static gboolean selection_interface_clear_selection (AtkSelection *selection); -static AtkObject* selection_interface_ref_selection (AtkSelection *selection, - gint i); -static gint selection_interface_get_selection_count (AtkSelection *selection); -static gboolean selection_interface_is_child_selected (AtkSelection *selection, - gint i); - -/* helpers */ -static EaCellTable * -ea_week_view_main_item_get_cell_data (EaWeekViewMainItem *ea_main_item); - -static void -ea_week_view_main_item_destory_cell_data (EaWeekViewMainItem *ea_main_item); - -static gint -ea_week_view_main_item_get_child_index_at (EaWeekViewMainItem *ea_main_item, - gint row, gint column); -static gint -ea_week_view_main_item_get_row_at_index (EaWeekViewMainItem *ea_main_item, - gint index); -static gint -ea_week_view_main_item_get_column_at_index (EaWeekViewMainItem *ea_main_item, - gint index); -static gint -ea_week_view_main_item_get_row_label (EaWeekViewMainItem *ea_main_item, - gint row, gchar *buffer, - gint buffer_size); - -#ifdef ACC_DEBUG -static gint n_ea_week_view_main_item_created = 0; -static gint n_ea_week_view_main_item_destroyed = 0; -#endif - -static gpointer parent_class = NULL; - -GType -ea_week_view_main_item_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaWeekViewMainItemClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_week_view_main_item_class_init, - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaWeekViewMainItem), /* 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 - }; - - static const GInterfaceInfo atk_table_info = { - (GInterfaceInitFunc) atk_table_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - static const GInterfaceInfo atk_selection_info = { - (GInterfaceInitFunc) atk_selection_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (GailCanvasItem, in this case) - * - */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - e_week_view_main_item_get_type()); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - type = g_type_register_static (derived_atk_type, - "EaWeekViewMainItem", &tinfo, 0); - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, - &atk_component_info); - g_type_add_interface_static (type, ATK_TYPE_TABLE, - &atk_table_info); - g_type_add_interface_static (type, ATK_TYPE_SELECTION, - &atk_selection_info); - } - - return type; -} - -static void -ea_week_view_main_item_class_init (EaWeekViewMainItemClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - - gobject_class->finalize = ea_week_view_main_item_finalize; - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_week_view_main_item_get_name; - class->get_description = ea_week_view_main_item_get_description; - - class->get_n_children = ea_week_view_main_item_get_n_children; - class->ref_child = ea_week_view_main_item_ref_child; - class->get_parent = ea_week_view_main_item_get_parent; - class->get_index_in_parent = ea_week_view_main_item_get_index_in_parent; -} - -AtkObject* -ea_week_view_main_item_new (GObject *obj) -{ - AtkObject *accessible; - GnomeCalendar *gcal; - EWeekViewMainItem *main_item; - - g_return_val_if_fail (E_IS_WEEK_VIEW_MAIN_ITEM (obj), NULL); - - accessible = ATK_OBJECT (g_object_new (EA_TYPE_WEEK_VIEW_MAIN_ITEM, - NULL)); - - atk_object_initialize (accessible, obj); - accessible->role = ATK_ROLE_TABLE; - -#ifdef ACC_DEBUG - ++n_ea_week_view_main_item_created; - printf ("ACC_DEBUG: n_ea_week_view_main_item_created = %d\n", - n_ea_week_view_main_item_created); -#endif - main_item = E_WEEK_VIEW_MAIN_ITEM (obj); - g_signal_connect (main_item->week_view, "selected_time_changed", - G_CALLBACK (ea_week_view_main_item_time_change_cb), - accessible); - - /* listen for date changes of calendar */ - gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (main_item->week_view)); - if (gcal) - g_signal_connect (gcal, "dates_shown_changed", - G_CALLBACK (ea_week_view_main_item_dates_change_cb), - accessible); - - return accessible; -} - -static void -ea_week_view_main_item_finalize (GObject *object) -{ - EaWeekViewMainItem *ea_main_item; - - g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (object)); - - ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (object); - - /* Free the allocated cell data */ - ea_week_view_main_item_destory_cell_data (ea_main_item); - - G_OBJECT_CLASS (parent_class)->finalize (object); -#ifdef ACC_DEBUG - ++n_ea_week_view_main_item_destroyed; - printf ("ACC_DEBUG: n_ea_week_view_main_item_destroyed = %d\n", - n_ea_week_view_main_item_destroyed); -#endif -} - -static G_CONST_RETURN gchar* -ea_week_view_main_item_get_name (AtkObject *accessible) -{ - AtkObject *parent; - g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL); - parent = atk_object_get_parent (accessible); - return atk_object_get_name (parent); - -} - -static G_CONST_RETURN gchar* -ea_week_view_main_item_get_description (AtkObject *accessible) -{ - return _("a table to view and select the current time range"); -} - -static gint -ea_week_view_main_item_get_n_children (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - - g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - if (week_view->multi_week_view) - return 7 * week_view->weeks_shown; - else - return 7; -} - -static AtkObject * -ea_week_view_main_item_ref_child (AtkObject *accessible, gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - gint n_children; - EWeekViewCell *cell; - EaCellTable *cell_data; - EaWeekViewMainItem *ea_main_item; - - g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - n_children = ea_week_view_main_item_get_n_children (accessible); - if (index < 0 || index >= n_children) - return NULL; - - ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (accessible); - cell_data = ea_week_view_main_item_get_cell_data (ea_main_item); - if (!cell_data) - return NULL; - cell = ea_cell_table_get_cell_at_index (cell_data, index); - if (!cell) { - gint row, column; - - row = ea_week_view_main_item_get_row_at_index (ea_main_item, index); - column = ea_week_view_main_item_get_column_at_index (ea_main_item, index); - cell = e_week_view_cell_new (week_view, row, column); - ea_cell_table_set_cell_at_index (cell_data, index, cell); - g_object_unref (cell); - } - - return g_object_ref (atk_gobject_accessible_for_object (G_OBJECT(cell))); -} - -static AtkObject * -ea_week_view_main_item_get_parent (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - - g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - return gtk_widget_get_accessible (GTK_WIDGET (main_item->week_view)); -} - -static gint -ea_week_view_main_item_get_index_in_parent (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - - g_return_val_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (accessible), -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - /* always the first child of ea-week-view */ - return 0; -} - -/* callbacks */ - -static void -ea_week_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data) -{ - EaWeekViewMainItem *ea_main_item; - - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (data); - g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (data)); - - ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (data); - -#ifdef ACC_DEBUG - printf ("EvoAcc: ea_week_view_main_item update cb\n"); -#endif - - ea_week_view_main_item_destory_cell_data (ea_main_item); -} - -static void -ea_week_view_main_item_time_change_cb (EWeekView *week_view, gpointer data) -{ - EaWeekViewMainItem *ea_main_item; - AtkObject *item_cell = NULL; - - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - g_return_if_fail (data); - g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (data)); - - ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (data); - -#ifdef ACC_DEBUG - printf ("EvoAcc: ea_week_view_main_item time changed cb\n"); -#endif - /* only deal with the first selected child, for now */ - item_cell = atk_selection_ref_selection (ATK_SELECTION (ea_main_item), - 0); - if (item_cell) { - AtkStateSet *state_set; - state_set = atk_object_ref_state_set (item_cell); - atk_state_set_add_state (state_set, ATK_STATE_FOCUSED); - g_object_unref (state_set); - - g_signal_emit_by_name (ea_main_item, - "active-descendant-changed", - item_cell); - g_signal_emit_by_name (data, "selection_changed"); - atk_focus_tracker_notify (item_cell); - g_object_unref (item_cell); - } -} - -/* helpers */ - -static gint -ea_week_view_main_item_get_child_index_at (EaWeekViewMainItem *ea_main_item, - gint row, gint column) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - - g_return_val_if_fail (ea_main_item, -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - if (row >= 0 && row < week_view->weeks_shown && - column >= 0 && column < 7) - return row * 7 + column; - - return -1; -} - -static gint -ea_week_view_main_item_get_row_at_index (EaWeekViewMainItem *ea_main_item, - gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - gint n_children; - - g_return_val_if_fail (ea_main_item, -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - n_children = ea_week_view_main_item_get_n_children (ATK_OBJECT (ea_main_item)); - if (index >= 0 && index < n_children) - return index / 7; - return -1; -} - -static gint -ea_week_view_main_item_get_column_at_index (EaWeekViewMainItem *ea_main_item, - gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - gint n_children; - - g_return_val_if_fail (ea_main_item, -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - n_children = ea_week_view_main_item_get_n_children (ATK_OBJECT (ea_main_item)); - if (index >= 0 && index < n_children) - return index % 7; - return -1; -} - -static gint -ea_week_view_main_item_get_row_label (EaWeekViewMainItem *ea_main_item, - gint row, gchar *buffer, gint buffer_size) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - - g_return_val_if_fail (ea_main_item, 0); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return 0 ; - - return g_snprintf (buffer, buffer_size, "the %i week", - row + 1); - -} - -static EaCellTable * -ea_week_view_main_item_get_cell_data (EaWeekViewMainItem *ea_main_item) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaCellTable *cell_data; - - g_return_val_if_fail (ea_main_item, NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - cell_data = g_object_get_data (G_OBJECT(ea_main_item), - "ea-week-view-cell-table"); - if (!cell_data) { - cell_data = ea_cell_table_create (week_view->weeks_shown, 7, TRUE); - g_object_set_data (G_OBJECT(ea_main_item), - "ea-week-view-cell-table", cell_data); - } - return cell_data; -} - -static void -ea_week_view_main_item_destory_cell_data (EaWeekViewMainItem *ea_main_item) -{ - EaCellTable *cell_data; - - g_return_if_fail (ea_main_item); - - cell_data = g_object_get_data (G_OBJECT(ea_main_item), - "ea-week-view-cell-table"); - if (cell_data) { - g_object_set_data (G_OBJECT(ea_main_item), - "ea-week-view-cell-table", NULL); - ea_cell_table_destroy (cell_data); - } -} - -/* 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 *ea_canvas; - EWeekViewMainItem *main_item; - EWeekView *week_view; - - *x = *y = *width = *height = 0; - - g_return_if_fail (EA_IS_WEEK_VIEW_MAIN_ITEM (component)); - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(component)); - if (!g_obj) - /* defunct object*/ - return; - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - ea_canvas = gtk_widget_get_accessible (week_view->main_canvas); - atk_component_get_extents (ATK_COMPONENT (ea_canvas), x, y, - width, height, coord_type); -} - -/* atk table interface */ - -static void -atk_table_interface_init (AtkTableIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->ref_at = table_interface_ref_at; - - iface->get_n_rows = table_interface_get_n_rows; - iface->get_n_columns = table_interface_get_n_columns; - iface->get_index_at = table_interface_get_index_at; - iface->get_column_at_index = table_interface_get_column_at_index; - iface->get_row_at_index = table_interface_get_row_at_index; - iface->get_column_extent_at = table_interface_get_column_extent_at; - iface->get_row_extent_at = table_interface_get_row_extent_at; - - iface->is_selected = table_interface_is_selected; - iface->get_selected_rows = table_interface_get_selected_rows; - iface->get_selected_columns = table_interface_get_selected_columns; - iface->is_row_selected = table_interface_is_row_selected; - iface->is_column_selected = table_interface_is_column_selected; - iface->add_row_selection = table_interface_add_row_selection; - iface->remove_row_selection = table_interface_remove_row_selection; - iface->add_column_selection = table_interface_add_column_selection; - iface->remove_column_selection = table_interface_remove_column_selection; - - iface->get_row_header = table_interface_get_row_header; - iface->get_column_header = table_interface_get_column_header; - iface->get_caption = table_interface_get_caption; - iface->get_summary = table_interface_get_summary; - iface->get_row_description = table_interface_get_row_description; - iface->get_column_description = table_interface_get_column_description; -} - -static AtkObject* -table_interface_ref_at (AtkTable *table, - gint row, - gint column) -{ - gint index; - - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - index = ea_week_view_main_item_get_child_index_at (ea_main_item, - row, column); - return ea_week_view_main_item_ref_child (ATK_OBJECT (ea_main_item), index); -} - -static gint -table_interface_get_n_rows (AtkTable *table) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - return week_view->weeks_shown; -} - -static gint -table_interface_get_n_columns (AtkTable *table) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - return 7; -} - -static gint -table_interface_get_index_at (AtkTable *table, - gint row, - gint column) -{ - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - return ea_week_view_main_item_get_child_index_at (ea_main_item, - row, column); -} - -static gint -table_interface_get_column_at_index (AtkTable *table, - gint index) -{ - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - return ea_week_view_main_item_get_column_at_index (ea_main_item, index); -} - -static gint -table_interface_get_row_at_index (AtkTable *table, - gint index) -{ - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - return ea_week_view_main_item_get_row_at_index (ea_main_item, index); -} - -static gint -table_interface_get_column_extent_at (AtkTable *table, - gint row, - gint column) -{ - gint index; - gint width = 0, height = 0; - AtkObject *child; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - - index = ea_week_view_main_item_get_child_index_at (ea_main_item, - row, column); - child = atk_object_ref_accessible_child (ATK_OBJECT (ea_main_item), - index); - if (child) - atk_component_get_size (ATK_COMPONENT (child), - &width, &height); - - return width; -} - -static gint -table_interface_get_row_extent_at (AtkTable *table, - gint row, - gint column) -{ - gint index; - gint width = 0, height = 0; - AtkObject *child; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - - index = ea_week_view_main_item_get_child_index_at (ea_main_item, - row, column); - child = atk_object_ref_accessible_child (ATK_OBJECT (ea_main_item), - index); - if (child) - atk_component_get_size (ATK_COMPONENT (child), - &width, &height); - - return height; -} - -static gboolean -table_interface_is_row_selected (AtkTable *table, - gint row) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - if (week_view->selection_start_day == -1) - /* no selection */ - return FALSE; - if ((row < 0)&&(row + 1 > week_view->weeks_shown )) - return FALSE; - if (((week_view->selection_start_day < row*7)&&(week_view->selection_end_day<row*7)) - ||((week_view->selection_start_day > row*7+6)&&(week_view->selection_end_day > row*7+6))) - return FALSE; - else - return TRUE; -} - -static gboolean -table_interface_is_selected (AtkTable *table, - gint row, - gint column) -{ - return table_interface_is_row_selected (table, row) && table_interface_is_column_selected(table, column); -} - -static gboolean -table_interface_is_column_selected (AtkTable *table, - gint column) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - if ((column <0)||(column >6)) - return FALSE; - else { - gint i; - for (i=0;i<week_view->weeks_shown;i++) - if ((column + i*7>= week_view->selection_start_day ) && - (column + i*7<= week_view->selection_end_day)) - return TRUE; - return FALSE; - } -} - -static gint -table_interface_get_selected_rows (AtkTable *table, - gint **rows_selected) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - gint start_row = -1, n_rows = 0; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - if (week_view->selection_start_day == -1) - return 0; - - start_row = week_view->selection_start_day; - n_rows = week_view->selection_end_day - start_row + 1; - - if (n_rows > 0 && start_row != -1 && rows_selected) { - gint index; - - *rows_selected = (gint *) g_malloc (n_rows * sizeof (gint)); - for (index = 0; index < n_rows; ++index) - (*rows_selected)[index] = start_row + index; - } - return n_rows; -} - -static gint -table_interface_get_selected_columns (AtkTable *table, - gint **columns_selected) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - gint start_column = -1, n_columns = 0; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - if (week_view->selection_start_day == -1) - return 0; - if (week_view->selection_end_day - week_view->selection_start_day >= 6 ) { - start_column = 0; - n_columns =7; - } else { - start_column = week_view->selection_start_day % 7; - n_columns = (week_view->selection_end_day % 7) - start_column + 1; - } - if (n_columns > 0 && start_column != -1 && columns_selected) { - gint index; - - *columns_selected = (gint *) g_malloc (n_columns * sizeof (gint)); - for (index = 0; index < n_columns; ++index) - (*columns_selected)[index] = start_column + index; - } - return n_columns; -} - -static gboolean -table_interface_add_row_selection (AtkTable *table, - gint row) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - /* FIXME: we need multi-selection */ - - week_view->selection_start_day = row * 7; - week_view->selection_end_day = row *7 + 6; - - gtk_widget_queue_draw (week_view->main_canvas); - return TRUE; -} - -static gboolean -table_interface_remove_row_selection (AtkTable *table, - gint row) -{ - return FALSE; -} - -static gboolean -table_interface_add_column_selection (AtkTable *table, - gint column) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - /* FIXME: we need multi-selection */ - - week_view->selection_start_day = column; - week_view->selection_end_day = (week_view->weeks_shown - 1)*7+column; - - gtk_widget_queue_draw (week_view->main_canvas); - return TRUE; -} - -static gboolean -table_interface_remove_column_selection (AtkTable *table, - gint column) -{ - /* FIXME: NOT IMPLEMENTED */ - return FALSE; -} - -static AtkObject* -table_interface_get_row_header (AtkTable *table, - gint row) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -static AtkObject* -table_interface_get_column_header (AtkTable *table, - gint in_col) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -static AtkObject* -table_interface_get_caption (AtkTable *table) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -static G_CONST_RETURN gchar* -table_interface_get_column_description (AtkTable *table, - gint in_col) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - const gchar *description; - EaCellTable *cell_data; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - if (in_col < 0 || in_col > 6) - return NULL; - cell_data = ea_week_view_main_item_get_cell_data (ea_main_item); - if (!cell_data) - return NULL; - - description = ea_cell_table_get_column_label (cell_data, in_col); - if (!description) { - gchar buffer[128]; - - switch (in_col) { - case 0: - g_snprintf(buffer,128,"Monday"); - break; - case 1: - g_snprintf(buffer,128,"Tuesday"); - break; - case 2: - g_snprintf(buffer,128,"Wednesday"); - break; - case 3: - g_snprintf(buffer,128,"Thursday"); - break; - case 4: - g_snprintf(buffer,128,"Friday"); - break; - case 5: - g_snprintf(buffer,128,"Saturday"); - break; - case 6: - g_snprintf(buffer,128,"Sunday"); - break; - default: - break; - } - - ea_cell_table_set_column_label (cell_data, in_col, buffer); - description = ea_cell_table_get_column_label (cell_data, in_col); - } - return description; -} - -static G_CONST_RETURN gchar* -table_interface_get_row_description (AtkTable *table, - gint row) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (table); - const gchar *description; - EaCellTable *cell_data; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - if (row < 0 || row >= week_view->weeks_shown) - return NULL; - cell_data = ea_week_view_main_item_get_cell_data (ea_main_item); - if (!cell_data) - return NULL; - - description = ea_cell_table_get_row_label (cell_data, row); - if (!description) { - gchar buffer[128]; - ea_week_view_main_item_get_row_label (ea_main_item, row, buffer, sizeof (buffer)); - ea_cell_table_set_row_label (cell_data, row, buffer); - description = ea_cell_table_get_row_label (cell_data, - row); - } - return description; -} - -static AtkObject* -table_interface_get_summary (AtkTable *table) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -/* atkselection interface */ - -static void -atk_selection_interface_init (AtkSelectionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->add_selection = selection_interface_add_selection; - iface->clear_selection = selection_interface_clear_selection; - iface->ref_selection = selection_interface_ref_selection; - iface->get_selection_count = selection_interface_get_selection_count; - iface->is_child_selected = selection_interface_is_child_selected; -} - -static gboolean -selection_interface_add_selection (AtkSelection *selection, gint i) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - if (i < 0 || i > week_view->weeks_shown * 7 -1) - return FALSE; - - /*FIXME: multi-selection is needed */ - week_view->selection_start_day = i; - week_view->selection_end_day = i; - - gtk_widget_queue_draw (week_view->main_canvas); - return TRUE; -} - -static gboolean -selection_interface_clear_selection (AtkSelection *selection) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - week_view->selection_start_day = -1; - week_view->selection_end_day = -1; - - gtk_widget_queue_draw (week_view->main_canvas); - - return TRUE; -} - -static AtkObject* -selection_interface_ref_selection (AtkSelection *selection, gint i) -{ - gint count; - GObject *g_obj; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection); - gint start_index; - - count = selection_interface_get_selection_count (selection); - if (i < 0 || i >=count) - return NULL; - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (ea_main_item)); - week_view = E_WEEK_VIEW_MAIN_ITEM (g_obj)->week_view; - start_index = ea_week_view_main_item_get_child_index_at (ea_main_item, - week_view->selection_start_day / 7, - week_view->selection_start_day % 7); - - return ea_week_view_main_item_ref_child (ATK_OBJECT (selection), start_index + i); -} - -static gint -selection_interface_get_selection_count (AtkSelection *selection) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return 0; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - if (week_view->selection_start_day == -1 || - week_view->selection_end_day == -1) - return 0; - - return week_view->selection_end_day - week_view->selection_start_day + 1; -} - -static gboolean -selection_interface_is_child_selected (AtkSelection *selection, gint i) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EWeekViewMainItem *main_item; - EWeekView *week_view; - EaWeekViewMainItem* ea_main_item = EA_WEEK_VIEW_MAIN_ITEM (selection); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - main_item = E_WEEK_VIEW_MAIN_ITEM (g_obj); - week_view = main_item->week_view; - - if ((week_view->selection_start_day <= i)&&(week_view->selection_end_day >= i)) - return TRUE; - else - return FALSE; -} - diff --git a/a11y/calendar/ea-week-view-main-item.h b/a11y/calendar/ea-week-view-main-item.h deleted file mode 100644 index 12687d26c0..0000000000 --- a/a11y/calendar/ea-week-view-main-item.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * Yang Wu <Yang.Wu@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_WEEK_VIEW_MAIN_ITEM_H__ -#define __EA_WEEK_VIEW_MAIN_ITEM_H__ - -#include <atk/atkgobjectaccessible.h> -#include "e-week-view-main-item.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define EA_TYPE_WEEK_VIEW_MAIN_ITEM (ea_week_view_main_item_get_type ()) -#define EA_WEEK_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_WEEK_VIEW_MAIN_ITEM, EaWeekViewMainItem)) -#define EA_WEEK_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_WEEK_VIEW_MAIN_ITEM, EaWeekViewMainItemClass)) -#define EA_IS_WEEK_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_WEEK_VIEW_MAIN_ITEM)) -#define EA_IS_WEEK_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_WEEK_VIEW_MAIN_ITEM)) -#define EA_WEEK_VIEW_MAIN_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_WEEK_VIEW_MAIN_ITEM, EaWeekViewMainItemClass)) - -typedef struct _EaWeekViewMainItem EaWeekViewMainItem; -typedef struct _EaWeekViewMainItemClass EaWeekViewMainItemClass; - -struct _EaWeekViewMainItem -{ - AtkGObjectAccessible parent; -}; - -GType ea_week_view_main_item_get_type (void); - -struct _EaWeekViewMainItemClass -{ - AtkGObjectAccessibleClass parent_class; -}; - -AtkObject* ea_week_view_main_item_new (GObject *obj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EA_WEEK_VIEW_MAIN_ITEM_H__ */ diff --git a/a11y/calendar/ea-week-view.c b/a11y/calendar/ea-week-view.c deleted file mode 100644 index 6cf234c864..0000000000 --- a/a11y/calendar/ea-week-view.c +++ /dev/null @@ -1,321 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-week-view.h" -#include "ea-cal-view-event.h" -#include "ea-calendar-helpers.h" -#include "ea-gnome-calendar.h" -#include "calendar-commands.h" -#include <text/e-text.h> -#include <glib/gi18n.h> - -static void ea_week_view_class_init (EaWeekViewClass *klass); - -static G_CONST_RETURN gchar* ea_week_view_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_week_view_get_description (AtkObject *accessible); -static gint ea_week_view_get_n_children (AtkObject *obj); -static AtkObject* ea_week_view_ref_child (AtkObject *obj, - gint i); - -static gpointer parent_class = NULL; - -GType -ea_week_view_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaWeekViewClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_week_view_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaWeekView), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (EaCalView, in this case) - * - * Note: we must still use run-time deriving here, because - * our parent class EaCalView is run-time deriving. - */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - e_calendar_view_get_type()); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - type = g_type_register_static (derived_atk_type, - "EaWeekView", &tinfo, 0); - - } - - return type; -} - -static void -ea_week_view_class_init (EaWeekViewClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_week_view_get_name; - class->get_description = ea_week_view_get_description; - - class->get_n_children = ea_week_view_get_n_children; - class->ref_child = ea_week_view_ref_child; -} - -AtkObject* -ea_week_view_new (GtkWidget *widget) -{ - GObject *object; - AtkObject *accessible; - - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - - object = g_object_new (EA_TYPE_WEEK_VIEW, NULL); - - accessible = ATK_OBJECT (object); - atk_object_initialize (accessible, widget); - -#ifdef ACC_DEBUG - printf ("EvoAcc: ea_week_view created %p\n", (void *)accessible); -#endif - - return accessible; -} - -static G_CONST_RETURN gchar* -ea_week_view_get_name (AtkObject *accessible) -{ - EWeekView *week_view; - GnomeCalendar *gcal; - const gchar *label_text; - GnomeCalendarViewType view_type; - gint n_events; - gchar *event_str, *name_str; - - g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), NULL); - - if (!GTK_ACCESSIBLE (accessible)->widget) - return NULL; - - week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget); - gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (week_view)); - if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (gcal))) - return NULL; - - label_text = ea_gnome_calendar_get_label_description (gcal); - - n_events = atk_object_get_n_accessible_children (accessible); - /* the child main item is always there */ - --n_events; - if (n_events >= 1) - event_str = g_strdup_printf (ngettext ("It has %d event.", "It has %d events.", n_events), n_events); - else - event_str = g_strdup (_("It has no events.")); - - view_type = gnome_calendar_get_view (gcal); - - if (view_type == GNOME_CAL_MONTH_VIEW) - name_str = g_strdup_printf (_("Month View: %s. %s"), - label_text, event_str); - - else - name_str = g_strdup_printf (_("Week View: %s. %s"), - label_text, event_str); - - ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name_str); - g_free (name_str); - g_free (event_str); - - return accessible->name; -} - -static G_CONST_RETURN gchar* -ea_week_view_get_description (AtkObject *accessible) -{ - EWeekView *week_view; - - g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), NULL); - - if (!GTK_ACCESSIBLE (accessible)->widget) - return NULL; - week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget); - - if (accessible->description) - return accessible->description; - else { - GnomeCalendar *gcal; - GnomeCalendarViewType view_type; - - gcal = e_calendar_view_get_calendar (E_CALENDAR_VIEW (week_view)); - view_type = gnome_calendar_get_view (gcal); - - if (view_type == GNOME_CAL_MONTH_VIEW) - return _("calendar view for a month"); - else - return _("calendar view for one or more weeks"); - } -} - -static gint -ea_week_view_get_n_children (AtkObject *accessible) -{ - EWeekView *week_view; - gint i, count = 0; - gint event_index; - - g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), -1); - - if (!GTK_ACCESSIBLE (accessible)->widget) - return -1; - week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget); - - for (event_index = 0; event_index < week_view->events->len; - ++event_index) { - EWeekViewEvent *event; - EWeekViewEventSpan *span; - - /* If week_view->spans == NULL, there is no visible events. */ - if (!week_view->spans) - break; - - event = &g_array_index (week_view->events, - EWeekViewEvent, event_index); - if (!event) - continue; - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + 0); - - if (!span) - continue; - - /* at least one of the event spans is visible, count it */ - if (span->text_item) - ++count; - } - - /* add the number of visible jump buttons */ - for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) { - if (week_view->jump_buttons[i]->object.flags & GNOME_CANVAS_ITEM_VISIBLE) - ++count; - } - - /* "+1" for the main item */ - count++; - -#ifdef ACC_DEBUG - printf("AccDebug: week view %p has %d children\n", (void *)week_view, count); -#endif - return count; -} - -static AtkObject * -ea_week_view_ref_child (AtkObject *accessible, gint index) -{ - EWeekView *week_view; - gint child_num, max_count; - AtkObject *atk_object = NULL; - gint event_index; - gint jump_button = -1; - gint span_num = 0; - gint count = 0; - - g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), NULL); - - child_num = atk_object_get_n_accessible_children (accessible); - if (child_num <= 0 || index < 0 || index >= child_num) - return NULL; - - if (!GTK_ACCESSIBLE (accessible)->widget) - return NULL; - week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget); - max_count = week_view->events->len; - - if (index == 0) { - /* index == 0 is the main item */ - atk_object = atk_gobject_accessible_for_object (G_OBJECT (week_view->main_canvas_item)); - g_object_ref (atk_object); - } else - for (event_index = 0; event_index < max_count; ++event_index) { - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint current_day; - - event = &g_array_index (week_view->events, - EWeekViewEvent, event_index); - if (!event) - continue; - - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - if (!span) - continue; - - current_day = span->start_day; - if (span->text_item) - ++count; - else if (current_day != jump_button) { - /* we should go to the jump button */ - jump_button = current_day; - ++count; - } - else - continue; - - if (count == index) { - if (span->text_item) { - /* Not use atk_gobject_accessible_for_object for event - * text_item we need to do special thing here - */ - atk_object = ea_calendar_helpers_get_accessible_for (span->text_item); - } - else { - atk_object = ea_calendar_helpers_get_accessible_for (week_view->jump_buttons[current_day == -1 ? 0 : current_day]); - } - g_object_ref (atk_object); - break; - } - } - -#ifdef ACC_DEBUG - printf ("EvoAcc: ea_week_view_ref_child [%d]=%p\n", - index, (void *)atk_object); -#endif - return atk_object; -} diff --git a/a11y/calendar/ea-week-view.h b/a11y/calendar/ea-week-view.h deleted file mode 100644 index b24fe72103..0000000000 --- a/a11y/calendar/ea-week-view.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_WEEK_VIEW_H__ -#define __EA_WEEK_VIEW_H__ - -#include "ea-cal-view.h" -#include "e-week-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define EA_TYPE_WEEK_VIEW (ea_week_view_get_type ()) -#define EA_WEEK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_WEEK_VIEW, EaWeekView)) -#define EA_WEEK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_WEEK_VIEW, EaWeekViewClass)) -#define EA_IS_WEEK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_WEEK_VIEW)) -#define EA_IS_WEEK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_WEEK_VIEW)) -#define EA_WEEK_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_WEEK_VIEW, EaWeekViewClass)) - -typedef struct _EaWeekView EaWeekView; -typedef struct _EaWeekViewClass EaWeekViewClass; - -struct _EaWeekView -{ - EaCalView parent; -}; - -GType ea_week_view_get_type (void); - -struct _EaWeekViewClass -{ - EaCalViewClass parent_class; -}; - -AtkObject* ea_week_view_new (GtkWidget *widget); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __EA_WEEK_VIEW_H__ */ diff --git a/a11y/e-table/Makefile.am b/a11y/e-table/Makefile.am deleted file mode 100644 index 413a37d97e..0000000000 --- a/a11y/e-table/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets \ - $(E_UTIL_CFLAGS) \ - $(GNOME_PLATFORM_CFLAGS) \ - -DG_LOG_DOMAIN=\"e-table\" - -noinst_LTLIBRARIES = libgal-a11y-etable.la - -libgal_a11y_etable_la_SOURCES = \ - gal-a11y-e-tree.c \ - gal-a11y-e-tree-factory.c \ - gal-a11y-e-cell.c \ - gal-a11y-e-cell-text.c \ - gal-a11y-e-cell-tree.c \ - gal-a11y-e-cell-toggle.c \ - gal-a11y-e-cell-popup.c \ - gal-a11y-e-cell-registry.c \ - gal-a11y-e-cell-vbox.c \ - gal-a11y-e-table.c \ - gal-a11y-e-table-item.c \ - gal-a11y-e-table-item-factory.c \ - gal-a11y-e-table-click-to-add.c \ - gal-a11y-e-table-column-header.c \ - gal-a11y-e-table-click-to-add-factory.c \ - gal-a11y-e-table-factory.c \ - gal-a11y-e-tree.h \ - gal-a11y-e-tree-factory.h \ - gal-a11y-e-cell.h \ - gal-a11y-e-cell-text.h \ - gal-a11y-e-cell-tree.h \ - gal-a11y-e-cell-toggle.h \ - gal-a11y-e-cell-popup.h \ - gal-a11y-e-cell-registry.h \ - gal-a11y-e-cell-vbox.h \ - gal-a11y-e-table.h \ - gal-a11y-e-table-item.h \ - gal-a11y-e-table-click-to-add-factory.h \ - gal-a11y-e-table-click-to-add.h \ - gal-a11y-e-table-column-header.h \ - gal-a11y-e-table-item-factory.h \ - gal-a11y-e-table-factory.h - --include $(top_srcdir)/git.mk diff --git a/a11y/e-table/gal-a11y-e-cell-popup.c b/a11y/e-table/gal-a11y-e-cell-popup.c deleted file mode 100644 index 1a40b23a21..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-popup.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yang Wu <yang.wu@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <gdk/gdkkeysyms.h> -#include <gtk/gtk.h> - -#include "a11y/gal-a11y-util.h" -#include "table/e-cell-popup.h" -#include <glib/gi18n.h> - -#include "gal-a11y-e-cell-popup.h" -#include "gal-a11y-e-cell-registry.h" - -static AtkObjectClass *parent_class = NULL; -#define PARENT_TYPE (gal_a11y_e_cell_get_type ()) - -static void gal_a11y_e_cell_popup_class_init (GalA11yECellPopupClass *klass); -static void popup_cell_action (GalA11yECell *cell); - -/** - * gal_a11y_e_cell_popup_get_type: - * @void: - * - * Registers the &GalA11yECellPopup class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yECellPopup class. - **/ -GType -gal_a11y_e_cell_popup_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yECellPopupClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gal_a11y_e_cell_popup_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yECellPopup), - 0, - (GInstanceInitFunc) NULL, - NULL /* value_cell_popup */ - }; - - type = g_type_register_static (PARENT_TYPE, "GalA11yECellPopup", &info, 0); - gal_a11y_e_cell_type_add_action_interface (type); - } - - return type; -} - -static void -gal_a11y_e_cell_popup_class_init (GalA11yECellPopupClass *klass) -{ - parent_class = g_type_class_ref (PARENT_TYPE); -} - -AtkObject * -gal_a11y_e_cell_popup_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row) -{ - AtkObject *a11y; - GalA11yECell *cell; - ECellPopup *popupcell; - ECellView* child_view = NULL; - - popupcell= E_CELL_POPUP(cell_view->ecell); - - if (popupcell && popupcell->popup_cell_view) - child_view = popupcell->popup_cell_view->child_view; - - if (child_view && child_view->ecell) { - a11y = gal_a11y_e_cell_registry_get_object (NULL, - item, - child_view, - parent, - model_col, - view_col, - row); - } else { - a11y = g_object_new (GAL_A11Y_TYPE_E_CELL_POPUP, NULL); - gal_a11y_e_cell_construct (a11y, - item, - cell_view, - parent, - model_col, - view_col, - row); - } - g_return_val_if_fail (a11y != NULL, NULL); - cell = GAL_A11Y_E_CELL(a11y); - gal_a11y_e_cell_add_action (cell, - _("popup"), /* action name*/ - _("popup a child"), /* action description */ - "<Alt>Down", /* action keybinding */ - popup_cell_action); - - a11y->role = ATK_ROLE_TABLE_CELL; - return a11y; -} - -static void -popup_cell_action (GalA11yECell *cell) -{ - gint finished; - GdkEvent event; - - event.key.type = GDK_KEY_PRESS; - event.key.window = GTK_LAYOUT(GNOME_CANVAS_ITEM(cell->item)->canvas)->bin_window;; - event.key.send_event = TRUE; - event.key.time = GDK_CURRENT_TIME; - event.key.state = GDK_MOD1_MASK; - event.key.keyval = GDK_Down; - - g_signal_emit_by_name (cell->item, "event", &event, &finished); -} diff --git a/a11y/e-table/gal-a11y-e-cell-popup.h b/a11y/e-table/gal-a11y-e-cell-popup.h deleted file mode 100644 index ebc16c1880..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-popup.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yang Wu <yang.wu@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_CELL_POPUP_H__ -#define __GAL_A11Y_E_CELL_POPUP_H__ - -#include <glib-object.h> -#include <table/e-table-item.h> -#include <a11y/e-table/gal-a11y-e-cell.h> -#include <atk/atkgobjectaccessible.h> - -#define GAL_A11Y_TYPE_E_CELL_POPUP (gal_a11y_e_cell_popup_get_type ()) -#define GAL_A11Y_E_CELL_POPUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_CELL_POPUP, GalA11yECellPopup)) -#define GAL_A11Y_E_CELL_POPUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_CELL_POPUP, GalA11yECellPopupClass)) -#define GAL_A11Y_IS_E_CELL_POPUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_CELL_POPUP)) -#define GAL_A11Y_IS_E_CELL_POPUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_CELL_POPUP)) - -typedef struct _GalA11yECellPopup GalA11yECellPopup; -typedef struct _GalA11yECellPopupClass GalA11yECellPopupClass; - -/* This struct should actually be larger as this isn't what we derive from. - * The GalA11yECellPopupPrivate comes right after the parent class structure. - **/ -struct _GalA11yECellPopup { - GalA11yECell object; -}; - -struct _GalA11yECellPopupClass { - GalA11yECellClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_cell_popup_get_type (void); -AtkObject *gal_a11y_e_cell_popup_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row); - -#endif /* ! __GAL_A11Y_E_CELL_POPUP_H__ */ diff --git a/a11y/e-table/gal-a11y-e-cell-registry.c b/a11y/e-table/gal-a11y-e-cell-registry.c deleted file mode 100644 index b88fb581fc..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-registry.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include "gal-a11y-e-cell.h" -#include "gal-a11y-e-cell-registry.h" - -static GObjectClass *parent_class; -static GalA11yECellRegistry *default_registry; -#define PARENT_TYPE (G_TYPE_OBJECT) - -struct _GalA11yECellRegistryPrivate { - GHashTable *table; -}; - -/* Static functions */ - -static void -gal_a11y_e_cell_registry_finalize (GObject *obj) -{ - GalA11yECellRegistry *registry = GAL_A11Y_E_CELL_REGISTRY (obj); - - g_hash_table_destroy (registry->priv->table); - g_free (registry->priv); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -static void -gal_a11y_e_cell_registry_class_init (GalA11yECellRegistryClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->finalize = gal_a11y_e_cell_registry_finalize; -} - -static void -gal_a11y_e_cell_registry_init (GalA11yECellRegistry *registry) -{ - registry->priv = g_new (GalA11yECellRegistryPrivate, 1); - registry->priv->table = g_hash_table_new (NULL, NULL); -} - -/** - * gal_a11y_e_cell_registry_get_type: - * @void: - * - * Registers the &GalA11yECellRegistry class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yECellRegistry class. - **/ -GType -gal_a11y_e_cell_registry_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yECellRegistryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gal_a11y_e_cell_registry_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yECellRegistry), - 0, - (GInstanceInitFunc) gal_a11y_e_cell_registry_init, - NULL /* value_cell */ - }; - - type = g_type_register_static (PARENT_TYPE, "GalA11yECellRegistry", &info, 0); - } - - return type; -} - -static void -init_default_registry (void) -{ - if (default_registry == NULL) { - default_registry = g_object_new (gal_a11y_e_cell_registry_get_type(), NULL); - } -} - - -AtkObject * -gal_a11y_e_cell_registry_get_object (GalA11yECellRegistry *registry, - ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row) -{ - GalA11yECellRegistryFunc func = NULL; - GType type; - - if (registry == NULL) { - init_default_registry (); - registry = default_registry; - } - - type = GTK_OBJECT_TYPE (cell_view->ecell); - while (func == NULL && type != 0) { - func = g_hash_table_lookup (registry->priv->table, GINT_TO_POINTER (type)); - type = g_type_parent (type); - } - - if (func) - return func (item, cell_view, parent, model_col, view_col, row); - else - return gal_a11y_e_cell_new (item, cell_view, parent, model_col, view_col, row); -} - -void -gal_a11y_e_cell_registry_add_cell_type (GalA11yECellRegistry *registry, - GType type, - GalA11yECellRegistryFunc func) -{ - if (registry == NULL) { - init_default_registry (); - registry = default_registry; - } - - g_hash_table_insert (registry->priv->table, GINT_TO_POINTER (type), func); -} diff --git a/a11y/e-table/gal-a11y-e-cell-registry.h b/a11y/e-table/gal-a11y-e-cell-registry.h deleted file mode 100644 index f231567222..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-registry.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_CELL_REGISTRY_H__ -#define __GAL_A11Y_E_CELL_REGISTRY_H__ - -#include <glib-object.h> -#include <atk/atkobject.h> -#include <table/e-table-item.h> -#include <table/e-cell.h> - -#define GAL_A11Y_TYPE_E_CELL_REGISTRY (gal_a11y_e_cell_registry_get_type ()) -#define GAL_A11Y_E_CELL_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_CELL_REGISTRY, GalA11yECellRegistry)) -#define GAL_A11Y_E_CELL_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_CELL_REGISTRY, GalA11yECellRegistryClass)) -#define GAL_A11Y_IS_E_CELL_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_CELL_REGISTRY)) -#define GAL_A11Y_IS_E_CELL_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_CELL_REGISTRY)) - -typedef struct _GalA11yECellRegistry GalA11yECellRegistry; -typedef struct _GalA11yECellRegistryClass GalA11yECellRegistryClass; -typedef struct _GalA11yECellRegistryPrivate GalA11yECellRegistryPrivate; - -typedef AtkObject *(*GalA11yECellRegistryFunc) (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row); - -struct _GalA11yECellRegistry { - GObject object; - - GalA11yECellRegistryPrivate *priv; -}; - -struct _GalA11yECellRegistryClass { - GObjectClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_cell_registry_get_type (void); -AtkObject *gal_a11y_e_cell_registry_get_object (GalA11yECellRegistry *registry, - ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row); -void gal_a11y_e_cell_registry_add_cell_type (GalA11yECellRegistry *registry, - GType type, - GalA11yECellRegistryFunc func); - -#endif /* ! __GAL_A11Y_E_CELL_REGISTRY_H__ */ diff --git a/a11y/e-table/gal-a11y-e-cell-text.c b/a11y/e-table/gal-a11y-e-cell-text.c deleted file mode 100644 index e77c0739a9..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-text.c +++ /dev/null @@ -1,737 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <string.h> - -#include <atk/atk.h> - -#include "a11y/gal-a11y-util.h" -#include "table/e-cell-text.h" -#include <glib/gi18n.h> - -#include "gal-a11y-e-cell-text.h" - -#define CS_CLASS(a11y) (G_TYPE_INSTANCE_GET_CLASS ((a11y), C_TYPE_STREAM, GalA11yECellTextClass)) -static AtkObjectClass *parent_class; -#define PARENT_TYPE (gal_a11y_e_cell_get_type ()) - -/* Static functions */ -static void -ect_dispose (GObject *object) -{ - GObjectClass *g_class; - GalA11yECell *gaec = GAL_A11Y_E_CELL (object); - GalA11yECellText *gaet = GAL_A11Y_E_CELL_TEXT (object); - - if (gaet->inserted_id != 0) { - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); - - if (ect) { - g_signal_handler_disconnect (ect, gaet->inserted_id); - g_signal_handler_disconnect (ect, gaet->deleted_id); - } - - gaet->inserted_id = 0; - gaet->deleted_id = 0; - } - - g_class = (GObjectClass *)parent_class; - if (g_class->dispose) - g_class->dispose (object); - -} - -static gboolean -ect_check (gpointer a11y) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (a11y); - ETableItem *item = gaec->item; - - g_return_val_if_fail ((gaec->item != NULL), FALSE); - g_return_val_if_fail ((gaec->cell_view != NULL), FALSE); - g_return_val_if_fail ((gaec->cell_view->ecell != NULL), FALSE); - - if (atk_state_set_contains_state (gaec->state_set, ATK_STATE_DEFUNCT)) - return FALSE; - - if (gaec->row < 0 || gaec->row >= item->rows - || gaec->view_col <0 || gaec->view_col >= item->cols - || gaec->model_col <0 || gaec->model_col >= e_table_model_column_count (item->table_model)) - return FALSE; - - if (!E_IS_CELL_TEXT (gaec->cell_view->ecell)) - return FALSE; - - return TRUE; -} - -static G_CONST_RETURN gchar* -ect_get_name (AtkObject * a11y) -{ - GalA11yECell *gaec; - char *name; - - if (!ect_check (a11y)) - return NULL; - - gaec = GAL_A11Y_E_CELL (a11y); - name = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); - if (name != NULL) { - ATK_OBJECT_CLASS (parent_class)->set_name (a11y, name); - g_free (name); - } - - if (a11y->name != NULL && strcmp (a11y->name, "")) { - return a11y->name; - } else { - return parent_class->get_name (a11y); - } -} - -static gchar * -ect_get_text (AtkText *text, - gint start_offset, - gint end_offset) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - gchar *full_text; - gchar *ret_val; - - if (!ect_check (text)) - return NULL; - - full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); - - if (end_offset == -1) - end_offset = strlen (full_text); - else - end_offset = g_utf8_offset_to_pointer (full_text, end_offset) - full_text; - - start_offset = g_utf8_offset_to_pointer (full_text, start_offset) - full_text; - - ret_val = g_strndup (full_text + start_offset, end_offset - start_offset); - - g_free (full_text); - - return ret_val; -} - -static gchar * -ect_get_text_after_offset (AtkText *text, - gint offset, - AtkTextBoundary boundary_type, - gint *start_offset, - gint *end_offset) -{ - /* Unimplemented */ - return NULL; -} - -static gchar * -ect_get_text_at_offset (AtkText *text, - gint offset, - AtkTextBoundary boundary_type, - gint *start_offset, - gint *end_offset) -{ - /* Unimplemented */ - return NULL; -} - -static gunichar -ect_get_character_at_offset (AtkText *text, - gint offset) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - gunichar ret_val; - gchar *at_offset; - gchar *full_text; - - if (!ect_check (text)) - return -1; - - full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); - at_offset = g_utf8_offset_to_pointer (full_text, offset); - ret_val = g_utf8_get_char_validated (at_offset, -1); - g_free (full_text); - - return ret_val; -} - - -static gchar* -ect_get_text_before_offset (AtkText *text, - gint offset, - AtkTextBoundary boundary_type, - gint *start_offset, - gint *end_offset) -{ - /* Unimplemented */ - return NULL; -} - - -static gint -ect_get_caret_offset (AtkText *text) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - gint start, end; - - if (!ect_check (text)) - return -1; - - if (e_cell_text_get_selection (gaec->cell_view, - gaec->view_col, gaec->row, - &start, &end)) { - gchar *full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); - end = g_utf8_pointer_to_offset (full_text, full_text + end); - g_free (full_text); - - return end; - } - else - return -1; -} - -static AtkAttributeSet* -ect_get_run_attributes (AtkText *text, - gint offset, - gint *start_offset, - gint *end_offset) -{ - /* Unimplemented */ - return NULL; -} - - -static AtkAttributeSet* -ect_get_default_attributes (AtkText *text) -{ - /* Unimplemented */ - return NULL; -} - - -static void -ect_get_character_extents (AtkText *text, - gint offset, - gint *x, - gint *y, - gint *width, - gint *height, - AtkCoordType coords) -{ - /* Unimplemented */ -} - - -static gint -ect_get_character_count (AtkText *text) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - gint ret_val; - gchar *full_text; - - if (!ect_check (text)) - return -1; - - full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); - - ret_val = g_utf8_strlen (full_text, -1); - g_free (full_text); - return ret_val; -} - - -static gint -ect_get_offset_at_point (AtkText *text, - gint x, - gint y, - AtkCoordType coords) -{ - /* Unimplemented */ - return 0; -} - - -static gint -ect_get_n_selections (AtkText *text) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - gint selection_start, selection_end; - - if (!ect_check (text)) - return 0; - - if (e_cell_text_get_selection (gaec->cell_view, - gaec->view_col, gaec->row, - &selection_start, - &selection_end) - && selection_start != selection_end) - return 1; - return 0; -} - - -static gchar* -ect_get_selection (AtkText *text, - gint selection_num, - gint *start_offset, - gint *end_offset) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - gchar *ret_val; - gint selection_start, selection_end; - - if (selection_num == 0 - && e_cell_text_get_selection (gaec->cell_view, - gaec->view_col, gaec->row, - &selection_start, - &selection_end) - && selection_start != selection_end) { - gint real_start, real_end, len; - gchar *full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); - len = strlen (full_text); - real_start = MIN (selection_start, selection_end); - real_end = MAX (selection_start, selection_end); - real_start = MIN (MAX (0, real_start), len); - real_end = MIN (MAX (0, real_end), len); - - ret_val = g_strndup (full_text + real_start, real_end - real_start); - - real_start = g_utf8_pointer_to_offset (full_text, full_text + real_start); - real_end = g_utf8_pointer_to_offset (full_text, full_text + real_end); - - if (start_offset) - *start_offset = real_start; - if (end_offset) - *end_offset = real_end; - g_free (full_text); - } else { - if (start_offset) - *start_offset = 0; - if (end_offset) - *end_offset = 0; - ret_val = NULL; - } - - return ret_val; -} - - -static gboolean -ect_add_selection (AtkText *text, - gint start_offset, - gint end_offset) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - - if (start_offset != end_offset) { - gint real_start, real_end, len; - gchar *full_text = - e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); - - len = g_utf8_strlen (full_text, -1); - if (end_offset == -1) - end_offset = len; - - real_start = MIN (start_offset, end_offset); - real_end = MAX (start_offset, end_offset); - - real_start = MIN (MAX (0, real_start), len); - real_end = MIN (MAX (0, real_end), len); - - real_start = g_utf8_offset_to_pointer (full_text, real_start) - full_text; - real_end = g_utf8_offset_to_pointer (full_text, real_end) - full_text; - g_free (full_text); - - if (e_cell_text_set_selection (gaec->cell_view, - gaec->view_col, gaec->row, - real_start, real_end)) { - g_signal_emit_by_name (ATK_OBJECT(text), "text_selection_changed"); - return TRUE; - } - } - - return FALSE; -} - - -static gboolean -ect_remove_selection (AtkText *text, - gint selection_num) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - gint selection_start, selection_end; - - if (selection_num == 0 - && e_cell_text_get_selection (gaec->cell_view, - gaec->view_col, gaec->row, - &selection_start, - &selection_end) - && selection_start != selection_end - && e_cell_text_set_selection (gaec->cell_view, - gaec->view_col, gaec->row, - selection_end, selection_end)) { - g_signal_emit_by_name (ATK_OBJECT(text), "text_selection_changed"); - return TRUE; - } - else - return FALSE; -} - - -static gboolean -ect_set_selection (AtkText *text, - gint selection_num, - gint start_offset, - gint end_offset) -{ - if (selection_num == 0) { - atk_text_add_selection (text, start_offset, end_offset); - return TRUE; - } - else - return FALSE; -} - - -static gboolean -ect_set_caret_offset (AtkText *text, - gint offset) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - gchar *full_text; - gint len; - - full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); - - len = g_utf8_strlen (full_text, -1); - if (offset == -1) - offset = len; - else - offset = MIN (MAX (0, offset), len); - - offset = g_utf8_offset_to_pointer (full_text, offset) - full_text; - - g_free (full_text); - - return e_cell_text_set_selection (gaec->cell_view, - gaec->view_col, gaec->row, - offset, offset); -} - -static gboolean -ect_set_run_attributes (AtkEditableText *text, - AtkAttributeSet *attrib_set, - gint start_offset, - gint end_offset) -{ - /* Unimplemented */ - return FALSE; -} - -static void -ect_set_text_contents (AtkEditableText *text, - const gchar *string) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); - - e_cell_text_set_value (ect, gaec->item->table_model, gaec->model_col, gaec->row, string); - e_table_item_enter_edit (gaec->item, gaec->view_col, gaec->row); -} - -static void -ect_insert_text (AtkEditableText *text, - const gchar *string, - gint length, - gint *position) -{ - /* Utf8 unimplemented */ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); - - gchar *full_text = e_cell_text_get_text_by_view (gaec->cell_view, gaec->model_col, gaec->row); - gchar *result = g_strdup_printf ("%.*s%.*s%s", *position, full_text, length, string, full_text + *position); - - e_cell_text_set_value (ect, gaec->item->table_model, gaec->model_col, gaec->row, result); - - *position += length; - - g_free (result); - g_free (full_text); -} - -static void -ect_copy_text (AtkEditableText *text, - gint start_pos, - gint end_pos) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - if (start_pos != end_pos - && atk_text_set_selection (ATK_TEXT (text), 0, start_pos, end_pos)) - e_cell_text_copy_clipboard (gaec->cell_view, - gaec->view_col, gaec->row); -} - -static void -ect_delete_text (AtkEditableText *text, - gint start_pos, - gint end_pos) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - if (start_pos != end_pos - && atk_text_set_selection (ATK_TEXT (text), 0, start_pos, end_pos)) - e_cell_text_delete_selection (gaec->cell_view, - gaec->view_col, gaec->row); -} - -static void -ect_cut_text (AtkEditableText *text, - gint start_pos, - gint end_pos) -{ - ect_copy_text (text, start_pos, end_pos); - ect_delete_text (text, start_pos, end_pos); -} - -static void -ect_paste_text (AtkEditableText *text, - gint position) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (text); - - e_table_item_enter_edit (gaec->item, gaec->view_col, gaec->row); - - if (atk_text_set_caret_offset (ATK_TEXT (text), position)) - e_cell_text_paste_clipboard (gaec->cell_view, - gaec->view_col, gaec->row); -} - -static void -ect_do_action_edit (AtkAction *action) -{ - GalA11yECell *a11y = GAL_A11Y_E_CELL (action); - ETableModel *e_table_model = a11y->item->table_model; - - if (e_table_model_is_cell_editable(e_table_model, a11y->model_col, a11y->row)) { - e_table_item_enter_edit (a11y->item, a11y->view_col, a11y->row); - } -} - -/* text signal handlers */ -static void -ect_text_inserted_cb (ECellText *text, ECellView *cell_view, int pos, int len, int row, int model_col, gpointer data) -{ - GalA11yECellText *gaet; - GalA11yECell *gaec; - - if (!ect_check (data)) - return; - gaet = GAL_A11Y_E_CELL_TEXT (data); - gaec = GAL_A11Y_E_CELL (data); - - if (cell_view == gaec->cell_view && row == gaec->row && model_col == gaec->model_col) { - g_signal_emit_by_name (gaet, "text_changed::insert", pos, len); - - } -} - -static void -ect_text_deleted_cb (ECellText *text, ECellView *cell_view, int pos, int len, int row, int model_col, gpointer data) -{ - GalA11yECellText *gaet; - GalA11yECell *gaec; - if (!ect_check (data)) - return; - gaet = GAL_A11Y_E_CELL_TEXT (data); - gaec = GAL_A11Y_E_CELL (data); - if (cell_view == gaec->cell_view && row == gaec->row && model_col == gaec->model_col) { - g_signal_emit_by_name (gaet, "text_changed::delete", pos, len); - } -} - -static void -ect_atk_text_iface_init (AtkTextIface *iface) -{ - iface->get_text = ect_get_text; - iface->get_text_after_offset = ect_get_text_after_offset; - iface->get_text_at_offset = ect_get_text_at_offset; - iface->get_character_at_offset = ect_get_character_at_offset; - iface->get_text_before_offset = ect_get_text_before_offset; - iface->get_caret_offset = ect_get_caret_offset; - iface->get_run_attributes = ect_get_run_attributes; - iface->get_default_attributes = ect_get_default_attributes; - iface->get_character_extents = ect_get_character_extents; - iface->get_character_count = ect_get_character_count; - iface->get_offset_at_point = ect_get_offset_at_point; - iface->get_n_selections = ect_get_n_selections; - iface->get_selection = ect_get_selection; - iface->add_selection = ect_add_selection; - iface->remove_selection = ect_remove_selection; - iface->set_selection = ect_set_selection; - iface->set_caret_offset = ect_set_caret_offset; -} - -static void -ect_atk_editable_text_iface_init (AtkEditableTextIface *iface) -{ - iface->set_run_attributes = ect_set_run_attributes; - iface->set_text_contents = ect_set_text_contents; - iface->insert_text = ect_insert_text; - iface->copy_text = ect_copy_text; - iface->cut_text = ect_cut_text; - iface->delete_text = ect_delete_text; - iface->paste_text = ect_paste_text; -} - -static void -ect_class_init (GalA11yECellTextClass *klass) -{ - AtkObjectClass *a11y = ATK_OBJECT_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - a11y->get_name = ect_get_name; - object_class->dispose = ect_dispose; -} - -static void -ect_action_init (GalA11yECellText *a11y) -{ - GalA11yECell *gaec = GAL_A11Y_E_CELL (a11y); - ECellText *ect = E_CELL_TEXT (gaec->cell_view->ecell); - if (ect->editable && e_table_model_is_cell_editable (gaec->cell_view->e_table_model, gaec->model_col, gaec->row)) - gal_a11y_e_cell_add_action (gaec, - _("edit"), - _("begin editing this cell"), - NULL, - (ACTION_FUNC) ect_do_action_edit); -} - -/** - * gal_a11y_e_cell_text_get_type: - * @void: - * - * Registers the &GalA11yECellText class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yECellText class. - **/ -GType -gal_a11y_e_cell_text_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yECellTextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ect_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yECellText), - 0, - (GInstanceInitFunc) NULL, - NULL /* value_cell_text */ - }; - - static const GInterfaceInfo atk_text_info = { - (GInterfaceInitFunc) ect_atk_text_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - static const GInterfaceInfo atk_editable_text_info = { - (GInterfaceInitFunc) ect_atk_editable_text_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - type = g_type_register_static (PARENT_TYPE, "GalA11yECellText", &info, 0); - g_type_add_interface_static (type, ATK_TYPE_TEXT, &atk_text_info); - g_type_add_interface_static (type, ATK_TYPE_EDITABLE_TEXT, &atk_editable_text_info); - gal_a11y_e_cell_type_add_action_interface (type); - } - - return type; -} - -static void -cell_text_destroyed (gpointer data) -{ - g_return_if_fail (GAL_A11Y_IS_E_CELL_TEXT (data)); - - g_object_unref (data); -} - -AtkObject * -gal_a11y_e_cell_text_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row) -{ - AtkObject *a11y; - GalA11yECell *gaec; - GalA11yECellText *gaet; - ECellText *ect; - - a11y = g_object_new (gal_a11y_e_cell_text_get_type (), NULL); - - gal_a11y_e_cell_construct (a11y, - item, - cell_view, - parent, - model_col, - view_col, - row); - gaet = GAL_A11Y_E_CELL_TEXT (a11y); - - /* will be unrefed in cell_text_destroyed */ - g_object_ref (a11y); - - gaet->inserted_id = g_signal_connect (E_CELL_TEXT (((ECellView *)cell_view)->ecell), - "text_inserted", G_CALLBACK (ect_text_inserted_cb), a11y); - gaet->deleted_id = g_signal_connect (E_CELL_TEXT (((ECellView *)cell_view)->ecell), - "text_deleted", G_CALLBACK (ect_text_deleted_cb), a11y); - - g_object_weak_ref (G_OBJECT (((ECellView *)cell_view)->ecell), - (GWeakNotify) cell_text_destroyed, - a11y); - - ect_action_init (gaet); - - ect = E_CELL_TEXT (cell_view->ecell); - gaec = GAL_A11Y_E_CELL (a11y); - if (ect->editable && e_table_model_is_cell_editable (gaec->cell_view->e_table_model, gaec->model_col, gaec->row)) - gal_a11y_e_cell_add_state (gaec, ATK_STATE_EDITABLE, FALSE); - else - gal_a11y_e_cell_remove_state (gaec, ATK_STATE_EDITABLE, FALSE); - - return a11y; -} diff --git a/a11y/e-table/gal-a11y-e-cell-text.h b/a11y/e-table/gal-a11y-e-cell-text.h deleted file mode 100644 index c69b374100..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-text.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_CELL_TEXT_H__ -#define __GAL_A11Y_E_CELL_TEXT_H__ - -#include <glib-object.h> -#include <table/e-table-item.h> -#include <table/e-cell-text.h> -#include <a11y/e-table/gal-a11y-e-cell.h> - -#define GAL_A11Y_TYPE_E_CELL_TEXT (gal_a11y_e_cell_text_get_type ()) -#define GAL_A11Y_E_CELL_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_CELL_TEXT, GalA11yECellText)) -#define GAL_A11Y_E_CELL_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_CELL_TEXT, GalA11yECellTextClass)) -#define GAL_A11Y_IS_E_CELL_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_CELL_TEXT)) -#define GAL_A11Y_IS_E_CELL_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_CELL_TEXT)) - -typedef struct _GalA11yECellText GalA11yECellText; -typedef struct _GalA11yECellTextClass GalA11yECellTextClass; -typedef struct _GalA11yECellTextPrivate GalA11yECellTextPrivate; - -/* This struct should actually be larger as this isn't what we derive from. - * The GalA11yECellTextPrivate comes right after the parent class structure. - **/ -struct _GalA11yECellText { - GalA11yECell object; - gint inserted_id; - gint deleted_id; -}; - -struct _GalA11yECellTextClass { - GalA11yECellClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_cell_text_get_type (void); -AtkObject *gal_a11y_e_cell_text_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row); - -#endif /* ! __GAL_A11Y_E_CELL_TEXT_H__ */ diff --git a/a11y/e-table/gal-a11y-e-cell-toggle.c b/a11y/e-table/gal-a11y-e-cell-toggle.c deleted file mode 100644 index 23114b0373..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-toggle.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <gtk/gtk.h> - -#include "table/e-cell-toggle.h" -#include "table/e-table-model.h" -#include <glib/gi18n.h> - -#include "gal-a11y-e-cell-toggle.h" - -#define PARENT_TYPE (gal_a11y_e_cell_get_type ()) -static GObjectClass *parent_class; - -static void gal_a11y_e_cell_toggle_class_init (GalA11yECellToggleClass *klass); - -static void -gal_a11y_e_cell_toggle_dispose (GObject *object) -{ - GalA11yECellToggle *a11y = GAL_A11Y_E_CELL_TOGGLE (object); - - ETableModel *e_table_model = GAL_A11Y_E_CELL (a11y)->item->table_model; - - if (e_table_model && a11y->model_id > 0) { - g_signal_handler_disconnect (e_table_model, a11y->model_id); - a11y->model_id = 0; - } - - if (parent_class->dispose) - parent_class->dispose (object); -} - -GType -gal_a11y_e_cell_toggle_get_type (void) -{ - static GType type = 0; - - if (!type) - { - static const GTypeInfo tinfo = - { - sizeof (GalA11yECellToggleClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) gal_a11y_e_cell_toggle_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (GalA11yECellToggle), /* instance size */ - 0, /* nb preallocs */ - NULL, /* instance init */ - NULL /* value table */ - }; - - - type = g_type_register_static (GAL_A11Y_TYPE_E_CELL, - "GalA11yECellToggle", &tinfo, 0); - gal_a11y_e_cell_type_add_action_interface (type); - - } - return type; -} - - -static void -gal_a11y_e_cell_toggle_class_init (GalA11yECellToggleClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = gal_a11y_e_cell_toggle_dispose; - parent_class = g_type_class_ref (PARENT_TYPE); -} - -static void -toggle_cell_action (GalA11yECell *cell) -{ - gint finished; - GdkEventButton event; - gint x, y, width, height; - gint row, col; - - row = cell->row; - col = cell->view_col; - - e_table_item_get_cell_geometry (cell->item, &row, &col, - &x, &y, &width, &height); - - event.x = x + width / 2 + (int)(GNOME_CANVAS_ITEM (cell->item)->x1); - event.y = y + height / 2 + (int)(GNOME_CANVAS_ITEM (cell->item)->y1); - - event.type = GDK_BUTTON_PRESS; - event.window = GTK_LAYOUT(GNOME_CANVAS_ITEM(cell->item)->canvas)->bin_window; - event.button = 1; - event.send_event = TRUE; - event.time = GDK_CURRENT_TIME; - event.axes = NULL; - - g_signal_emit_by_name (cell->item, "event", &event, &finished); -} - -static void -model_change_cb (ETableModel *etm, - gint col, - gint row, - GalA11yECell *cell) -{ - gint value; - - if (col == cell->model_col && row == cell->row) { - - value = GPOINTER_TO_INT ( - e_table_model_value_at (cell->cell_view->e_table_model, - cell->model_col, cell->row)); - /* Cheat gnopernicus, or it will ignore the state change signal */ - atk_focus_tracker_notify (ATK_OBJECT (cell)); - - if (value) - gal_a11y_e_cell_add_state (cell, ATK_STATE_CHECKED, TRUE); - else - gal_a11y_e_cell_remove_state (cell, ATK_STATE_CHECKED, TRUE); - } -} - - -AtkObject* -gal_a11y_e_cell_toggle_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row) -{ - AtkObject *a11y; - GalA11yECell *cell; - GalA11yECellToggle *toggle_cell; - gint value; - - a11y = ATK_OBJECT(g_object_new (GAL_A11Y_TYPE_E_CELL_TOGGLE, NULL)); - - g_return_val_if_fail (a11y != NULL, NULL); - - cell = GAL_A11Y_E_CELL(a11y); - toggle_cell = GAL_A11Y_E_CELL_TOGGLE(a11y); - a11y->role = ATK_ROLE_TABLE_CELL; - - gal_a11y_e_cell_construct (a11y, - item, - cell_view, - parent, - model_col, - view_col, - row); - - gal_a11y_e_cell_add_action (cell, - _("toggle"), /* action name*/ - _("toggle the cell"), /* action description */ - NULL, /* action keybinding */ - toggle_cell_action); - - toggle_cell->model_id = g_signal_connect (item->table_model, - "model_cell_changed", - (GCallback) model_change_cb, - a11y); - - value = GPOINTER_TO_INT ( - e_table_model_value_at (cell->cell_view->e_table_model, - cell->model_col, cell->row)); - if (value) - gal_a11y_e_cell_add_state (cell, ATK_STATE_CHECKED, FALSE); - else - gal_a11y_e_cell_remove_state (cell, ATK_STATE_CHECKED, FALSE); - - return a11y; -} diff --git a/a11y/e-table/gal-a11y-e-cell-toggle.h b/a11y/e-table/gal-a11y-e-cell-toggle.h deleted file mode 100644 index 56483aae6b..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-toggle.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_CELL_TOGGLE_H__ -#define __GAL_A11Y_E_CELL_TOGGLE_H__ - -#include <atk/atk.h> -#include "gal-a11y-e-cell.h" -#include "gal-a11y-e-cell-toggle.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define GAL_A11Y_TYPE_E_CELL_TOGGLE (gal_a11y_e_cell_toggle_get_type ()) -#define GAL_A11Y_E_CELL_TOGGLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_CELL_TOGGLE, GalA11yECellToggle)) -#define GAL_A11Y_E_CELL_TOGGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_E_CELL_TOGGLE, GalA11yECellToggleClass)) -#define GAL_A11Y_IS_E_CELL_TOGGLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_CELL_TOGGLE)) -#define GAL_A11Y_IS_E_CELL_TOGGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_CELL_TOGGLE)) -#define GAL_A11Y_E_CELL_TOGGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAL_A11Y_TYPE_E_CELL_TOGGLE, GalA11yECellToggleClass)) - -typedef struct _GalA11yECellToggle GalA11yECellToggle; -typedef struct _GalA11yECellToggleClass GalA11yECellToggleClass; - -struct _GalA11yECellToggle -{ - GalA11yECell parent; - gint model_id; -}; - -GType gal_a11y_e_cell_toggle_get_type (void); - -struct _GalA11yECellToggleClass -{ - GalA11yECellClass parent_class; -}; - -AtkObject *gal_a11y_e_cell_toggle_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GAL_A11Y_E_CELL_TOGGLE_H__ */ diff --git a/a11y/e-table/gal-a11y-e-cell-tree.c b/a11y/e-table/gal-a11y-e-cell-tree.c deleted file mode 100644 index 520a818a37..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-tree.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Tim Wo <tim.wo@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <atk/atk.h> - -#include "a11y/gal-a11y-util.h" -#include "table/e-cell-tree.h" -#include "table/e-table.h" -#include "table/e-tree-table-adapter.h" -#include <glib/gi18n.h> - -#include "gal-a11y-e-cell-tree.h" -#include "gal-a11y-e-cell-registry.h" - -#define CS_CLASS(a11y) (G_TYPE_INSTANCE_GET_CLASS ((a11y), C_TYPE_STREAM, GalA11yECellTreeClass)) -static AtkObjectClass *a11y_parent_class; -#define A11Y_PARENT_TYPE (gal_a11y_e_cell_get_type ()) - -#define d(x) - -static void -ectr_model_row_changed_cb (ETableModel *etm, - gint row, - GalA11yECell *a11y) -{ - ETreePath node; - ETreeModel *tree_model; - ETreeTableAdapter *tree_table_adapter; - - g_return_if_fail (a11y); - if (a11y->row != row) - return; - - node = e_table_model_value_at (etm, -1, a11y->row); - tree_model = e_table_model_value_at (etm, -2, a11y->row); - tree_table_adapter = e_table_model_value_at (etm, -3, a11y->row); - - if (e_tree_model_node_is_expandable (tree_model, node)) { - gboolean is_exp = e_tree_table_adapter_node_is_expanded (tree_table_adapter, node); - if (is_exp) - gal_a11y_e_cell_add_state (a11y, ATK_STATE_EXPANDED, TRUE); - else - gal_a11y_e_cell_remove_state (a11y, ATK_STATE_EXPANDED, TRUE); - } -} - -static void -kill_view_cb(ECellView *subcell_view, - gpointer psubcell_a11ies) -{ - GList *node; - GList *subcell_a11ies = (GList *) psubcell_a11ies; - GalA11yECell *subcell; - - for (node = subcell_a11ies; node != NULL; node = g_list_next (node)) - { - subcell = GAL_A11Y_E_CELL(node->data); - if (subcell && subcell->cell_view == subcell_view) - { - d(fprintf(stderr, "subcell_view %p deleted before the a11y object %p\n", subcell_view, subcell)); - subcell->cell_view = NULL; - } - } -} - -static void -ectr_subcell_weak_ref (GalA11yECellTree *a11y, - GalA11yECell *subcell_a11y) -{ - ECellView *subcell_view = subcell_a11y ? subcell_a11y->cell_view : NULL; - if (subcell_a11y && subcell_view && subcell_view->kill_view_cb_data) - subcell_view->kill_view_cb_data = g_list_remove(subcell_view->kill_view_cb_data, subcell_a11y); - - g_signal_handler_disconnect (GAL_A11Y_E_CELL (a11y)->item->table_model, - a11y->model_row_changed_id); - g_object_unref (a11y); -} - -static void -ectr_do_action_expand (AtkAction *action) -{ - GalA11yECell *a11y; - ETableModel *table_model; - ETreePath node; - ETreeModel *tree_model; - ETreeTableAdapter *tree_table_adapter; - - a11y = GAL_A11Y_E_CELL (action); - table_model = a11y->item->table_model; - node = e_table_model_value_at (table_model, -1, a11y->row); - tree_model = e_table_model_value_at (table_model, -2, a11y->row); - tree_table_adapter = e_table_model_value_at (table_model, -3, a11y->row); - - if (e_tree_model_node_is_expandable (tree_model, node)) { - e_tree_table_adapter_node_set_expanded (tree_table_adapter, - node, - TRUE); - gal_a11y_e_cell_add_state (a11y, ATK_STATE_EXPANDED, TRUE); - } -} - -static void -ectr_do_action_collapse (AtkAction *action) -{ - GalA11yECell *a11y; - ETableModel *table_model; - ETreePath node; - ETreeModel *tree_model; - ETreeTableAdapter *tree_table_adapter; - - a11y = GAL_A11Y_E_CELL (action); - table_model = a11y->item->table_model; - node = e_table_model_value_at (table_model, -1, a11y->row); - tree_model = e_table_model_value_at (table_model, -2, a11y->row); - tree_table_adapter = e_table_model_value_at (table_model, -3, a11y->row); - - if (e_tree_model_node_is_expandable (tree_model, node)) { - e_tree_table_adapter_node_set_expanded (tree_table_adapter, - node, - FALSE); - gal_a11y_e_cell_remove_state (a11y, ATK_STATE_EXPANDED, TRUE); - } -} - -static void -ectr_class_init (GalA11yECellTreeClass *klass) -{ - a11y_parent_class = g_type_class_ref (A11Y_PARENT_TYPE); -} - -static void -ectr_init (GalA11yECellTree *a11y) -{ -} - -GType -gal_a11y_e_cell_tree_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yECellTreeClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ectr_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yECellTree), - 0, - (GInstanceInitFunc) ectr_init, - NULL /* value_cell_text */ - }; - - type = g_type_register_static (A11Y_PARENT_TYPE, "GalA11yECellTree", &info, 0); - gal_a11y_e_cell_type_add_action_interface (type); - } - - return type; -} - -AtkObject * -gal_a11y_e_cell_tree_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row) -{ - AtkObject *subcell_a11y; - GalA11yECellTree *a11y; - - ETreePath node; - ETreeModel *tree_model; - ETreeTableAdapter *tree_table_adapter; - - ECellView *subcell_view; - subcell_view = e_cell_tree_view_get_subcell_view (cell_view); - - if (subcell_view->ecell) { - subcell_a11y = gal_a11y_e_cell_registry_get_object (NULL, - item, - subcell_view, - parent, - model_col, - view_col, - row); - gal_a11y_e_cell_add_action (GAL_A11Y_E_CELL (subcell_a11y), - _("expand"), - _("expands the row in the ETree containing this cell"), - NULL, - (ACTION_FUNC)ectr_do_action_expand); - - gal_a11y_e_cell_add_action (GAL_A11Y_E_CELL (subcell_a11y), - _("collapse"), - _("collapses the row in the ETree containing this cell"), - NULL, - (ACTION_FUNC)ectr_do_action_collapse); - - /* init AtkStates for the cell's a11y object */ - node = e_table_model_value_at (item->table_model, -1, row); - tree_model = e_table_model_value_at (item->table_model, -2, row); - tree_table_adapter = e_table_model_value_at (item->table_model, -3, row); - if (e_tree_model_node_is_expandable (tree_model, node)) { - gal_a11y_e_cell_add_state (GAL_A11Y_E_CELL (subcell_a11y), ATK_STATE_EXPANDABLE, FALSE); - if (e_tree_table_adapter_node_is_expanded (tree_table_adapter, node)) - gal_a11y_e_cell_add_state (GAL_A11Y_E_CELL (subcell_a11y), ATK_STATE_EXPANDED, FALSE); - } - } - else - subcell_a11y = NULL; - - /* create a companion a11y object, this object has type GalA11yECellTree - and it connects to some signals to determine whether a tree cell is - expanded or collapsed */ - a11y = g_object_new (gal_a11y_e_cell_tree_get_type (), NULL); - gal_a11y_e_cell_construct (ATK_OBJECT (a11y), - item, - cell_view, - parent, - model_col, - view_col, - row); - a11y->model_row_changed_id = - g_signal_connect (item->table_model, "model_row_changed", - G_CALLBACK (ectr_model_row_changed_cb), - subcell_a11y); - - if (subcell_a11y && subcell_view) - { - subcell_view->kill_view_cb = kill_view_cb; - if (!g_list_find(subcell_view->kill_view_cb_data, subcell_a11y)) - subcell_view->kill_view_cb_data = g_list_append(subcell_view->kill_view_cb_data, subcell_a11y); - } - - g_object_weak_ref (G_OBJECT (subcell_a11y), (GWeakNotify) ectr_subcell_weak_ref, a11y); - - return subcell_a11y; -} diff --git a/a11y/e-table/gal-a11y-e-cell-tree.h b/a11y/e-table/gal-a11y-e-cell-tree.h deleted file mode 100644 index f6f6d9dd70..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-tree.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Tim Wo <tim.wo@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_CELL_TREE_H__ -#define __GAL_A11Y_E_CELL_TREE_H__ - -#include <glib-object.h> -#include <table/e-table-item.h> -#include <table/e-cell-tree.h> -#include "gal-a11y-e-cell.h" - -#define GAL_A11Y_TYPE_E_CELL_TREE (gal_a11y_e_cell_tree_get_type ()) -#define GAL_A11Y_E_CELL_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_CELL_TREE, GalA11yECellTree)) -#define GAL_A11Y_E_CELL_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_CELL_TREE, GalA11yECellTreeClass)) -#define GAL_A11Y_IS_E_CELL_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_CELL_TREE)) -#define GAL_A11Y_IS_E_CELL_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_CELL_TREE)) - -typedef struct _GalA11yECellTree GalA11yECellTree; -typedef struct _GalA11yECellTreeClass GalA11yECellTreeClass; -typedef struct _GalA11yECellTreePrivate GalA11yECellTreePrivate; - -/* This struct should actually be larger as this isn't what we derive from. - * The GalA11yECellTreePrivate comes right after the parent class structure. - **/ -struct _GalA11yECellTree { - GalA11yECell object; - - int model_row_changed_id; -}; - -struct _GalA11yECellTreeClass { - GalA11yECellClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_cell_tree_get_type (void); -AtkObject *gal_a11y_e_cell_tree_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row); - -#endif /* ! __GAL_A11Y_E_CELL_TREE_H__ */ diff --git a/a11y/e-table/gal-a11y-e-cell-vbox.c b/a11y/e-table/gal-a11y-e-cell-vbox.c deleted file mode 100644 index 08859d07ef..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-vbox.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Eric Zhao <eric.zhao@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * Copyright (C) 2004 Sun Microsystem, Inc. - * - */ - -#include <config.h> - -#include <atk/atk.h> - -#include "table/e-cell-vbox.h" - -#include "gal-a11y-e-cell-registry.h" -#include "gal-a11y-e-cell-vbox.h" - -static GObjectClass *parent_class; -static AtkComponentIface *component_parent_iface; -#define PARENT_TYPE (gal_a11y_e_cell_get_type ()) - -static gint -ecv_get_n_children (AtkObject *a11y) -{ - g_return_val_if_fail (GAL_A11Y_IS_E_CELL_VBOX (a11y), 0); - - return GAL_A11Y_E_CELL_VBOX (a11y)->a11y_subcell_count; -} - -static void -subcell_destroyed (gpointer data) -{ - GalA11yECell *cell; - AtkObject *parent; - GalA11yECellVbox *gaev; - - g_return_if_fail (GAL_A11Y_IS_E_CELL (data)); - cell = GAL_A11Y_E_CELL (data); - - parent = atk_object_get_parent (ATK_OBJECT (cell)); - g_return_if_fail (GAL_A11Y_IS_E_CELL_VBOX (parent)); - gaev = GAL_A11Y_E_CELL_VBOX (parent); - - if (cell->view_col < gaev->a11y_subcell_count) - gaev->a11y_subcells[cell->view_col] = NULL; -} - -static AtkObject* -ecv_ref_child (AtkObject *a11y, gint i) -{ - GalA11yECellVbox *gaev = GAL_A11Y_E_CELL_VBOX (a11y); - GalA11yECell *gaec = GAL_A11Y_E_CELL (a11y); - ECellVboxView *ecvv = (ECellVboxView *) (gaec->cell_view); - AtkObject *ret; - if (i < gaev->a11y_subcell_count) { - if (gaev->a11y_subcells[i] == NULL) { - ECellView *subcell_view; - gint model_col, row; - row = gaec->row; - model_col = ecvv->model_cols[i]; - subcell_view = ecvv->subcell_views[i]; - ret = gal_a11y_e_cell_registry_get_object (NULL, - gaec->item, - subcell_view, - a11y, - model_col, - gaec->view_col, /* FIXME should the view column use a fake one or the same as its parent? */ - row); - gaev->a11y_subcells[i] = ret; - g_object_ref (ret); - g_object_weak_ref (G_OBJECT (ret), - (GWeakNotify) subcell_destroyed, - ret); - } else { - ret = (AtkObject *) gaev->a11y_subcells[i]; - if (ATK_IS_OBJECT (ret)) - g_object_ref (ret); - else - ret = NULL; - } - } else { - ret = NULL; - } - - return ret; -} - -static void -ecv_dispose (GObject *object) -{ - GalA11yECellVbox *gaev = GAL_A11Y_E_CELL_VBOX (object); - if (gaev->a11y_subcells) - g_free (gaev->a11y_subcells); - - if (parent_class->dispose) - parent_class->dispose (object); -} - -/* AtkComponet interface */ -static AtkObject* -ecv_ref_accessible_at_point (AtkComponent *component, - gint x, - gint y, - AtkCoordType coord_type) -{ - gint x0, y0, width, height; - int subcell_height, i; - - GalA11yECell *gaec = GAL_A11Y_E_CELL (component); - ECellVboxView *ecvv = (ECellVboxView *) (gaec->cell_view); - - atk_component_get_extents (component, &x0, &y0, &width, &height, coord_type); - x -= x0; - y -= y0; - if (x < 0 || x > width || y < 0 || y > height) - return NULL; - - for (i = 0; i < ecvv->subcell_view_count; i++) { - subcell_height = e_cell_height (ecvv->subcell_views[i], ecvv->model_cols[i], gaec->view_col, gaec->row); - if ( 0 <= y && y <= subcell_height) { - return ecv_ref_child ((AtkObject *)component, i); - } else - y -= subcell_height; - } - - return NULL; -} - -static void -ecv_class_init (GalA11yECellVboxClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - AtkObjectClass *a11y_class = ATK_OBJECT_CLASS (klass); - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->dispose = ecv_dispose; - - a11y_class->get_n_children = ecv_get_n_children; - a11y_class->ref_child = ecv_ref_child; -} - -static void -ecv_init (GalA11yECellVbox *a11y) -{ -} - -static void -ecv_atk_component_iface_init (AtkComponentIface *iface) -{ - component_parent_iface = g_type_interface_peek_parent (iface); - - iface->ref_accessible_at_point = ecv_ref_accessible_at_point; -} - -GType -gal_a11y_e_cell_vbox_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (GalA11yECellVboxClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) ecv_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yECellVbox), - 0, - (GInstanceInitFunc) ecv_init, - NULL /* value_cell */ - }; - - static const GInterfaceInfo atk_component_info = { - (GInterfaceInitFunc) ecv_atk_component_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - type = g_type_register_static (PARENT_TYPE, "GalA11yECellVbox", &info, 0); - gal_a11y_e_cell_type_add_action_interface (type); - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, &atk_component_info); - } - - return type; -} - -AtkObject *gal_a11y_e_cell_vbox_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row) -{ - AtkObject *a11y; - GalA11yECell *gaec; - GalA11yECellVbox *gaev; - ECellVboxView *ecvv; - - a11y = g_object_new (gal_a11y_e_cell_vbox_get_type (), NULL); - - gal_a11y_e_cell_construct (a11y, item, cell_view, parent, model_col, view_col, row); - - gaec = GAL_A11Y_E_CELL (a11y); - gaev = GAL_A11Y_E_CELL_VBOX (a11y); - ecvv = (ECellVboxView *) (gaec->cell_view); - gaev->a11y_subcell_count = ecvv->subcell_view_count; - gaev->a11y_subcells = g_malloc0 (sizeof(AtkObject *)*gaev->a11y_subcell_count); - return a11y; -} diff --git a/a11y/e-table/gal-a11y-e-cell-vbox.h b/a11y/e-table/gal-a11y-e-cell-vbox.h deleted file mode 100644 index 276a60177a..0000000000 --- a/a11y/e-table/gal-a11y-e-cell-vbox.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Eric Zhao <eric.zhao@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * Copyright (C) 2004 Sun Microsystem, Inc. - * - */ - -#ifndef __GAL_A11Y_E_CELL_VBOX_H__ -#define __GAL_A11Y_E_CELL_VBOX_H__ - -#include "gal-a11y-e-cell.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define GAL_A11Y_TYPE_E_CELL_VBOX (gal_a11y_e_cell_vbox_get_type ()) -#define GAL_A11Y_E_CELL_VBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_CELL_VBOX, GalA11yECellVbox)) -#define GAL_A11Y_E_CELL_VBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_E_CELL_VBOX, GalA11yECellVboxClass)) -#define GAL_A11Y_IS_E_CELL_VBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_CELL_VBOX)) -#define GAL_A11Y_IS_E_CELL_VBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_CELL_VBOX)) -#define GAL_A11Y_E_CELL_VBOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAL_A11Y_TYPE_E_CELL_VBOX, GalA11yECellVboxClass)) - -typedef struct _GalA11yECellVbox GalA11yECellVbox; -typedef struct _GalA11yECellVboxClass GalA11yECellVboxClass; - -struct _GalA11yECellVbox -{ - GalA11yECell object; - int a11y_subcell_count; - gpointer *a11y_subcells; -}; - -struct _GalA11yECellVboxClass -{ - GalA11yECellClass parent_class; -}; - -GType gal_a11y_e_cell_vbox_get_type (void); -AtkObject *gal_a11y_e_cell_vbox_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __GAL_A11Y_E_CELL_VBOX_H__ */ diff --git a/a11y/e-table/gal-a11y-e-cell.c b/a11y/e-table/gal-a11y-e-cell.c deleted file mode 100644 index 6154fc0acd..0000000000 --- a/a11y/e-table/gal-a11y-e-cell.c +++ /dev/null @@ -1,644 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <string.h> - -#include <gtk/gtk.h> - -#include "a11y/gal-a11y-util.h" -#include "table/e-table.h" -#include "table/e-tree.h" -#include <glib/gi18n.h> - -#include "gal-a11y-e-cell.h" -#include "gal-a11y-e-cell-vbox.h" -#include "gal-a11y-e-table-item.h" - -#define CS_CLASS(a11y) (G_TYPE_INSTANCE_GET_CLASS ((a11y), C_TYPE_STREAM, GalA11yECellClass)) -static GObjectClass *parent_class; -#define PARENT_TYPE (atk_object_get_type ()) - - -#if 0 -static void -unref_item (gpointer user_data, GObject *obj_loc) -{ - GalA11yECell *a11y = GAL_A11Y_E_CELL (user_data); - a11y->item = NULL; - g_object_unref (a11y); -} - -static void -unref_cell (gpointer user_data, GObject *obj_loc) -{ - GalA11yECell *a11y = GAL_A11Y_E_CELL (user_data); - a11y->cell_view = NULL; - g_object_unref (a11y); -} -#endif - -static gboolean -is_valid (AtkObject *cell) -{ - GalA11yECell *a11y = GAL_A11Y_E_CELL (cell); - GalA11yETableItem *a11yItem = GAL_A11Y_E_TABLE_ITEM (a11y->parent); - AtkStateSet *item_ss; - gboolean ret = TRUE; - - item_ss = atk_object_ref_state_set (ATK_OBJECT (a11yItem)); - if (atk_state_set_contains_state (item_ss, ATK_STATE_DEFUNCT)) - ret = FALSE; - - g_object_unref (item_ss); - - if (ret && atk_state_set_contains_state (a11y->state_set, ATK_STATE_DEFUNCT)) - ret = FALSE; - - return ret; -} - -static void -gal_a11y_e_cell_dispose (GObject *object) -{ - GalA11yECell *a11y = GAL_A11Y_E_CELL (object); - -#if 0 - if (a11y->item) - g_object_unref (G_OBJECT (a11y->item)); /*, unref_item, a11y); */ - if (a11y->cell_view) - g_object_unref (G_OBJECT (a11y->cell_view)); /*, unref_cell, a11y); */ - if (a11y->parent) - g_object_unref (a11y->parent); -#endif - - if (a11y->state_set) { - g_object_unref (a11y->state_set); - a11y->state_set = NULL; - } - - if (parent_class->dispose) - parent_class->dispose (object); - -} - -/* Static functions */ -static G_CONST_RETURN gchar* -gal_a11y_e_cell_get_name (AtkObject * a11y) -{ - GalA11yECell *cell = GAL_A11Y_E_CELL (a11y); - ETableCol *ecol; - - if (a11y->name != NULL && strcmp (a11y->name, "")) - return a11y->name; - - if (cell->item != NULL) { - ecol = e_table_header_get_column (cell->item->header, cell->view_col); - if (ecol != NULL) - return ecol->text; - } - - return _("Table Cell"); -} - -static AtkStateSet * -gal_a11y_e_cell_ref_state_set (AtkObject *accessible) -{ - GalA11yECell *cell = GAL_A11Y_E_CELL (accessible); - - g_return_val_if_fail (cell->state_set, NULL); - - g_object_ref(cell->state_set); - - return cell->state_set; -} - -static AtkObject* -gal_a11y_e_cell_get_parent (AtkObject *accessible) -{ - GalA11yECell *a11y = GAL_A11Y_E_CELL (accessible); - return a11y->parent; -} - -static gint -gal_a11y_e_cell_get_index_in_parent (AtkObject *accessible) -{ - GalA11yECell *a11y = GAL_A11Y_E_CELL (accessible); - - if (!is_valid (accessible)) - return -1; - - return (a11y->row + 1) * a11y->item->cols + a11y->view_col; -} - - -/* Component IFace */ -static void -gal_a11y_e_cell_get_extents (AtkComponent *component, - gint *x, - gint *y, - gint *width, - gint *height, - AtkCoordType coord_type) -{ - GalA11yECell *a11y = GAL_A11Y_E_CELL (component); - GtkWidget *tableOrTree; - int row; - int col; - int xval; - int yval; - - row = a11y->row; - col = a11y->view_col; - - tableOrTree = gtk_widget_get_parent (GTK_WIDGET (a11y->item->parent.canvas)); - if (E_IS_TREE (tableOrTree)) { - e_tree_get_cell_geometry (E_TREE (tableOrTree), - row, col, &xval, &yval, - width, height); - } else { - e_table_get_cell_geometry (E_TABLE (tableOrTree), - row, col, &xval, &yval, - width, height); - } - - atk_component_get_position (ATK_COMPONENT (a11y->parent), - x, y, coord_type); - if (x && *x != G_MININT) - *x += xval; - if (y && *y != G_MININT) - *y += yval; -} - -static gboolean -gal_a11y_e_cell_grab_focus (AtkComponent *component) -{ - GalA11yECell *a11y; - gint index; - GtkWidget *toplevel; - GalA11yETableItem *a11yTableItem; - - a11y = GAL_A11Y_E_CELL (component); - - /* for e_cell_vbox's children, we just grab the e_cell_vbox */ - if (GAL_A11Y_IS_E_CELL_VBOX (a11y->parent)) { - return atk_component_grab_focus (ATK_COMPONENT (a11y->parent)); - } - - a11yTableItem = GAL_A11Y_E_TABLE_ITEM (a11y->parent); - index = atk_object_get_index_in_parent (ATK_OBJECT (a11y)); - - atk_selection_clear_selection (ATK_SELECTION (a11yTableItem)); - atk_selection_add_selection (ATK_SELECTION (a11yTableItem), index); - - gtk_widget_grab_focus (GTK_WIDGET (GNOME_CANVAS_ITEM (a11y->item)->canvas)); - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (GNOME_CANVAS_ITEM (a11y->item)->canvas)); - if (toplevel && GTK_WIDGET_TOPLEVEL (toplevel)) - gtk_window_present (GTK_WINDOW (toplevel)); - - return TRUE; -} - -/* Table IFace */ - -static void -gal_a11y_e_cell_atk_component_iface_init (AtkComponentIface *iface) -{ - iface->get_extents = gal_a11y_e_cell_get_extents; - iface->grab_focus = gal_a11y_e_cell_grab_focus; -} - -static void -gal_a11y_e_cell_class_init (GalA11yECellClass *klass) -{ - AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->dispose = gal_a11y_e_cell_dispose; - - atk_object_class->get_parent = gal_a11y_e_cell_get_parent; - atk_object_class->get_index_in_parent = gal_a11y_e_cell_get_index_in_parent; - atk_object_class->ref_state_set = gal_a11y_e_cell_ref_state_set; - atk_object_class->get_name = gal_a11y_e_cell_get_name; -} - -static void -gal_a11y_e_cell_init (GalA11yECell *a11y) -{ - a11y->item = NULL; - a11y->cell_view = NULL; - a11y->parent = NULL; - a11y->model_col = -1; - a11y->view_col = -1; - a11y->row = -1; - - a11y->state_set = atk_state_set_new (); - atk_state_set_add_state (a11y->state_set, ATK_STATE_TRANSIENT); - atk_state_set_add_state (a11y->state_set, ATK_STATE_ENABLED); - atk_state_set_add_state (a11y->state_set, ATK_STATE_SENSITIVE); - atk_state_set_add_state (a11y->state_set, ATK_STATE_SELECTABLE); - atk_state_set_add_state (a11y->state_set, ATK_STATE_SHOWING); - atk_state_set_add_state (a11y->state_set, ATK_STATE_FOCUSABLE); - atk_state_set_add_state (a11y->state_set, ATK_STATE_VISIBLE); -} - - -static ActionInfo * -_gal_a11y_e_cell_get_action_info (GalA11yECell *cell, - gint index) -{ - GList *list_node; - - g_return_val_if_fail (GAL_A11Y_IS_E_CELL (cell), NULL); - if (cell->action_list == NULL) - return NULL; - list_node = g_list_nth (cell->action_list, index); - if (!list_node) - return NULL; - return (ActionInfo *) (list_node->data); -} - -static void -_gal_a11y_e_cell_destroy_action_info (gpointer action_info, - gpointer user_data) -{ - ActionInfo *info = (ActionInfo *)action_info; - - g_return_if_fail (info != NULL); - g_free (info->name); - g_free (info->description); - g_free (info->keybinding); - g_free (info); -} - - -gboolean -gal_a11y_e_cell_add_action ( GalA11yECell * cell, - const gchar *action_name, - const gchar *action_description, - const gchar *action_keybinding, - ACTION_FUNC action_func) -{ - ActionInfo *info; - g_return_val_if_fail (GAL_A11Y_IS_E_CELL (cell), FALSE); - info = g_new (ActionInfo, 1); - - if (action_name != NULL) - info->name = g_strdup (action_name); - else - info->name = NULL; - - if (action_description != NULL) - info->description = g_strdup (action_description); - else - info->description = NULL; - if (action_keybinding != NULL) - info->keybinding = g_strdup (action_keybinding); - else - info->keybinding = NULL; - info->do_action_func = action_func; - - cell->action_list = g_list_append (cell->action_list, (gpointer) info); - return TRUE; -} - -gboolean -gal_a11y_e_cell_remove_action (GalA11yECell *cell, - gint action_index) -{ - GList *list_node; - - g_return_val_if_fail (GAL_A11Y_IS_E_CELL (cell), FALSE); - list_node = g_list_nth (cell->action_list, action_index); - if (!list_node) - return FALSE; - g_return_val_if_fail (list_node->data != NULL, FALSE); - _gal_a11y_e_cell_destroy_action_info (list_node->data, NULL); - cell->action_list = g_list_remove_link (cell->action_list, list_node); - - return TRUE; -} - -gboolean -gal_a11y_e_cell_remove_action_by_name (GalA11yECell *cell, - const gchar *action_name) -{ - GList *list_node; - gboolean action_found= FALSE; - - g_return_val_if_fail (GAL_A11Y_IS_E_CELL (cell), FALSE); - for (list_node = cell->action_list; list_node && !action_found; - list_node = list_node->next) { - if (!g_ascii_strcasecmp (((ActionInfo *)(list_node->data))->name, action_name)) { - action_found = TRUE; - break; - } - } - - g_return_val_if_fail (action_found, FALSE); - _gal_a11y_e_cell_destroy_action_info (list_node->data, NULL); - cell->action_list = g_list_remove_link (cell->action_list, list_node); - - return TRUE; -} - -static gint -gal_a11y_e_cell_action_get_n_actions (AtkAction *action) -{ - GalA11yECell *cell = GAL_A11Y_E_CELL(action); - if (cell->action_list != NULL) - return g_list_length (cell->action_list); - else - return 0; -} - -static G_CONST_RETURN gchar * -gal_a11y_e_cell_action_get_name (AtkAction *action, - gint index) -{ - GalA11yECell *cell = GAL_A11Y_E_CELL(action); - ActionInfo *info = _gal_a11y_e_cell_get_action_info (cell, index); - - if (info == NULL) - return NULL; - return info->name; -} - -static G_CONST_RETURN gchar * -gal_a11y_e_cell_action_get_description (AtkAction *action, - gint index) -{ - GalA11yECell *cell = GAL_A11Y_E_CELL(action); - ActionInfo *info = _gal_a11y_e_cell_get_action_info (cell, index); - - if (info == NULL) - return NULL; - return info->description; -} - -static gboolean -gal_a11y_e_cell_action_set_description (AtkAction *action, - gint index, - const gchar *desc) -{ - GalA11yECell *cell = GAL_A11Y_E_CELL(action); - ActionInfo *info = _gal_a11y_e_cell_get_action_info (cell, index); - - if (info == NULL) - return FALSE; - g_free (info->description); - info->description = g_strdup (desc); - return TRUE; -} - -static G_CONST_RETURN gchar * -gal_a11y_e_cell_action_get_keybinding (AtkAction *action, - gint index) -{ - GalA11yECell *cell = GAL_A11Y_E_CELL(action); - ActionInfo *info = _gal_a11y_e_cell_get_action_info (cell, index); - if (info == NULL) - return NULL; - - return info->keybinding; -} - -static gboolean -idle_do_action (gpointer data) -{ - GalA11yECell *cell; - - cell = GAL_A11Y_E_CELL (data); - - if (!is_valid (ATK_OBJECT (cell))) - return FALSE; - - cell->action_idle_handler = 0; - cell->action_func (cell); - g_object_unref (cell); - - return FALSE; -} - -static gboolean -gal_a11y_e_cell_action_do_action (AtkAction *action, - gint index) -{ - GalA11yECell *cell = GAL_A11Y_E_CELL(action); - ActionInfo *info = _gal_a11y_e_cell_get_action_info (cell, index); - - if (!is_valid (ATK_OBJECT (action))) - return FALSE; - - if (info == NULL) - return FALSE; - g_return_val_if_fail (info->do_action_func, FALSE); - if (cell->action_idle_handler) - return FALSE; - cell->action_func = info->do_action_func; - g_object_ref (cell); - cell->action_idle_handler = g_idle_add (idle_do_action, cell); - - return TRUE; -} - -static void -gal_a11y_e_cell_atk_action_interface_init (AtkActionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->get_n_actions = gal_a11y_e_cell_action_get_n_actions; - iface->do_action = gal_a11y_e_cell_action_do_action; - iface->get_name = gal_a11y_e_cell_action_get_name; - iface->get_description = gal_a11y_e_cell_action_get_description; - iface->set_description = gal_a11y_e_cell_action_set_description; - iface->get_keybinding = gal_a11y_e_cell_action_get_keybinding; -} - -void -gal_a11y_e_cell_type_add_action_interface (GType type) -{ - static const GInterfaceInfo atk_action_info = - { - (GInterfaceInitFunc) gal_a11y_e_cell_atk_action_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - g_type_add_interface_static (type, ATK_TYPE_ACTION, - &atk_action_info); -} - -gboolean -gal_a11y_e_cell_add_state (GalA11yECell *cell, - AtkStateType state_type, - gboolean emit_signal) -{ - if (!atk_state_set_contains_state (cell->state_set, state_type)) { - gboolean rc; - - rc = atk_state_set_add_state (cell->state_set, state_type); - /* - * The signal should only be generated if the value changed, - * not when the cell is set up. So states that are set - * initially should pass FALSE as the emit_signal argument. - */ - - if (emit_signal) { - atk_object_notify_state_change (ATK_OBJECT (cell), state_type, TRUE); - /* If state_type is ATK_STATE_VISIBLE, additional - notification */ - if (state_type == ATK_STATE_VISIBLE) - g_signal_emit_by_name (cell, "visible_data_changed"); - } - - return rc; - } - else - return FALSE; -} - -gboolean -gal_a11y_e_cell_remove_state (GalA11yECell *cell, - AtkStateType state_type, - gboolean emit_signal) -{ - if (atk_state_set_contains_state (cell->state_set, state_type)) { - gboolean rc; - - rc = atk_state_set_remove_state (cell->state_set, state_type); - /* - * The signal should only be generated if the value changed, - * not when the cell is set up. So states that are set - * initially should pass FALSE as the emit_signal argument. - */ - - if (emit_signal) { - atk_object_notify_state_change (ATK_OBJECT (cell), state_type, FALSE); - /* If state_type is ATK_STATE_VISIBLE, additional notification */ - if (state_type == ATK_STATE_VISIBLE) - g_signal_emit_by_name (cell, "visible_data_changed"); - } - - return rc; - } - else - return FALSE; -} - -/** - * gal_a11y_e_cell_get_type: - * @void: - * - * Registers the &GalA11yECell class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yECell class. - **/ -GType -gal_a11y_e_cell_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yECellClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gal_a11y_e_cell_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yECell), - 0, - (GInstanceInitFunc) gal_a11y_e_cell_init, - NULL /* value_cell */ - }; - - static const GInterfaceInfo atk_component_info = { - (GInterfaceInitFunc) gal_a11y_e_cell_atk_component_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - type = g_type_register_static (PARENT_TYPE, "GalA11yECell", &info, 0); - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, &atk_component_info); - } - - return type; -} - -AtkObject * -gal_a11y_e_cell_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row) -{ - AtkObject *a11y; - - a11y = g_object_new (gal_a11y_e_cell_get_type (), NULL); - - gal_a11y_e_cell_construct (a11y, - item, - cell_view, - parent, - model_col, - view_col, - row); - return a11y; -} - -void -gal_a11y_e_cell_construct (AtkObject *object, - ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row) -{ - GalA11yECell *a11y = GAL_A11Y_E_CELL (object); - a11y->item = item; - a11y->cell_view = cell_view; - a11y->parent = parent; - a11y->model_col = model_col; - a11y->view_col = view_col; - a11y->row = row; - ATK_OBJECT (a11y) ->role = ATK_ROLE_TABLE_CELL; - - if (item) - g_object_ref (G_OBJECT (item)); - -#if 0 - if (parent) - g_object_ref (parent); - - if (cell_view) - g_object_ref (G_OBJECT (cell_view)); - - -#endif -} diff --git a/a11y/e-table/gal-a11y-e-cell.h b/a11y/e-table/gal-a11y-e-cell.h deleted file mode 100644 index cdae721112..0000000000 --- a/a11y/e-table/gal-a11y-e-cell.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_CELL_H__ -#define __GAL_A11Y_E_CELL_H__ - -#include <glib-object.h> -#include <table/e-table-item.h> -#include <table/e-cell.h> - -#define GAL_A11Y_TYPE_E_CELL (gal_a11y_e_cell_get_type ()) -#define GAL_A11Y_E_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_CELL, GalA11yECell)) -#define GAL_A11Y_E_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_CELL, GalA11yECellClass)) -#define GAL_A11Y_IS_E_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_CELL)) -#define GAL_A11Y_IS_E_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_CELL)) - -typedef struct _GalA11yECell GalA11yECell; -typedef struct _GalA11yECellClass GalA11yECellClass; -typedef struct _GalA11yECellPrivate GalA11yECellPrivate; -typedef struct _ActionInfo ActionInfo; -typedef void (*ACTION_FUNC) (GalA11yECell *cell); - - -/* This struct should actually be larger as this isn't what we derive from. - * The GalA11yECellPrivate comes right after the parent class structure. - **/ -struct _GalA11yECell { - AtkObject object; - - ETableItem *item; - ECellView *cell_view; - AtkObject *parent; - int model_col; - int view_col; - int row; - AtkStateSet *state_set; - GList *action_list; - gint action_idle_handler; - ACTION_FUNC action_func; -}; - -struct _GalA11yECellClass { - AtkObjectClass parent_class; -}; - -struct _ActionInfo { - gchar *name; - gchar *description; - gchar *keybinding; - ACTION_FUNC do_action_func; -}; - - - -/* Standard Glib function */ -GType gal_a11y_e_cell_get_type (void); -AtkObject *gal_a11y_e_cell_new (ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row); -void gal_a11y_e_cell_construct (AtkObject *object, - ETableItem *item, - ECellView *cell_view, - AtkObject *parent, - int model_col, - int view_col, - int row); - -void gal_a11y_e_cell_type_add_action_interface (GType type); - -gboolean gal_a11y_e_cell_add_action (GalA11yECell *cell, - const gchar *action_name, - const gchar *action_description, - const gchar *action_keybinding, - ACTION_FUNC action_func); - -gboolean gal_a11y_e_cell_remove_action (GalA11yECell *cell, - gint action_id); - -gboolean gal_a11y_e_cell_remove_action_by_name (GalA11yECell *cell, - const gchar *action_name); - -gboolean gal_a11y_e_cell_add_state (GalA11yECell *cell, - AtkStateType state_type, - gboolean emit_signal); - -gboolean gal_a11y_e_cell_remove_state (GalA11yECell *cell, - AtkStateType state_type, - gboolean emit_signal); - - -#endif /* ! __GAL_A11Y_E_CELL_H__ */ diff --git a/a11y/e-table/gal-a11y-e-table-click-to-add-factory.c b/a11y/e-table/gal-a11y-e-table-click-to-add-factory.c deleted file mode 100644 index 9161b4d834..0000000000 --- a/a11y/e-table/gal-a11y-e-table-click-to-add-factory.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yuedong Du <yuedong.du@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <atk/atk.h> - -#include "table/e-table.h" -#include "table/e-table-click-to-add.h" - -#include "gal-a11y-e-table.h" -#include "gal-a11y-e-table-click-to-add.h" -#include "gal-a11y-e-table-click-to-add-factory.h" - -#define CS_CLASS(factory) (G_TYPE_INSTANCE_GET_CLASS ((factory), C_TYPE_STREAM, GalA11yETableClickToAddFactoryClass)) -static AtkObjectFactoryClass *parent_class; -#define PARENT_TYPE (ATK_TYPE_OBJECT_FACTORY) - -/* Static functions */ - -static GType -gal_a11y_e_table_click_to_add_factory_get_accessible_type (void) -{ - return GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD; -} - -static AtkObject* -gal_a11y_e_table_click_to_add_factory_create_accessible (GObject *obj) -{ - AtkObject * atk_object; - - g_return_val_if_fail (E_IS_TABLE_CLICK_TO_ADD(obj), NULL); - - atk_object = gal_a11y_e_table_click_to_add_new (obj); - - return atk_object; -} - -static void -gal_a11y_e_table_click_to_add_factory_class_init (GalA11yETableClickToAddFactoryClass *klass) -{ - AtkObjectFactoryClass *factory_class = ATK_OBJECT_FACTORY_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - factory_class->create_accessible = gal_a11y_e_table_click_to_add_factory_create_accessible; - factory_class->get_accessible_type = gal_a11y_e_table_click_to_add_factory_get_accessible_type; -} - -static void -gal_a11y_e_table_click_to_add_factory_init (GalA11yETableClickToAddFactory *factory) -{ -} - -/** - * gal_a11y_e_table_factory_get_type: - * @void: - * - * Registers the &GalA11yETableFactory class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yETableFactory class. - **/ -GType -gal_a11y_e_table_click_to_add_factory_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yETableClickToAddFactoryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gal_a11y_e_table_click_to_add_factory_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yETableClickToAddFactory), - 0, - (GInstanceInitFunc) gal_a11y_e_table_click_to_add_factory_init, - NULL /* value_table */ - }; - - type = g_type_register_static (PARENT_TYPE, "GalA11yETableClickToAddFactory", &info, 0); - } - - return type; -} diff --git a/a11y/e-table/gal-a11y-e-table-click-to-add-factory.h b/a11y/e-table/gal-a11y-e-table-click-to-add-factory.h deleted file mode 100644 index 0e4ac11f79..0000000000 --- a/a11y/e-table/gal-a11y-e-table-click-to-add-factory.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yuedong Du <yuedong.du@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_TABLE_CLICK_TO_ADD_FACTORY_H__ -#define __GAL_A11Y_E_TABLE_CLICK_TO_ADD_FACTORY_H__ - -#include <glib-object.h> -#include <atk/atkobjectfactory.h> - -#define GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD_FACTORY (gal_a11y_e_table_item_factory_get_type ()) -#define GAL_A11Y_E_TABLE_CLICK_TO_ADD_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD_FACTORY, GalA11yETableClickToAddFactory)) -#define GAL_A11Y_E_TABLE_CLICK_TO_ADD_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD_FACTORY, GalA11yETableClickToAddFactoryClass)) -#define GAL_A11Y_IS_E_TABLE_CLICK_TO_ADD_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD_FACTORY)) -#define GAL_A11Y_IS_E_TABLE_CLICK_TO_ADD_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD_FACTORY)) - -typedef struct _GalA11yETableClickToAddFactory GalA11yETableClickToAddFactory; -typedef struct _GalA11yETableClickToAddFactoryClass GalA11yETableClickToAddFactoryClass; - -struct _GalA11yETableClickToAddFactory { - AtkObject object; -}; - -struct _GalA11yETableClickToAddFactoryClass { - AtkObjectClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_table_click_to_add_factory_get_type (void); - -#endif diff --git a/a11y/e-table/gal-a11y-e-table-click-to-add.c b/a11y/e-table/gal-a11y-e-table-click-to-add.c deleted file mode 100644 index 85c896ccf3..0000000000 --- a/a11y/e-table/gal-a11y-e-table-click-to-add.c +++ /dev/null @@ -1,344 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yuedong Du <yuedong.du@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <atk/atk.h> - -#include "a11y/gal-a11y-util.h" -#include "table/e-table-click-to-add.h" -#include "table/e-table-group.h" -#include "table/e-table-group-leaf.h" -#include <glib/gi18n.h> - -#include "gal-a11y-e-table-click-to-add.h" -#include "gal-a11y-e-table-click-to-add-factory.h" - -static AtkObjectClass *parent_class; -static GType parent_type; -static gint priv_offset; -#define GET_PRIVATE(object) ((GalA11yETableClickToAddPrivate *) (((char *) object) + priv_offset)) -#define PARENT_TYPE (parent_type) - -struct _GalA11yETableClickToAddPrivate { - gpointer rect; - gpointer row; -}; - - -static gint -etcta_get_n_actions (AtkAction *action) -{ - return 1; -} - -static G_CONST_RETURN gchar* -etcta_get_description (AtkAction *action, - gint i) -{ - if (i == 0) - return _("click to add"); - - return NULL; -} - -static G_CONST_RETURN gchar* -etcta_action_get_name (AtkAction *action, gint i) -{ - if (i == 0) - return _("click"); - - return NULL; -} - - -static gboolean -idle_do_action (gpointer data) -{ - GdkEventButton event; - ETableClickToAdd * etcta; - gint finished; - - g_return_val_if_fail ( data!= NULL, FALSE); - - etcta = E_TABLE_CLICK_TO_ADD (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (data))); - g_return_val_if_fail (etcta, FALSE); - - event.x = 0; - event.y = 0; - - event.type = GDK_BUTTON_PRESS; - event.window = GTK_LAYOUT(GNOME_CANVAS_ITEM(etcta)->canvas)->bin_window; - event.button = 1; - event.send_event = TRUE; - event.time = GDK_CURRENT_TIME; - event.axes = NULL; - - g_signal_emit_by_name (etcta, "event", &event, &finished); - - return FALSE; -} - -static gboolean -etcta_do_action (AtkAction * action, gint i) -{ - g_return_val_if_fail (i == 0, FALSE); - - g_idle_add (idle_do_action, action); - - return TRUE; -} - -static void -atk_action_interface_init (AtkActionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->do_action = etcta_do_action; - iface->get_n_actions = etcta_get_n_actions; - iface->get_description = etcta_get_description; - iface->get_name = etcta_action_get_name; -} - - -static G_CONST_RETURN gchar * -etcta_get_name (AtkObject *obj) -{ - ETableClickToAdd * etcta; - - g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_CLICK_TO_ADD (obj), NULL); - - etcta = E_TABLE_CLICK_TO_ADD (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(obj))); - if (etcta && etcta->message != NULL) - return etcta->message; - - return _("click to add"); -} - -static gint -etcta_get_n_children (AtkObject *accessible) -{ - return 1; -} - -static AtkObject* -etcta_ref_child (AtkObject *accessible, - gint i) -{ - AtkObject * atk_obj = NULL; - ETableClickToAdd * etcta; - - if ( i != 0 ) - return NULL; - - etcta = E_TABLE_CLICK_TO_ADD(atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); - - g_return_val_if_fail (etcta, NULL); - - if (etcta->rect) { - atk_obj = atk_gobject_accessible_for_object (G_OBJECT(etcta->rect)); - } else if (etcta->row) { - atk_obj = atk_gobject_accessible_for_object (G_OBJECT(etcta->row)); - } - - g_object_ref (atk_obj); - - return atk_obj; -} - -static AtkStateSet * -etcta_ref_state_set (AtkObject *accessible) -{ - AtkStateSet * state_set = NULL; - - state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible); - if (state_set != NULL) { - atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE); - atk_state_set_add_state (state_set, ATK_STATE_SHOWING); - } - - return state_set; -} - -static void -etcta_class_init (GalA11yETableClickToAddClass *klass) -{ - AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - atk_object_class->get_name = etcta_get_name; - atk_object_class->get_n_children = etcta_get_n_children; - atk_object_class->ref_child = etcta_ref_child; - atk_object_class->ref_state_set = etcta_ref_state_set; -} - -static void -etcta_init (GalA11yETableClickToAdd *a11y) -{ -} - -/** - * gal_a11y_e_table_click_to_add_get_type: - * @void: - * - * Registers the &GalA11yETableClickToAdd class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yETableClickToAdd class. - **/ -GType -gal_a11y_e_table_click_to_add_get_type (void) -{ - static GType type = 0; - - if (!type) { - AtkObjectFactory *factory; - - GTypeInfo info = { - sizeof (GalA11yETableClickToAddClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) etcta_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yETableClickToAdd), - 0, - (GInstanceInitFunc) etcta_init, - NULL /* value_table */ - }; - - static const GInterfaceInfo atk_action_info = { - (GInterfaceInitFunc) atk_action_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - factory = atk_registry_get_factory (atk_get_default_registry (), GNOME_TYPE_CANVAS_ITEM); - - parent_type = atk_object_factory_get_accessible_type (factory); - type = gal_a11y_type_register_static_with_private (PARENT_TYPE, - "GalA11yETableClickToAdd", &info, 0, - sizeof(GalA11yETableClickToAddPrivate), &priv_offset); - - g_type_add_interface_static (type, ATK_TYPE_ACTION, &atk_action_info); - - } - - return type; -} - -static gboolean -etcta_event (GnomeCanvasItem *item, GdkEvent *e, gpointer data) -{ - ETableClickToAdd *etcta = E_TABLE_CLICK_TO_ADD (item); - GalA11yETableClickToAdd *a11y; - GalA11yETableClickToAddPrivate *priv; - - g_return_val_if_fail (item, TRUE); - - g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_CLICK_TO_ADD(data), FALSE); - a11y = GAL_A11Y_E_TABLE_CLICK_TO_ADD (data); - - priv = GET_PRIVATE (a11y); - - /* rect replaced by row. */ - if (etcta->rect == NULL && priv->rect != NULL) { - g_signal_emit_by_name (a11y, "children_changed::remove", 0, NULL, NULL); - - } - /* row inserted, and/or replaced by a new row. */ - if (etcta->row != NULL && priv->row == NULL) { - g_signal_emit_by_name (a11y, "children_changed::add", 0, NULL, NULL); - } else if (etcta->row != NULL && priv->row != NULL && etcta->row != priv->row) { - g_signal_emit_by_name (a11y, "children_changed::remove", 0, NULL, NULL); - g_signal_emit_by_name (a11y, "children_changed::add", 0, NULL, NULL); - } - - - priv->rect = etcta->rect; - priv->row = etcta->row; - - return FALSE; -} - -static void -etcta_selection_cursor_changed (ESelectionModel *esm, gint row, gint col, - GalA11yETableClickToAdd *a11y) -{ - ETableClickToAdd *etcta; - AtkObject *row_a11y; - - etcta = E_TABLE_CLICK_TO_ADD (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(a11y))); - - if (etcta == NULL || etcta->row == NULL) - return; - - row_a11y = atk_gobject_accessible_for_object (G_OBJECT(etcta->row)); - if (row_a11y) { - AtkObject *cell_a11y = g_object_get_data (G_OBJECT(row_a11y), "gail-focus-object"); - if (cell_a11y) { - atk_focus_tracker_notify (cell_a11y); - } - } -} - -AtkObject * -gal_a11y_e_table_click_to_add_new (GObject *widget) -{ - GalA11yETableClickToAdd *a11y; - ETableClickToAdd * etcta; - GalA11yETableClickToAddPrivate *priv; - - g_return_val_if_fail (widget != NULL, NULL); - - a11y = g_object_new (gal_a11y_e_table_click_to_add_get_type (), NULL); - priv = GET_PRIVATE (a11y); - - etcta = E_TABLE_CLICK_TO_ADD(widget); - - - atk_object_initialize (ATK_OBJECT (a11y), etcta); - - priv->rect = etcta->rect; - priv->row = etcta->row; - - - g_signal_connect_after (G_OBJECT(widget), "event", - G_CALLBACK (etcta_event), a11y); - - g_signal_connect (etcta->selection, "cursor_changed", - G_CALLBACK (etcta_selection_cursor_changed), a11y); - - return ATK_OBJECT (a11y); -} - -void -gal_a11y_e_table_click_to_add_init (void) -{ - if (atk_get_root ()) - atk_registry_set_factory_type (atk_get_default_registry (), - E_TABLE_CLICK_TO_ADD_TYPE, - gal_a11y_e_table_click_to_add_factory_get_type ()); - -} - diff --git a/a11y/e-table/gal-a11y-e-table-click-to-add.h b/a11y/e-table/gal-a11y-e-table-click-to-add.h deleted file mode 100644 index ccefc7a9b8..0000000000 --- a/a11y/e-table/gal-a11y-e-table-click-to-add.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_TABLE_CLICK_TO_ADD_H__ -#define __GAL_A11Y_E_TABLE_CLICK_TO_ADD_H__ - -#include <glib-object.h> -#include <table/e-table-item.h> -#include <atk/atkgobjectaccessible.h> - -#define GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD (gal_a11y_e_table_click_to_add_get_type ()) -#define GAL_A11Y_E_TABLE_CLICK_TO_ADD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD, GalA11yETableClickToAdd)) -#define GAL_A11Y_E_TABLE_CLICK_TO_ADD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD, GalA11yETableClickToAddClass)) -#define GAL_A11Y_IS_E_TABLE_CLICK_TO_ADD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD)) -#define GAL_A11Y_IS_E_TABLE_CLICK_TO_ADD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TABLE_CLICK_TO_ADD)) - -typedef struct _GalA11yETableClickToAdd GalA11yETableClickToAdd; -typedef struct _GalA11yETableClickToAddClass GalA11yETableClickToAddClass; -typedef struct _GalA11yETableClickToAddPrivate GalA11yETableClickToAddPrivate; - -/* This struct should actually be larger as this isn't what we derive from. - * The GalA11yETableClickToAddPrivate comes right after the parent class structure. - **/ -struct _GalA11yETableClickToAdd { - AtkGObjectAccessible parent; -}; - -struct _GalA11yETableClickToAddClass { - AtkGObjectAccessibleClass parent_class; -}; - -/* Standard Glib function */ -GType gal_a11y_e_table_click_to_add_get_type (void); -AtkObject *gal_a11y_e_table_click_to_add_new (GObject *widget); - -void gal_a11y_e_table_click_to_add_init (void); -#endif /* ! __GAL_A11Y_E_TABLE_CLICK_TO_ADD_H__ */ diff --git a/a11y/e-table/gal-a11y-e-table-column-header.c b/a11y/e-table/gal-a11y-e-table-column-header.c deleted file mode 100644 index a50a286940..0000000000 --- a/a11y/e-table/gal-a11y-e-table-column-header.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Li Yuan <li.yuan@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> -#include <glib/gi18n.h> -#include <atk/atkobject.h> -#include <atk/atkregistry.h> -#include "table/e-table-header-item.h" -#include "a11y/gal-a11y-util.h" -#include "gal-a11y-e-table-column-header.h" - -static GObjectClass *parent_class; -static gint priv_offset; - -#define GET_PRIVATE(object) ((GalA11yETableColumnHeaderPrivate *) (((char *) object) + priv_offset)) -#define PARENT_TYPE (atk_gobject_accessible_get_type ()) - -struct _GalA11yETableColumnHeaderPrivate { - ETableItem *item; - AtkObject *parent; - AtkStateSet *state_set; -}; - -static void -etch_init (GalA11yETableColumnHeader *a11y) -{ - GET_PRIVATE (a11y)->item = NULL; - GET_PRIVATE (a11y)->parent = NULL; - GET_PRIVATE (a11y)->state_set = NULL; -} - -static AtkStateSet * -gal_a11y_e_table_column_header_ref_state_set (AtkObject *accessible) -{ - GalA11yETableColumnHeaderPrivate *priv = GET_PRIVATE (accessible); - - g_return_val_if_fail (priv->state_set, NULL); - - g_object_ref(priv->state_set); - - return priv->state_set; -} - -static void -gal_a11y_e_table_column_header_real_initialize (AtkObject *obj, gpointer data) -{ - ATK_OBJECT_CLASS (parent_class)->initialize (obj, data); -} - -static void -gal_a11y_e_table_column_header_dispose (GObject *object) -{ - GalA11yETableColumnHeader *a11y = GAL_A11Y_E_TABLE_COLUMN_HEADER (object); - GalA11yETableColumnHeaderPrivate *priv = GET_PRIVATE (a11y); - - if (priv->state_set) { - g_object_unref (priv->state_set); - priv->state_set = NULL; - } - - if (parent_class->dispose) - parent_class->dispose (object); - -} - -static void -etch_class_init (GalA11yETableColumnHeaderClass *klass) -{ - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->dispose = gal_a11y_e_table_column_header_dispose; - - class->ref_state_set = gal_a11y_e_table_column_header_ref_state_set; - class->initialize = gal_a11y_e_table_column_header_real_initialize; -} - -inline static GObject * -etch_a11y_get_gobject (AtkGObjectAccessible *accessible) -{ - return atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible)); -} - -static gboolean -gal_a11y_e_table_column_header_do_action (AtkAction *action, - gint i) -{ - gboolean return_value = TRUE; - GtkWidget *widget; - GalA11yETableColumnHeader *a11y; - ETableHeaderItem *ethi; - ETableItem *item; - ETableCol *col; - - switch (i) { - case 0: - a11y = GAL_A11Y_E_TABLE_COLUMN_HEADER (action); - col = E_TABLE_COL (etch_a11y_get_gobject (ATK_GOBJECT_ACCESSIBLE (a11y))); - item = GET_PRIVATE (a11y)->item; - widget = gtk_widget_get_parent (GTK_WIDGET (item->parent.canvas)); - if (E_IS_TREE (widget)) { - ethi = E_TABLE_HEADER_ITEM (e_tree_get_header_item (E_TREE (widget))); - } - else if (E_IS_TABLE (widget)) - ethi = E_TABLE_HEADER_ITEM (E_TABLE (widget)->header_item); - else - break; - ethi_change_sort_state (ethi, col); - default: - return_value = FALSE; - break; - } - return return_value; -} - -static gint -gal_a11y_e_table_column_header_get_n_actions (AtkAction *action) -{ - return 1; -} - -static G_CONST_RETURN gchar* -gal_a11y_e_table_column_header_action_get_name (AtkAction *action, - gint i) -{ - G_CONST_RETURN gchar *return_value; - - switch (i) { - case 0: - return_value = _("sort"); - break; - default: - return_value = NULL; - break; - } - return return_value; -} - -static void -atk_action_interface_init (AtkActionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->do_action = gal_a11y_e_table_column_header_do_action; - iface->get_n_actions = gal_a11y_e_table_column_header_get_n_actions; - iface->get_name = gal_a11y_e_table_column_header_action_get_name; -} - -GType -gal_a11y_e_table_column_header_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yETableColumnHeaderClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) etch_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (GalA11yETableColumnHeader), - 0, - (GInstanceInitFunc) etch_init, - NULL - }; - static const GInterfaceInfo atk_action_info = { - (GInterfaceInitFunc) atk_action_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - type = gal_a11y_type_register_static_with_private (PARENT_TYPE, "GalA11yETableColumnHeader", &info, 0, - sizeof (GalA11yETableColumnHeaderPrivate), &priv_offset); - - g_type_add_interface_static (type, ATK_TYPE_ACTION, &atk_action_info); - } - - return type; -} - -AtkObject * -gal_a11y_e_table_column_header_new (ETableCol *ecol, ETableItem *item) -{ - GalA11yETableColumnHeader *a11y; - AtkObject *accessible; - - g_return_val_if_fail (E_IS_TABLE_COL (ecol), NULL); - - a11y = g_object_new (gal_a11y_e_table_column_header_get_type(), NULL); - accessible = ATK_OBJECT (a11y); - atk_object_initialize (accessible, ecol); - - GET_PRIVATE (a11y)->item = item; - GET_PRIVATE (a11y)->state_set = atk_state_set_new (); - - atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_VISIBLE); - atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_SHOWING); - atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_SENSITIVE); - atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_ENABLED); - - if (ecol->text) - atk_object_set_name (accessible, ecol->text); - atk_object_set_role (accessible, ATK_ROLE_TABLE_COLUMN_HEADER); - - return ATK_OBJECT (a11y); -} diff --git a/a11y/e-table/gal-a11y-e-table-column-header.h b/a11y/e-table/gal-a11y-e-table-column-header.h deleted file mode 100644 index 083f0af3de..0000000000 --- a/a11y/e-table/gal-a11y-e-table-column-header.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Li Yuan <li.yuan@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - - -#ifndef __GAL_A11Y_E_TABLE_COLUMN_HEADER_H__ -#define __GAL_A11Y_E_TABLE_COLUMN_HEADER_H__ - -#include <glib-object.h> -#include <atk/atkgobjectaccessible.h> - -#define GAL_A11Y_TYPE_E_TABLE_COLUMN_HEADER (gal_a11y_e_table_column_header_get_type ()) -#define GAL_A11Y_E_TABLE_COLUMN_HEADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TABLE_COLUMN_HEADER, GalA11yETableColumnHeader)) -#define GAL_A11Y_E_TABLE_COLUMN_HEADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TABLE_COLUMN_HEADER, GalA11yETableColumnHeaderClass)) -#define GAL_A11Y_IS_E_TABLE_COLUMN_HEADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TABLE_COLUMN_HEADER)) -#define GAL_A11Y_IS_E_TABLE_COLUMN_HEADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TABLE_COLUMN_HEADER)) - -typedef struct _GalA11yETableColumnHeader GalA11yETableColumnHeader; -typedef struct _GalA11yETableColumnHeaderClass GalA11yETableColumnHeaderClass; -typedef struct _GalA11yETableColumnHeaderPrivate GalA11yETableColumnHeaderPrivate; - -struct _GalA11yETableColumnHeader { - AtkGObjectAccessible parent; -}; - -struct _GalA11yETableColumnHeaderClass { - AtkGObjectAccessibleClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_table_column_header_get_type (void); -AtkObject *gal_a11y_e_table_column_header_new (ETableCol *etc, ETableItem *item); -void gal_a11y_e_table_column_header_init (void); - -#endif /* ! __GAL_A11Y_E_TABLE_COLUMN_HEADER_H__ */ diff --git a/a11y/e-table/gal-a11y-e-table-factory.c b/a11y/e-table/gal-a11y-e-table-factory.c deleted file mode 100644 index 37c396aba8..0000000000 --- a/a11y/e-table/gal-a11y-e-table-factory.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include "gal-a11y-e-table.h" -#include "gal-a11y-e-table-factory.h" - -#define CS_CLASS(factory) (G_TYPE_INSTANCE_GET_CLASS ((factory), C_TYPE_STREAM, GalA11yETableFactoryClass)) -static AtkObjectFactoryClass *parent_class; -#define PARENT_TYPE (ATK_TYPE_OBJECT_FACTORY) - -/* Static functions */ - -static GType -gal_a11y_e_table_factory_get_accessible_type (void) -{ - return GAL_A11Y_TYPE_E_TABLE; -} - -static AtkObject* -gal_a11y_e_table_factory_create_accessible (GObject *obj) -{ - AtkObject *accessible; - - accessible = gal_a11y_e_table_new (obj); - - return accessible; -} - -static void -gal_a11y_e_table_factory_class_init (GalA11yETableFactoryClass *klass) -{ - AtkObjectFactoryClass *factory_class = ATK_OBJECT_FACTORY_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - factory_class->create_accessible = gal_a11y_e_table_factory_create_accessible; - factory_class->get_accessible_type = gal_a11y_e_table_factory_get_accessible_type; -} - -static void -gal_a11y_e_table_factory_init (GalA11yETableFactory *factory) -{ -} - -/** - * gal_a11y_e_table_factory_get_type: - * @void: - * - * Registers the &GalA11yETableFactory class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yETableFactory class. - **/ -GType -gal_a11y_e_table_factory_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yETableFactoryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gal_a11y_e_table_factory_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yETableFactory), - 0, - (GInstanceInitFunc) gal_a11y_e_table_factory_init, - NULL /* value_table */ - }; - - type = g_type_register_static (PARENT_TYPE, "GalA11yETableFactory", &info, 0); - } - - return type; -} diff --git a/a11y/e-table/gal-a11y-e-table-factory.h b/a11y/e-table/gal-a11y-e-table-factory.h deleted file mode 100644 index e3ef52c872..0000000000 --- a/a11y/e-table/gal-a11y-e-table-factory.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_TABLE_FACTORY_H__ -#define __GAL_A11Y_E_TABLE_FACTORY_H__ - -#include <glib-object.h> -#include <atk/atkobjectfactory.h> - -#define GAL_A11Y_TYPE_E_TABLE_FACTORY (gal_a11y_e_table_factory_get_type ()) -#define GAL_A11Y_E_TABLE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TABLE_FACTORY, GalA11yETableFactory)) -#define GAL_A11Y_E_TABLE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TABLE_FACTORY, GalA11yETableFactoryClass)) -#define GAL_A11Y_IS_E_TABLE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TABLE_FACTORY)) -#define GAL_A11Y_IS_E_TABLE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TABLE_FACTORY)) - -typedef struct _GalA11yETableFactory GalA11yETableFactory; -typedef struct _GalA11yETableFactoryClass GalA11yETableFactoryClass; - -struct _GalA11yETableFactory { - AtkObject object; -}; - -struct _GalA11yETableFactoryClass { - AtkObjectClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_table_factory_get_type (void); - -#endif /* ! __GAL_A11Y_E_TABLE_FACTORY_H__ */ diff --git a/a11y/e-table/gal-a11y-e-table-item-factory.c b/a11y/e-table/gal-a11y-e-table-item-factory.c deleted file mode 100644 index 43508e4796..0000000000 --- a/a11y/e-table/gal-a11y-e-table-item-factory.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yuedong Du <yuedong.du@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <atk/atk.h> - -#include "table/e-table.h" -#include "table/e-tree.h" - -#include "gal-a11y-e-table.h" -#include "gal-a11y-e-table-item.h" -#include "gal-a11y-e-table-item-factory.h" - -#define CS_CLASS(factory) (G_TYPE_INSTANCE_GET_CLASS ((factory), C_TYPE_STREAM, GalA11yETableItemFactoryClass)) -static AtkObjectFactoryClass *parent_class; -#define PARENT_TYPE (ATK_TYPE_OBJECT_FACTORY) - -/* Static functions */ - -static GType -gal_a11y_e_table_item_factory_get_accessible_type (void) -{ - return GAL_A11Y_TYPE_E_TABLE_ITEM; -} - -static AtkObject* -gal_a11y_e_table_item_factory_create_accessible (GObject *obj) -{ - AtkObject *accessible; - - g_return_val_if_fail (E_IS_TABLE_ITEM(obj), NULL); - accessible = gal_a11y_e_table_item_new (E_TABLE_ITEM (obj)); - - return accessible; -} - -static void -gal_a11y_e_table_item_factory_class_init (GalA11yETableItemFactoryClass *klass) -{ - AtkObjectFactoryClass *factory_class = ATK_OBJECT_FACTORY_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - factory_class->create_accessible = gal_a11y_e_table_item_factory_create_accessible; - factory_class->get_accessible_type = gal_a11y_e_table_item_factory_get_accessible_type; -} - -static void -gal_a11y_e_table_item_factory_init (GalA11yETableItemFactory *factory) -{ -} - -/** - * gal_a11y_e_table_factory_get_type: - * @void: - * - * Registers the &GalA11yETableFactory class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yETableFactory class. - **/ -GType -gal_a11y_e_table_item_factory_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yETableItemFactoryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gal_a11y_e_table_item_factory_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yETableItemFactory), - 0, - (GInstanceInitFunc) gal_a11y_e_table_item_factory_init, - NULL /* value_table */ - }; - - type = g_type_register_static (PARENT_TYPE, "GalA11yETableItemFactory", &info, 0); - } - - return type; -} diff --git a/a11y/e-table/gal-a11y-e-table-item-factory.h b/a11y/e-table/gal-a11y-e-table-item-factory.h deleted file mode 100644 index a85c9e894f..0000000000 --- a/a11y/e-table/gal-a11y-e-table-item-factory.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yuedong Du <yuedong.du@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_TABLE_ITEM_FACTORY_H__ -#define __GAL_A11Y_E_TABLE_ITEM_FACTORY_H__ - -#include <glib-object.h> -#include <atk/atkobjectfactory.h> - -#define GAL_A11Y_TYPE_E_TABLE_ITEM_FACTORY (gal_a11y_e_table_item_factory_get_type ()) -#define GAL_A11Y_E_TABLE_ITEM_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TABLE_ITEM_FACTORY, GalA11yETableItemFactory)) -#define GAL_A11Y_E_TABLE_ITEM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TABLE_ITEM_FACTORY, GalA11yETableItemFactoryClass)) -#define GAL_A11Y_IS_E_TABLE_ITEM_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TABLE_ITEM_FACTORY)) -#define GAL_A11Y_IS_E_TABLE_ITEM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TABLE_ITEM_FACTORY)) - -typedef struct _GalA11yETableItemFactory GalA11yETableItemFactory; -typedef struct _GalA11yETableItemFactoryClass GalA11yETableItemFactoryClass; - -struct _GalA11yETableItemFactory { - AtkObject object; -}; - -struct _GalA11yETableItemFactoryClass { - AtkObjectClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_table_item_factory_get_type (void); - -#endif /* ! __GAL_A11Y_E_TABLE_FACTORY_H__ */ diff --git a/a11y/e-table/gal-a11y-e-table-item.c b/a11y/e-table/gal-a11y-e-table-item.c deleted file mode 100644 index 16d50df9b0..0000000000 --- a/a11y/e-table/gal-a11y-e-table-item.c +++ /dev/null @@ -1,1327 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <string.h> - -#include <atk/atk.h> - -#include "a11y/gal-a11y-util.h" -#include "table/e-table-click-to-add.h" -#include "table/e-table-subset.h" -#include "table/e-table.h" -#include "table/e-tree.h" -#include "misc/e-canvas.h" -#include "misc/e-selection-model.h" - -#include "gal-a11y-e-table-item.h" -#include "gal-a11y-e-table-item-factory.h" -#include "gal-a11y-e-table-click-to-add.h" -#include "gal-a11y-e-cell-registry.h" -#include "gal-a11y-e-cell.h" -#include "gal-a11y-e-table-column-header.h" - -#define CS_CLASS(a11y) (G_TYPE_INSTANCE_GET_CLASS ((a11y), C_TYPE_STREAM, GalA11yETableItemClass)) -static GObjectClass *parent_class; -static AtkComponentIface *component_parent_iface; -static GType parent_type; -static gint priv_offset; -static GQuark quark_accessible_object = 0; -#define GET_PRIVATE(object) ((GalA11yETableItemPrivate *) (((char *) object) + priv_offset)) -#define PARENT_TYPE (parent_type) - -struct _GalA11yETableItemPrivate { - gint cols; - gint rows; - int selection_change_id; - int cursor_change_id; - ETableCol ** columns; - ESelectionModel *selection; - AtkStateSet *state_set; - GtkWidget *widget; -}; - -static gboolean gal_a11y_e_table_item_ref_selection (GalA11yETableItem *a11y, - ESelectionModel *selection); -static gboolean gal_a11y_e_table_item_unref_selection (GalA11yETableItem *a11y); - -static AtkObject* eti_ref_at (AtkTable *table, gint row, gint column); - -static void -item_destroyed (GtkObject *item, gpointer user_data) -{ - GalA11yETableItem *a11y = GAL_A11Y_E_TABLE_ITEM (user_data); - GalA11yETableItemPrivate *priv = GET_PRIVATE (a11y); - - atk_state_set_add_state (priv->state_set, ATK_STATE_DEFUNCT); - atk_object_notify_state_change (ATK_OBJECT (a11y), ATK_STATE_DEFUNCT, TRUE); - - if (priv->selection) - gal_a11y_e_table_item_unref_selection (a11y); - -} - -static AtkStateSet * -eti_ref_state_set (AtkObject *accessible) -{ - GalA11yETableItemPrivate *priv = GET_PRIVATE (accessible); - - g_object_ref(priv->state_set); - - return priv->state_set; -} - -inline static gint -view_to_model_row(ETableItem *eti, int row) -{ - if (eti->uses_source_model) { - ETableSubset *etss = E_TABLE_SUBSET(eti->table_model); - if (row >= 0 && row < etss->n_map) { - eti->row_guess = row; - return etss->map_table[row]; - } else - return -1; - } else - return row; -} - -inline static gint -view_to_model_col(ETableItem *eti, int col) -{ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - return ecol ? ecol->col_idx : -1; -} - -inline static gint -model_to_view_row(ETableItem *eti, int row) -{ - int i; - if (row == -1) - return -1; - if (eti->uses_source_model) { - ETableSubset *etss = E_TABLE_SUBSET(eti->table_model); - if (eti->row_guess >= 0 && eti->row_guess < etss->n_map) { - if (etss->map_table[eti->row_guess] == row) { - return eti->row_guess; - } - } - for (i = 0; i < etss->n_map; i++) { - if (etss->map_table[i] == row) - return i; - } - return -1; - } else - return row; -} - -inline static gint -model_to_view_col(ETableItem *eti, int col) -{ - int i; - if (col == -1) - return -1; - for (i = 0; i < eti->cols; i++) { - ETableCol *ecol = e_table_header_get_column (eti->header, i); - if (ecol->col_idx == col) - return i; - } - return -1; -} - -inline static GObject * -eti_a11y_get_gobject (AtkObject *accessible) -{ - return atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible)); -} - -static void -eti_a11y_reset_focus_object (GalA11yETableItem *a11y, ETableItem *item, gboolean notify) -{ - ESelectionModel * esm; - int cursor_row, cursor_col, view_row, view_col; - AtkObject *cell, *old_cell; - - esm = item->selection; - g_return_if_fail (esm); - - cursor_row = e_selection_model_cursor_row (esm); - cursor_col = e_selection_model_cursor_col (esm); - - view_row = model_to_view_row (item, cursor_row); - view_col = model_to_view_col (item, cursor_col); - - if (view_row == -1) - view_row = 0; - if (view_col == -1) - view_col = 0; - - old_cell = (AtkObject *)g_object_get_data (G_OBJECT (a11y), "gail-focus-object"); - if (old_cell && GAL_A11Y_IS_E_CELL (old_cell)) - gal_a11y_e_cell_remove_state (GAL_A11Y_E_CELL (old_cell), ATK_STATE_FOCUSED, FALSE); - if (old_cell) - g_object_unref (old_cell); - - cell = eti_ref_at (ATK_TABLE (a11y), view_row, view_col); - - if (cell != NULL) { - g_object_set_data (G_OBJECT (a11y), "gail-focus-object", cell); - gal_a11y_e_cell_add_state (GAL_A11Y_E_CELL (cell), ATK_STATE_FOCUSED, FALSE); - } else - g_object_set_data (G_OBJECT (a11y), "gail-focus-object", NULL); - - if (notify && cell) - atk_focus_tracker_notify (cell); -} - -static void -eti_dispose (GObject *object) -{ - GalA11yETableItem *a11y = GAL_A11Y_E_TABLE_ITEM (object); - GalA11yETableItemPrivate *priv = GET_PRIVATE (a11y); - - if (priv->columns) { - g_free(priv->columns); - priv->columns = NULL; - } - - if (parent_class->dispose) - parent_class->dispose (object); -} - -/* Static functions */ -static gint -eti_get_n_children (AtkObject *accessible) -{ - g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (accessible), 0); - if (!eti_a11y_get_gobject (accessible)) - return 0; - - return atk_table_get_n_columns (ATK_TABLE (accessible)) * - (atk_table_get_n_rows (ATK_TABLE (accessible)) + 1); -} - -static AtkObject* -eti_ref_child (AtkObject *accessible, gint index) -{ - ETableItem *item; - gint col, row; - - g_return_val_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (accessible), NULL); - item = E_TABLE_ITEM (eti_a11y_get_gobject (accessible)); - if (!item) - return NULL; - - if (index < item->cols) { - ETableCol *ecol; - AtkObject *child; - - ecol = e_table_header_get_column (item->header, index); - child = gal_a11y_e_table_column_header_new (ecol, item); - return child; - } - index -= item->cols; - - col = index % item->cols; - row = index / item->cols; - - return eti_ref_at (ATK_TABLE (accessible), row, col); -} - -static void -eti_get_extents (AtkComponent *component, - gint *x, - gint *y, - gint *width, - gint *height, - AtkCoordType coord_type) -{ - ETableItem *item; - AtkObject *parent; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (component))); - if (!item) - return; - - parent = ATK_OBJECT (component)->accessible_parent; - if (parent && ATK_IS_COMPONENT (parent)) - atk_component_get_extents (ATK_COMPONENT (parent), x, y, - width, height, - coord_type); - - if (parent && GAL_A11Y_IS_E_TABLE_CLICK_TO_ADD (parent)) { - ETableClickToAdd *etcta = E_TABLE_CLICK_TO_ADD (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (parent))); - if (etcta) { - *width = etcta->width; - *height = etcta->height; - } - } -} - -static AtkObject* -eti_ref_accessible_at_point (AtkComponent *component, - gint x, - gint y, - AtkCoordType coord_type) -{ - int row = -1; - int col = -1; - int x_origin, y_origin; - ETableItem *item; - GtkWidget *tableOrTree; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (component))); - if (!item) - return NULL; - - atk_component_get_position (component, - &x_origin, - &y_origin, - coord_type); - x -= x_origin; - y -= y_origin; - - tableOrTree = gtk_widget_get_parent (GTK_WIDGET (item->parent.canvas)); - - if (E_IS_TREE(tableOrTree)) - e_tree_get_cell_at (E_TREE (tableOrTree), x, y, &row, &col); - else - e_table_get_cell_at (E_TABLE (tableOrTree), x, y, &row, &col); - - if (row != -1 && col != -1) { - return eti_ref_at (ATK_TABLE (component), row, col); - } else { - return NULL; - } -} - - -static void -cell_destroyed (gpointer data) -{ - GalA11yECell * cell; - - g_return_if_fail (GAL_A11Y_IS_E_CELL (data)); - cell = GAL_A11Y_E_CELL (data); - - g_return_if_fail (cell->item && G_IS_OBJECT (cell->item)); - - if (cell->item) { - g_object_unref (cell->item); - cell->item = NULL; - } - -} - -/* atk table */ -static AtkObject* -eti_ref_at (AtkTable *table, gint row, gint column) -{ - ETableItem *item; - AtkObject* ret; - GalA11yETableItemPrivate *priv = GET_PRIVATE (table); - - if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT)) - return NULL; - - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return NULL; - - if (column >= 0 && - column < item->cols && - row >= 0 && - row < item->rows && - item->cell_views_realized) { - ECellView *cell_view = item->cell_views[column]; - ETableCol *ecol = e_table_header_get_column (item->header, column); - ret = gal_a11y_e_cell_registry_get_object (NULL, - item, - cell_view, - ATK_OBJECT (table), - ecol->col_idx, - column, - row); - if (ATK_IS_OBJECT (ret)) { - g_object_weak_ref (G_OBJECT (ret), - (GWeakNotify) cell_destroyed, - ret); - /* if current cell is focused, add FOCUSED state */ - if (e_selection_model_cursor_row (item->selection) == GAL_A11Y_E_CELL (ret)->row && - e_selection_model_cursor_col (item->selection) == GAL_A11Y_E_CELL (ret)->model_col) - gal_a11y_e_cell_add_state (GAL_A11Y_E_CELL (ret), ATK_STATE_FOCUSED, FALSE); - } else - ret = NULL; - - return ret; - } - - return NULL; -} - -static gint -eti_get_index_at (AtkTable *table, gint row, gint column) -{ - ETableItem *item; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return -1; - - return column + (row + 1) * item->cols; -} - -static gint -eti_get_column_at_index (AtkTable *table, gint index) -{ - ETableItem *item; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return -1; - - return index % item->cols; -} - -static gint -eti_get_row_at_index (AtkTable *table, gint index) -{ - ETableItem *item; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return -1; - - return index / item->cols - 1; -} - -static gint -eti_get_n_columns (AtkTable *table) -{ - ETableItem *item; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return -1; - - return item->cols; -} - -static gint -eti_get_n_rows (AtkTable *table) -{ - ETableItem *item; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return -1; - - return item->rows; -} - -static gint -eti_get_column_extent_at (AtkTable *table, - gint row, - gint column) -{ - ETableItem *item; - int width; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return -1; - - e_table_item_get_cell_geometry (item, - &row, - &column, - NULL, - NULL, - &width, - NULL); - - return width; -} - -static gint -eti_get_row_extent_at (AtkTable *table, - gint row, - gint column) -{ - ETableItem *item; - int height; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return -1; - - e_table_item_get_cell_geometry (item, - &row, - &column, - NULL, - NULL, - NULL, - &height); - - return height; -} - -static AtkObject * -eti_get_caption (AtkTable *table) -{ - /* Unimplemented */ - return NULL; -} - -static G_CONST_RETURN gchar * -eti_get_column_description (AtkTable *table, - gint column) -{ - ETableItem *item; - ETableCol *ecol; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return NULL; - - ecol = e_table_header_get_column (item->header, column); - - return ecol->text; -} - -static AtkObject * -eti_get_column_header (AtkTable *table, gint column) -{ - ETableItem *item; - ETableCol *ecol; - AtkObject *atk_obj = NULL; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return NULL; - - ecol = e_table_header_get_column (item->header, column); - if (ecol) { - atk_obj = gal_a11y_e_table_column_header_new (ecol, item); - } - - return atk_obj; -} - -static G_CONST_RETURN gchar * -eti_get_row_description (AtkTable *table, - gint row) -{ - /* Unimplemented */ - return NULL; -} - -static AtkObject * -eti_get_row_header (AtkTable *table, - gint row) -{ - /* Unimplemented */ - return NULL; -} - -static AtkObject * -eti_get_summary (AtkTable *table) -{ - /* Unimplemented */ - return NULL; -} - -static gboolean -table_is_row_selected (AtkTable *table, gint row) -{ - ETableItem *item; - GalA11yETableItemPrivate *priv = GET_PRIVATE (table); - - if (row < 0) - return FALSE; - - if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT)) - return FALSE; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return FALSE; - - return e_selection_model_is_row_selected(item->selection, view_to_model_row (item, row)); -} - -static gboolean -table_is_selected (AtkTable *table, gint row, gint column) -{ - return table_is_row_selected (table, row); -} - -static gint -table_get_selected_rows (AtkTable *table, gint **rows_selected) -{ - ETableItem *item; - gint n_selected, row, index_selected; - GalA11yETableItemPrivate *priv = GET_PRIVATE (table); - - if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT)) - return 0; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return 0; - - n_selected = e_selection_model_selected_count (item->selection); - if (rows_selected) { - *rows_selected = (gint *) g_malloc (n_selected * sizeof (gint)); - - index_selected = 0; - for (row = 0; row < item->rows && index_selected < n_selected; ++row) { - if (atk_table_is_row_selected (table, row)) { - (*rows_selected)[index_selected] = row; - ++index_selected; - } - } - } - return n_selected; -} - -static gboolean -table_add_row_selection (AtkTable *table, gint row) -{ - ETableItem *item; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return FALSE; - - if (table_is_row_selected (table, row)) - return TRUE; - e_selection_model_toggle_single_row (item->selection, - view_to_model_row (item, row)); - - return TRUE; -} - -static gboolean -table_remove_row_selection (AtkTable *table, gint row) -{ - ETableItem *item; - GalA11yETableItemPrivate *priv = GET_PRIVATE (table); - - if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT)) - return FALSE; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (table))); - if (!item) - return FALSE; - - if (!atk_table_is_row_selected (table, row)) - return TRUE; - e_selection_model_toggle_single_row (item->selection, view_to_model_row (item, row)); - return TRUE; -} - -static void -eti_atk_table_iface_init (AtkTableIface *iface) -{ - iface->ref_at = eti_ref_at; - iface->get_index_at = eti_get_index_at; - iface->get_column_at_index = eti_get_column_at_index; - iface->get_row_at_index = eti_get_row_at_index; - iface->get_n_columns = eti_get_n_columns; - iface->get_n_rows = eti_get_n_rows; - iface->get_column_extent_at = eti_get_column_extent_at; - iface->get_row_extent_at = eti_get_row_extent_at; - iface->get_caption = eti_get_caption; - iface->get_column_description = eti_get_column_description; - iface->get_column_header = eti_get_column_header; - iface->get_row_description = eti_get_row_description; - iface->get_row_header = eti_get_row_header; - iface->get_summary = eti_get_summary; - - iface->is_row_selected = table_is_row_selected; - iface->is_selected = table_is_selected; - iface->get_selected_rows = table_get_selected_rows; - iface->add_row_selection = table_add_row_selection; - iface->remove_row_selection = table_remove_row_selection; -} - -static void -eti_atk_component_iface_init (AtkComponentIface *iface) -{ - component_parent_iface = g_type_interface_peek_parent (iface); - - iface->ref_accessible_at_point = eti_ref_accessible_at_point; - iface->get_extents = eti_get_extents; -} - -static void -eti_rows_inserted (ETableModel * model, int row, int count, - AtkObject * table_item) -{ - gint n_cols,n_rows,i,j; - GalA11yETableItem * item_a11y; - gint old_nrows; - - g_return_if_fail (table_item); - item_a11y = GAL_A11Y_E_TABLE_ITEM (table_item); - - n_cols = atk_table_get_n_columns (ATK_TABLE(table_item)); - n_rows = atk_table_get_n_rows (ATK_TABLE(table_item)); - - old_nrows = GET_PRIVATE(item_a11y)->rows; - - g_return_if_fail (n_cols > 0 && n_rows > 0); - g_return_if_fail (old_nrows == n_rows - count); - - GET_PRIVATE(table_item)->rows = n_rows; - - g_signal_emit_by_name (table_item, "row-inserted", row, - count, NULL); - - for (i = row; i < (row + count); i ++) { - for (j = 0; j < n_cols; j ++) { - g_signal_emit_by_name (table_item, - "children_changed::add", - ( ((i + 1)*n_cols) + j), NULL, NULL); - } - } - - g_signal_emit_by_name (table_item, "visible-data-changed"); -} - -static void -eti_rows_deleted (ETableModel * model, int row, int count, - AtkObject * table_item) -{ - gint i,j, n_rows, n_cols, old_nrows; - ETableItem *item = E_TABLE_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (table_item))); - - n_rows = atk_table_get_n_rows (ATK_TABLE(table_item)); - n_cols = atk_table_get_n_columns (ATK_TABLE(table_item)); - - old_nrows = GET_PRIVATE(table_item)->rows; - - g_return_if_fail ( row+count <= old_nrows); - g_return_if_fail (old_nrows == n_rows + count); - GET_PRIVATE(table_item)->rows = n_rows; - - g_signal_emit_by_name (table_item, "row-deleted", row, - count, NULL); - - for (i = row; i < (row + count); i ++) { - for (j = 0; j < n_cols; j ++) { - g_signal_emit_by_name (table_item, - "children_changed::remove", - ( ((i + 1)*n_cols) + j), NULL, NULL); - } - } - g_signal_emit_by_name (table_item, "visible-data-changed"); - eti_a11y_reset_focus_object ((GalA11yETableItem *)table_item, item, TRUE); -} - -static void -eti_tree_model_node_changed_cb (ETreeModel *model, ETreePath node, ETableItem *eti) -{ - AtkObject *atk_obj; - GalA11yETableItem *a11y; - - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - atk_obj = atk_gobject_accessible_for_object (G_OBJECT (eti)); - a11y = GAL_A11Y_E_TABLE_ITEM (atk_obj); - - /* we can't figure out which rows are changed, so just send out a signal ... */ - if (GET_PRIVATE (a11y)->rows > 0) - g_signal_emit_by_name (a11y, "visible-data-changed"); -} - -enum { - ETI_HEADER_UNCHANGED = 0, - ETI_HEADER_REORDERED, - ETI_HEADER_NEW_ADDED, - ETI_HEADER_REMOVED, -}; - -/* - * 1. Check what actually happened: column reorder, remove or add - * 2. Update cache - * 3. Emit signals - */ -static void -eti_header_structure_changed (ETableHeader *eth, AtkObject *a11y) -{ - - gboolean reorder_found=FALSE, added_found=FALSE, removed_found=FALSE; - GalA11yETableItem * a11y_item; - ETableCol ** cols, **prev_cols; - GalA11yETableItemPrivate *priv; - gint *state = NULL, *prev_state = NULL, *reorder = NULL; - gint i,j,n_rows,n_cols, prev_n_cols; - - a11y_item = GAL_A11Y_E_TABLE_ITEM (a11y); - priv = GET_PRIVATE (a11y_item); - - /* Assume rows do not changed. */ - n_rows = priv->rows; - - prev_n_cols = priv->cols; - prev_cols = priv->columns; - - cols = e_table_header_get_columns (eth); - n_cols = eth->col_count; - - g_return_if_fail (cols && prev_cols && n_cols > 0); - - /* Init to ETI_HEADER_UNCHANGED. */ - state = g_malloc0 (sizeof (gint) * n_cols); - prev_state = g_malloc0 (sizeof (gint) * prev_n_cols); - reorder = g_malloc0 (sizeof (gint) * n_cols); - - /* Compare with previously saved column headers. */ - for ( i = 0 ; i < n_cols && cols[i]; i ++ ) { - for ( j = 0 ; j < prev_n_cols && prev_cols[j]; j ++ ) { - if ( prev_cols [j] == cols[i] && i != j ) { - - reorder_found = TRUE; - state [i] = ETI_HEADER_REORDERED; - reorder [i] = j; - - break; - } else if (prev_cols[j] == cols[i]) { - /* OK, this column is not changed. */ - break; - } - } - - /* cols[i] is new added column. */ - if ( j == prev_n_cols ) { - added_found = TRUE; - state[i] = ETI_HEADER_NEW_ADDED; - } - } - - /* Now try to find if there are removed columns. */ - for (i = 0 ; i < prev_n_cols && prev_cols[i]; i ++) { - for (j = 0 ; j < n_cols && cols[j]; j ++) - if ( prev_cols [j] == cols[i] ) - break; - - /* Removed columns found. */ - if ( j == n_cols ) { - removed_found = TRUE; - prev_state[j] = ETI_HEADER_REMOVED; - } - } - - /* If nothing interesting just return. */ - if (!reorder_found && !added_found && !removed_found) - return; - - /* Emit signals */ - if (reorder_found) - g_signal_emit_by_name (G_OBJECT(a11y_item), "column_reordered"); - - - if (removed_found) { - for (i = 0; i < prev_n_cols; i ++ ) { - if (prev_state[i] == ETI_HEADER_REMOVED) { - g_signal_emit_by_name (G_OBJECT(a11y_item), "column-deleted", i, 1); - for (j = 0 ; j < n_rows; j ++) - g_signal_emit_by_name (G_OBJECT(a11y_item), "children_changed::remove", ((j+1)*prev_n_cols+i), NULL, NULL); - } - } - } - - if (added_found) { - for ( i = 0; i < n_cols; i ++ ) { - if (state[i] == ETI_HEADER_NEW_ADDED) { - g_signal_emit_by_name (G_OBJECT(a11y_item), "column-inserted", i, 1); - for (j = 0 ; j < n_rows; j ++) - g_signal_emit_by_name (G_OBJECT(a11y_item), "children_changed::add", ((j+1)*n_cols+i), NULL, NULL); - } - } - } - - priv->cols = n_cols; - - g_free (state); - g_free (reorder); - g_free (prev_state); - - g_free (priv->columns); - priv->columns = cols; -} - - -static void -eti_real_initialize (AtkObject *obj, - gpointer data) -{ - ETableItem * eti; - ETableModel * model; - - ATK_OBJECT_CLASS (parent_class)->initialize (obj, data); - eti = E_TABLE_ITEM (data); - - model = eti->table_model; - - g_signal_connect (model, "model-rows-inserted", - G_CALLBACK (eti_rows_inserted), - obj); - g_signal_connect (model, "model-rows-deleted", - G_CALLBACK (eti_rows_deleted), - obj); - g_signal_connect (G_OBJECT (eti->header), "structure_change", - G_CALLBACK (eti_header_structure_changed), obj); - -} - -static void -eti_class_init (GalA11yETableItemClass *klass) -{ - AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - quark_accessible_object = g_quark_from_static_string ("gtk-accessible-object"); - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->dispose = eti_dispose; - - atk_object_class->get_n_children = eti_get_n_children; - atk_object_class->ref_child = eti_ref_child; - atk_object_class->initialize = eti_real_initialize; - atk_object_class->ref_state_set = eti_ref_state_set; -} - -static void -eti_init (GalA11yETableItem *a11y) -{ - GalA11yETableItemPrivate *priv; - - priv = GET_PRIVATE (a11y); - - priv->selection_change_id = 0; - priv->cursor_change_id = 0; - priv->selection = NULL; -} - -/* atk selection */ - -static void atk_selection_interface_init (AtkSelectionIface *iface); -static gboolean selection_add_selection (AtkSelection *selection, - gint i); -static gboolean selection_clear_selection (AtkSelection *selection); -static AtkObject* selection_ref_selection (AtkSelection *selection, - gint i); -static gint selection_get_selection_count (AtkSelection *selection); -static gboolean selection_is_child_selected (AtkSelection *selection, - gint i); - -/* callbacks */ -static void eti_a11y_selection_model_removed_cb (ETableItem *eti, - ESelectionModel *selection, - gpointer data); -static void eti_a11y_selection_model_added_cb (ETableItem *eti, - ESelectionModel *selection, - gpointer data); -static void eti_a11y_selection_changed_cb (ESelectionModel *selection, - GalA11yETableItem *a11y); -static void eti_a11y_cursor_changed_cb (ESelectionModel *selection, - int row, int col, - GalA11yETableItem *a11y); - -/** - * gal_a11y_e_table_item_get_type: - * @void: - * - * Registers the &GalA11yETableItem class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yETableItem class. - **/ -GType -gal_a11y_e_table_item_get_type (void) -{ - static GType type = 0; - - if (!type) { - AtkObjectFactory *factory; - - GTypeInfo info = { - sizeof (GalA11yETableItemClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) eti_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yETableItem), - 0, - (GInstanceInitFunc) eti_init, - NULL /* value_table_item */ - }; - - static const GInterfaceInfo atk_component_info = { - (GInterfaceInitFunc) eti_atk_component_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - static const GInterfaceInfo atk_table_info = { - (GInterfaceInitFunc) eti_atk_table_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - static const GInterfaceInfo atk_selection_info = { - (GInterfaceInitFunc) atk_selection_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - - factory = atk_registry_get_factory (atk_get_default_registry (), GNOME_TYPE_CANVAS_ITEM); - parent_type = atk_object_factory_get_accessible_type (factory); - - type = gal_a11y_type_register_static_with_private (PARENT_TYPE, "GalA11yETableItem", &info, 0, - sizeof (GalA11yETableItemPrivate), &priv_offset); - - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, &atk_component_info); - g_type_add_interface_static (type, ATK_TYPE_TABLE, &atk_table_info); - g_type_add_interface_static (type, ATK_TYPE_SELECTION, &atk_selection_info); - } - - return type; -} - -AtkObject * -gal_a11y_e_table_item_new (ETableItem *item) -{ - GalA11yETableItem *a11y; - AtkObject *accessible; - ESelectionModel * esm; - AtkObject *parent; - const char *name; - - g_return_val_if_fail (item && item->cols >= 0 && item->rows >= 0, NULL); - a11y = g_object_new (gal_a11y_e_table_item_get_type (), NULL); - - atk_object_initialize (ATK_OBJECT (a11y), item); - - GET_PRIVATE (a11y)->state_set = atk_state_set_new (); - - atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_TRANSIENT); - atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_ENABLED); - atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_SENSITIVE); - atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_SHOWING); - atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_VISIBLE); - - - accessible = ATK_OBJECT(a11y); - - /* Initialize cell data. */ - GET_PRIVATE (a11y)->cols = item->cols; - GET_PRIVATE (a11y)->rows = item->rows; - - GET_PRIVATE (a11y)->columns = e_table_header_get_columns (item->header); - if ( GET_PRIVATE (a11y)->columns == NULL) - return NULL; - - if (item) { - g_signal_connect (G_OBJECT(item), "selection_model_removed", - G_CALLBACK (eti_a11y_selection_model_removed_cb), NULL); - g_signal_connect (G_OBJECT(item), "selection_model_added", - G_CALLBACK (eti_a11y_selection_model_added_cb), NULL); - if (item->selection) - gal_a11y_e_table_item_ref_selection (a11y, - item->selection); - - /* find the TableItem's parent: table or tree */ - GET_PRIVATE (a11y)->widget = gtk_widget_get_parent (GTK_WIDGET (item->parent.canvas)); - parent = gtk_widget_get_accessible (GET_PRIVATE (a11y)->widget); - name = atk_object_get_name (parent); - if (name) - atk_object_set_name (accessible, name); - atk_object_set_parent (accessible, parent); - - if (E_IS_TREE (GET_PRIVATE (a11y)->widget)) { - ETreeModel *model; - model = e_tree_get_model (E_TREE (GET_PRIVATE (a11y)->widget)); - g_signal_connect (G_OBJECT(model), "node_changed", - G_CALLBACK (eti_tree_model_node_changed_cb), item); - accessible->role = ATK_ROLE_TREE_TABLE; - } else if (E_IS_TABLE (GET_PRIVATE (a11y)->widget)) { - accessible->role = ATK_ROLE_TABLE; - } - } - - if (item) - g_signal_connect (G_OBJECT (item), "destroy", - G_CALLBACK (item_destroyed), - a11y); - esm = item->selection; - - if (esm != NULL) { - eti_a11y_reset_focus_object (a11y, item, FALSE); - } - - return ATK_OBJECT (a11y); -} - -static gboolean -gal_a11y_e_table_item_ref_selection (GalA11yETableItem *a11y, - ESelectionModel *selection) -{ - GalA11yETableItemPrivate *priv; - - g_return_val_if_fail (a11y && selection, FALSE); - - priv = GET_PRIVATE (a11y); - priv->selection_change_id = g_signal_connect ( - G_OBJECT(selection), "selection_changed", - G_CALLBACK (eti_a11y_selection_changed_cb), a11y); - priv->cursor_change_id = g_signal_connect ( - G_OBJECT(selection), "cursor_changed", - G_CALLBACK (eti_a11y_cursor_changed_cb), a11y); - - priv->selection = selection; - g_object_ref (selection); - - return TRUE; -} - -static gboolean -gal_a11y_e_table_item_unref_selection (GalA11yETableItem *a11y) -{ - GalA11yETableItemPrivate *priv; - - g_return_val_if_fail (a11y, FALSE); - - priv = GET_PRIVATE (a11y); - - g_return_val_if_fail (priv->selection_change_id != 0, FALSE); - g_return_val_if_fail (priv->cursor_change_id != 0, FALSE); - - - g_signal_handler_disconnect (priv->selection, - priv->selection_change_id); - g_signal_handler_disconnect (priv->selection, - priv->cursor_change_id); - priv->cursor_change_id = 0; - priv->selection_change_id = 0; - - g_object_unref (priv->selection); - priv->selection = NULL; - - return TRUE; -} - -/* callbacks */ - -static void -eti_a11y_selection_model_removed_cb (ETableItem *eti, ESelectionModel *selection, - gpointer data) -{ - AtkObject *atk_obj; - GalA11yETableItem *a11y; - - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - g_return_if_fail (E_IS_SELECTION_MODEL (selection)); - - atk_obj = atk_gobject_accessible_for_object (G_OBJECT (eti)); - a11y = GAL_A11Y_E_TABLE_ITEM (atk_obj); - - if (selection == GET_PRIVATE (a11y)->selection) - gal_a11y_e_table_item_unref_selection (a11y); -} - -static void -eti_a11y_selection_model_added_cb (ETableItem *eti, ESelectionModel *selection, - gpointer data) -{ - AtkObject *atk_obj; - GalA11yETableItem *a11y; - - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - g_return_if_fail (E_IS_SELECTION_MODEL (selection)); - - atk_obj = atk_gobject_accessible_for_object (G_OBJECT (eti)); - a11y = GAL_A11Y_E_TABLE_ITEM (atk_obj); - - if (GET_PRIVATE (a11y)->selection) - gal_a11y_e_table_item_unref_selection (a11y); - gal_a11y_e_table_item_ref_selection (a11y, selection); -} - -static void -eti_a11y_selection_changed_cb (ESelectionModel *selection, GalA11yETableItem *a11y) -{ - GalA11yETableItemPrivate *priv = GET_PRIVATE (a11y); - - if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT)) - return; - - g_return_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (a11y)); - - g_signal_emit_by_name (a11y, "selection_changed"); -} - -static void -eti_a11y_cursor_changed_cb (ESelectionModel *selection, - int row, int col, GalA11yETableItem *a11y) -{ - ETableItem *item; - GalA11yETableItemPrivate *priv = GET_PRIVATE (a11y); - - g_return_if_fail (GAL_A11Y_IS_E_TABLE_ITEM (a11y)); - - if (atk_state_set_contains_state (priv->state_set, ATK_STATE_DEFUNCT)) - return; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (a11y))); - - g_return_if_fail (item); - - if (row == -1 && col == -1) - return; - eti_a11y_reset_focus_object (a11y, item, TRUE); -} - -/* atk selection */ - -static void atk_selection_interface_init (AtkSelectionIface *iface) -{ - g_return_if_fail (iface != NULL); - iface->add_selection = selection_add_selection; - iface->clear_selection = selection_clear_selection; - iface->ref_selection = selection_ref_selection; - iface->get_selection_count = selection_get_selection_count; - iface->is_child_selected = selection_is_child_selected; -} - -static gboolean -selection_add_selection (AtkSelection *selection, gint index) -{ - AtkTable *table; - gint row, col, cursor_row, cursor_col, model_row, model_col; - ETableItem *item; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (selection))); - if (!item) - return FALSE; - - table = ATK_TABLE (selection); - - row = atk_table_get_row_at_index (table, index); - col = atk_table_get_column_at_index (table, index); - - model_row = view_to_model_row (item, row); - model_col = view_to_model_col (item, col); - - cursor_row = e_selection_model_cursor_row (item->selection); - cursor_col = e_selection_model_cursor_col (item->selection); - - /* check whether is selected already */ - if (model_row == cursor_row && model_col == cursor_col) - return TRUE; - - if (model_row != cursor_row) { - /* we need to make the item get focus */ - e_canvas_item_grab_focus (GNOME_CANVAS_ITEM (item), TRUE); - - /* FIXME, currently we only support single row selection */ - atk_selection_clear_selection (selection); - atk_table_add_row_selection (table, row); - } - - e_selection_model_change_cursor (item->selection, - model_row, - model_col); - e_selection_model_cursor_changed (item->selection, - model_row, - model_col); - e_selection_model_cursor_activated (item->selection, - model_row, - model_col); - return TRUE; -} - -static gboolean -selection_clear_selection (AtkSelection *selection) -{ - ETableItem *item; - - item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (selection))); - if (!item) - return FALSE; - - e_selection_model_clear (item->selection); - return TRUE; -} - -static AtkObject * -selection_ref_selection (AtkSelection *selection, gint index) -{ - AtkTable *table; - gint row, col; - - table = ATK_TABLE (selection); - row = atk_table_get_row_at_index (table, index); - col = atk_table_get_column_at_index (table, index); - if (!atk_table_is_row_selected (table, row)) - return NULL; - - return eti_ref_at (table, row, col); -} - -static gint -selection_get_selection_count (AtkSelection *selection) -{ - AtkTable *table; - gint n_selected; - - table = ATK_TABLE (selection); - n_selected = atk_table_get_selected_rows (table, NULL); - if (n_selected > 0) - n_selected *= atk_table_get_n_columns (table); - return n_selected; -} - -static gboolean -selection_is_child_selected (AtkSelection *selection, gint i) -{ - gint row; - - row = atk_table_get_row_at_index (ATK_TABLE (selection), i); - return atk_table_is_row_selected (ATK_TABLE (selection), row); -} - -void -gal_a11y_e_table_item_init (void) -{ - if (atk_get_root ()) - atk_registry_set_factory_type (atk_get_default_registry (), - E_TABLE_ITEM_TYPE, - gal_a11y_e_table_item_factory_get_type ()); -} - diff --git a/a11y/e-table/gal-a11y-e-table-item.h b/a11y/e-table/gal-a11y-e-table-item.h deleted file mode 100644 index e89f0824b3..0000000000 --- a/a11y/e-table/gal-a11y-e-table-item.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_TABLE_ITEM_H__ -#define __GAL_A11Y_E_TABLE_ITEM_H__ - -#include <glib-object.h> -#include <table/e-table-item.h> -#include <atk/atkgobjectaccessible.h> - -#define GAL_A11Y_TYPE_E_TABLE_ITEM (gal_a11y_e_table_item_get_type ()) -#define GAL_A11Y_E_TABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TABLE_ITEM, GalA11yETableItem)) -#define GAL_A11Y_E_TABLE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TABLE_ITEM, GalA11yETableItemClass)) -#define GAL_A11Y_IS_E_TABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TABLE_ITEM)) -#define GAL_A11Y_IS_E_TABLE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TABLE_ITEM)) - -typedef struct _GalA11yETableItem GalA11yETableItem; -typedef struct _GalA11yETableItemClass GalA11yETableItemClass; -typedef struct _GalA11yETableItemPrivate GalA11yETableItemPrivate; - -/* This struct should actually be larger as this isn't what we derive from. - * The GalA11yETableItemPrivate comes right after the parent class structure. - **/ -struct _GalA11yETableItem { - AtkGObjectAccessible parent; -}; - -struct _GalA11yETableItemClass { - AtkGObjectAccessibleClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_table_item_get_type (void); -AtkObject *gal_a11y_e_table_item_new (ETableItem *item); - -void gal_a11y_e_table_item_init (void); - -#endif /* ! __GAL_A11Y_E_TABLE_ITEM_H__ */ diff --git a/a11y/e-table/gal-a11y-e-table.c b/a11y/e-table/gal-a11y-e-table.c deleted file mode 100644 index 20261d4eab..0000000000 --- a/a11y/e-table/gal-a11y-e-table.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include "a11y/gal-a11y-util.h" -#include "table/e-table.h" -#include "table/e-table-click-to-add.h" -#include "table/e-table-group.h" -#include "table/e-table-group-container.h" -#include "table/e-table-group-leaf.h" - -#include "gal-a11y-e-table.h" -#include "gal-a11y-e-table-factory.h" -#include "gal-a11y-e-table-item.h" - -#define CS_CLASS(a11y) (G_TYPE_INSTANCE_GET_CLASS ((a11y), C_TYPE_STREAM, GalA11yETableClass)) -static AtkObjectClass *parent_class; -static GType parent_type; -static gint priv_offset; -#define GET_PRIVATE(object) ((GalA11yETablePrivate *) (((char *) object) + priv_offset)) -#define PARENT_TYPE (parent_type) - -struct _GalA11yETablePrivate { - AtkObject *child_item; -}; - -/* Static functions */ -static ETableItem * -find_first_table_item (ETableGroup *group) -{ - GnomeCanvasGroup *cgroup; - GList *l; - - cgroup = GNOME_CANVAS_GROUP (group); - - for (l = cgroup->item_list; l; l = l->next) { - GnomeCanvasItem *i; - - i = GNOME_CANVAS_ITEM (l->data); - - if (E_IS_TABLE_GROUP (i)) - return find_first_table_item (E_TABLE_GROUP (i)); - else if (E_IS_TABLE_ITEM (i)) { - return E_TABLE_ITEM (i); - } - } - - return NULL; -} - -static AtkObject* -eti_get_accessible (ETableItem *eti, AtkObject *parent) -{ - AtkObject *a11y = NULL; - - g_return_val_if_fail (eti, NULL); - - a11y = atk_gobject_accessible_for_object (G_OBJECT (eti)); - g_return_val_if_fail (a11y, NULL); - - return a11y; -} - -static gboolean -init_child_item (GalA11yETable *a11y) -{ - ETable *table; - - if (!a11y || !GTK_IS_ACCESSIBLE (a11y)) - return FALSE; - - table = E_TABLE (GTK_ACCESSIBLE (a11y)->widget); - if (table && GTK_WIDGET_MAPPED (GTK_WIDGET (table)) && table->group && E_IS_TABLE_GROUP_CONTAINER(table->group)) { - ETableGroupContainer *etgc = (ETableGroupContainer *)table->group; - GList *list; - - for (list = etgc->children; list; list = g_list_next (list)) { - ETableGroupContainerChildNode *child_node = list->data; - ETableGroup *child = child_node->child; - ETableItem *eti = find_first_table_item (child); - - eti_get_accessible (eti, ATK_OBJECT (a11y)); - } - } - g_object_unref (a11y); - g_object_unref (table); - - return FALSE; -} - -static AtkObject* -et_ref_accessible_at_point (AtkComponent *component, - gint x, - gint y, - AtkCoordType coord_type) -{ - GalA11yETable *a11y = GAL_A11Y_E_TABLE (component); - if (GET_PRIVATE (a11y)->child_item) - g_object_ref (GET_PRIVATE (a11y)->child_item); - return GET_PRIVATE (a11y)->child_item; -} - -static gint -et_get_n_children (AtkObject *accessible) -{ - GalA11yETable *a11y = GAL_A11Y_E_TABLE (accessible); - ETable * et; - int n = 0; - - et = E_TABLE(GTK_ACCESSIBLE (a11y)->widget); - - if (et->group) { - if (E_IS_TABLE_GROUP_LEAF (et->group)) - n = 1; - else if (E_IS_TABLE_GROUP_CONTAINER (et->group)) { - ETableGroupContainer *etgc = (ETableGroupContainer *)et->group; - n = g_list_length (etgc->children); - } - } - - if (et && et->use_click_to_add && et->click_to_add) { - n++; - } - return n; -} - -static AtkObject* -et_ref_child (AtkObject *accessible, - gint i) -{ - GalA11yETable *a11y = GAL_A11Y_E_TABLE (accessible); - ETable * et; - gint child_no; - - et = E_TABLE(GTK_ACCESSIBLE (a11y)->widget); - - child_no = et_get_n_children (accessible); - if (i == 0 || i < child_no - 1) { - if (E_IS_TABLE_GROUP_LEAF (et->group)) { - ETableItem *eti = find_first_table_item (et->group); - AtkObject *aeti = eti_get_accessible (eti, accessible); - if (aeti) - g_object_ref (aeti); - return aeti; - - } else if (E_IS_TABLE_GROUP_CONTAINER (et->group)) { - ETableGroupContainer *etgc = (ETableGroupContainer *) et->group; - ETableGroupContainerChildNode *child_node = g_list_nth_data (etgc->children, i); - if (child_node) { - ETableGroup *child = child_node->child; - ETableItem * eti = find_first_table_item (child); - AtkObject *aeti = eti_get_accessible (eti, accessible); - if (aeti) - g_object_ref (aeti); - return aeti; - } - } - } else if (i == child_no -1) { - ETableClickToAdd * etcta; - - if (et && et->use_click_to_add && et->click_to_add) { - etcta = E_TABLE_CLICK_TO_ADD(et->click_to_add); - accessible = atk_gobject_accessible_for_object (G_OBJECT(etcta)); - if (accessible) - g_object_ref (accessible); - return accessible; - } - } - - return NULL; -} - -static AtkLayer -et_get_layer (AtkComponent *component) -{ - return ATK_LAYER_WIDGET; -} - -static void -et_class_init (GalA11yETableClass *klass) -{ - AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - atk_object_class->get_n_children = et_get_n_children; - atk_object_class->ref_child = et_ref_child; -} - -static void -et_atk_component_iface_init (AtkComponentIface *iface) -{ - iface->ref_accessible_at_point = et_ref_accessible_at_point; - iface->get_layer = et_get_layer; -} - -static void -et_init (GalA11yETable *a11y) -{ - GalA11yETablePrivate *priv; - - priv = GET_PRIVATE (a11y); - - priv->child_item = NULL; -} - -/** - * gal_a11y_e_table_get_type: - * @void: - * - * Registers the &GalA11yETable class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yETable class. - **/ -GType -gal_a11y_e_table_get_type (void) -{ - static GType type = 0; - - if (!type) { - AtkObjectFactory *factory; - - GTypeInfo info = { - sizeof (GalA11yETableClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) et_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yETable), - 0, - (GInstanceInitFunc) et_init, - NULL /* value_table */ - }; - - static const GInterfaceInfo atk_component_info = { - (GInterfaceInitFunc) et_atk_component_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_WIDGET); - parent_type = atk_object_factory_get_accessible_type (factory); - - type = gal_a11y_type_register_static_with_private (PARENT_TYPE, "GalA11yETable", &info, 0, - sizeof (GalA11yETablePrivate), &priv_offset); - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, &atk_component_info); - } - - return type; -} - -AtkObject * -gal_a11y_e_table_new (GObject *widget) -{ - GalA11yETable *a11y; - ETable *table; - - table = E_TABLE (widget); - - a11y = g_object_new (gal_a11y_e_table_get_type (), NULL); - - GTK_ACCESSIBLE (a11y)->widget = GTK_WIDGET (widget); - - /* we need to init all the children for multiple table items */ - if (table && GTK_WIDGET_MAPPED (GTK_WIDGET (table)) && table->group && E_IS_TABLE_GROUP_CONTAINER (table->group)) { - /* Ref it here so that it is still valid in the idle function */ - /* It will be unrefed in the idle function */ - g_object_ref (a11y); - g_object_ref (widget); - - g_idle_add ((GSourceFunc)init_child_item, a11y); - } - - return ATK_OBJECT (a11y); -} - -void -gal_a11y_e_table_init (void) -{ - if (atk_get_root ()) - atk_registry_set_factory_type (atk_get_default_registry (), - E_TABLE_TYPE, - gal_a11y_e_table_factory_get_type ()); - -} - diff --git a/a11y/e-table/gal-a11y-e-table.h b/a11y/e-table/gal-a11y-e-table.h deleted file mode 100644 index ab133f5c71..0000000000 --- a/a11y/e-table/gal-a11y-e-table.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_TABLE_H__ -#define __GAL_A11Y_E_TABLE_H__ - -#include <gtk/gtk.h> -#include <atk/atkobject.h> -#include <atk/atkcomponent.h> - -#define GAL_A11Y_TYPE_E_TABLE (gal_a11y_e_table_get_type ()) -#define GAL_A11Y_E_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TABLE, GalA11yETable)) -#define GAL_A11Y_E_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TABLE, GalA11yETableClass)) -#define GAL_A11Y_IS_E_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TABLE)) -#define GAL_A11Y_IS_E_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TABLE)) - -typedef struct _GalA11yETable GalA11yETable; -typedef struct _GalA11yETableClass GalA11yETableClass; -typedef struct _GalA11yETablePrivate GalA11yETablePrivate; - -/* This struct should actually be larger as this isn't what we derive from. - * The GalA11yETablePrivate comes right after the parent class structure. - **/ -struct _GalA11yETable { - GtkAccessible object; -}; - -struct _GalA11yETableClass { - GtkAccessibleClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_table_get_type (void); -AtkObject *gal_a11y_e_table_new (GObject *table); - -void gal_a11y_e_table_init (void); - -#endif /* ! __GAL_A11Y_E_TABLE_H__ */ diff --git a/a11y/e-table/gal-a11y-e-tree-factory.c b/a11y/e-table/gal-a11y-e-tree-factory.c deleted file mode 100644 index cacb3fe082..0000000000 --- a/a11y/e-table/gal-a11y-e-tree-factory.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yuedong Du <yuedong.du@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include "gal-a11y-e-tree.h" -#include "gal-a11y-e-tree-factory.h" - -#define CS_CLASS(factory) (G_TYPE_INSTANCE_GET_CLASS ((factory), C_TYPE_STREAM, GalA11yETreeFactoryClass)) -static AtkObjectFactoryClass *parent_class; -#define PARENT_TYPE (ATK_TYPE_OBJECT_FACTORY) - -/* Static functions */ - -static GType -gal_a11y_e_tree_factory_get_accessible_type (void) -{ - return GAL_A11Y_TYPE_E_TREE; -} - -static AtkObject* -gal_a11y_e_tree_factory_create_accessible (GObject *obj) -{ - AtkObject *accessible; - - accessible = gal_a11y_e_tree_new (obj); - - return accessible; -} - -static void -gal_a11y_e_tree_factory_class_init (GalA11yETreeFactoryClass *klass) -{ - AtkObjectFactoryClass *factory_class = ATK_OBJECT_FACTORY_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - factory_class->create_accessible = gal_a11y_e_tree_factory_create_accessible; - factory_class->get_accessible_type = gal_a11y_e_tree_factory_get_accessible_type; -} - -static void -gal_a11y_e_tree_factory_init (GalA11yETreeFactory *factory) -{ -} - -/** - * gal_a11y_e_tree_factory_get_type: - * @void: - * - * Registers the &GalA11yETreeFactory class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yETreeFactory class. - **/ -GType -gal_a11y_e_tree_factory_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yETreeFactoryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gal_a11y_e_tree_factory_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yETreeFactory), - 0, - (GInstanceInitFunc) gal_a11y_e_tree_factory_init, - NULL /* value_tree */ - }; - - type = g_type_register_static (PARENT_TYPE, "GalA11yETreeFactory", &info, 0); - } - - return type; -} diff --git a/a11y/e-table/gal-a11y-e-tree-factory.h b/a11y/e-table/gal-a11y-e-tree-factory.h deleted file mode 100644 index 621d256c48..0000000000 --- a/a11y/e-table/gal-a11y-e-tree-factory.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yuedong Du <yuedong.du@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_TREE_FACTORY_H__ -#define __GAL_A11Y_E_TREE_FACTORY_H__ - -#include <glib-object.h> -#include <atk/atkobjectfactory.h> - -#define GAL_A11Y_TYPE_E_TREE_FACTORY (gal_a11y_e_table_factory_get_type ()) -#define GAL_A11Y_E_TREE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TREE_FACTORY, GalA11yETreeFactory)) -#define GAL_A11Y_E_TREE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TREE_FACTORY, GalA11yETreeFactoryClass)) -#define GAL_A11Y_IS_E_TREE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TREE_FACTORY)) -#define GAL_A11Y_IS_E_TREE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TREE_FACTORY)) - -typedef struct _GalA11yETreeFactory GalA11yETreeFactory; -typedef struct _GalA11yETreeFactoryClass GalA11yETreeFactoryClass; - -struct _GalA11yETreeFactory { - AtkObject object; -}; - -struct _GalA11yETreeFactoryClass { - AtkObjectClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_tree_factory_get_type (void); - -#endif /* ! __GAL_A11Y_E_TREE_FACTORY_H__ */ diff --git a/a11y/e-table/gal-a11y-e-tree.c b/a11y/e-table/gal-a11y-e-tree.c deleted file mode 100644 index 6fde32b8e7..0000000000 --- a/a11y/e-table/gal-a11y-e-tree.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yuedong Du <yuedong.du@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include "a11y/gal-a11y-util.h" -#include "table/e-table-item.h" -#include "table/e-tree.h" - -#include "gal-a11y-e-table-item.h" -#include "gal-a11y-e-tree.h" -#include "gal-a11y-e-tree-factory.h" - -#define CS_CLASS(a11y) (G_TYPE_INSTANCE_GET_CLASS ((a11y), C_TYPE_STREAM, GalA11yETreeClass)) -static AtkObjectClass *parent_class; -static GType parent_type; -static gint priv_offset; -#define GET_PRIVATE(object) ((GalA11yETreePrivate *) (((char *) object) + priv_offset)) -#define PARENT_TYPE (parent_type) - -struct _GalA11yETreePrivate { - AtkObject *child_item; -}; - -/* Static functions */ - -static void -init_child_item (GalA11yETree *a11y) -{ - GalA11yETreePrivate *priv = GET_PRIVATE (a11y); - ETree *tree = E_TREE (GTK_ACCESSIBLE (a11y)->widget); - ETableItem * eti; - - g_return_if_fail (tree); - eti = e_tree_get_item (tree); - if (priv->child_item == NULL) { - priv->child_item = atk_gobject_accessible_for_object (G_OBJECT (eti)); - } -} - -static AtkObject* -et_ref_accessible_at_point (AtkComponent *component, - gint x, - gint y, - AtkCoordType coord_type) -{ - GalA11yETree *a11y = GAL_A11Y_E_TREE (component); - init_child_item (a11y); - return GET_PRIVATE (a11y)->child_item; -} - -static gint -et_get_n_children (AtkObject *accessible) -{ - return 1; -} - -static AtkObject* -et_ref_child (AtkObject *accessible, - gint i) -{ - GalA11yETree *a11y = GAL_A11Y_E_TREE (accessible); - if (i != 0) - return NULL; - init_child_item (a11y); - g_object_ref (GET_PRIVATE (a11y)->child_item); - return GET_PRIVATE (a11y)->child_item; -} - -static AtkLayer -et_get_layer (AtkComponent *component) -{ - return ATK_LAYER_WIDGET; -} - -static void -et_class_init (GalA11yETreeClass *klass) -{ - AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - atk_object_class->get_n_children = et_get_n_children; - atk_object_class->ref_child = et_ref_child; -} - -static void -et_atk_component_iface_init (AtkComponentIface *iface) -{ - iface->ref_accessible_at_point = et_ref_accessible_at_point; - iface->get_layer = et_get_layer; -} - -static void -et_init (GalA11yETree *a11y) -{ - GalA11yETreePrivate *priv; - - priv = GET_PRIVATE (a11y); - - priv->child_item = NULL; -} - -/** - * gal_a11y_e_tree_get_type: - * @void: - * - * Registers the &GalA11yETree class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yETree class. - **/ -GType -gal_a11y_e_tree_get_type (void) -{ - static GType type = 0; - - if (!type) { - AtkObjectFactory *factory; - - GTypeInfo info = { - sizeof (GalA11yETreeClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) et_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yETree), - 0, - (GInstanceInitFunc) et_init, - NULL /* value_tree */ - }; - - static const GInterfaceInfo atk_component_info = { - (GInterfaceInitFunc) et_atk_component_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_WIDGET); - parent_type = atk_object_factory_get_accessible_type (factory); - - type = gal_a11y_type_register_static_with_private (PARENT_TYPE, "GalA11yETree", &info, 0, - sizeof (GalA11yETreePrivate), &priv_offset); - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, &atk_component_info); - } - - return type; -} - -AtkObject * -gal_a11y_e_tree_new (GObject *widget) -{ - GalA11yETree *a11y; - - a11y = g_object_new (gal_a11y_e_tree_get_type (), NULL); - - GTK_ACCESSIBLE (a11y)->widget = GTK_WIDGET (widget); - - return ATK_OBJECT (a11y); -} - -void -gal_a11y_e_tree_init (void) -{ - if (atk_get_root ()) - atk_registry_set_factory_type (atk_get_default_registry (), - E_TREE_TYPE, - gal_a11y_e_tree_factory_get_type ()); - -} - diff --git a/a11y/e-table/gal-a11y-e-tree.h b/a11y/e-table/gal-a11y-e-tree.h deleted file mode 100644 index 9fe482e1f8..0000000000 --- a/a11y/e-table/gal-a11y-e-tree.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Yuedong Du <yuedong.du@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_TREE_H__ -#define __GAL_A11Y_E_TREE_H__ - -#include <gtk/gtk.h> -#include <atk/atkobject.h> -#include <atk/atkcomponent.h> - -#define GAL_A11Y_TYPE_E_TREE (gal_a11y_e_tree_get_type ()) -#define GAL_A11Y_E_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TREE, GalA11yETree)) -#define GAL_A11Y_E_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TREE, GalA11yETreeClass)) -#define GAL_A11Y_IS_E_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TREE)) -#define GAL_A11Y_IS_E_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TREE)) - -typedef struct _GalA11yETree GalA11yETree; -typedef struct _GalA11yETreeClass GalA11yETreeClass; -typedef struct _GalA11yETreePrivate GalA11yETreePrivate; - -/* This struct should actually be larger as this isn't what we derive from. - * The GalA11yETablePrivate comes right after the parent class structure. - **/ -struct _GalA11yETree { - GtkAccessible object; -}; - -struct _GalA11yETreeClass { - GtkAccessibleClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_tree_get_type (void); -AtkObject *gal_a11y_e_tree_new (GObject *tree); - -void gal_a11y_e_tree_init (void); - -#endif /* ! __GAL_A11Y_E_TREE_H__ */ diff --git a/a11y/e-text/Makefile.am b/a11y/e-text/Makefile.am deleted file mode 100644 index 069284a617..0000000000 --- a/a11y/e-text/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets \ - $(GNOME_PLATFORM_CFLAGS) \ - -DG_LOG_DOMAIN=\"e-text\" - -noinst_LTLIBRARIES = libgal-a11y-etext.la - -libgal_a11y_etext_la_SOURCES = \ - gal-a11y-e-text-factory.c \ - gal-a11y-e-text.c \ - gal-a11y-e-text-factory.h \ - gal-a11y-e-text.h - --include $(top_srcdir)/git.mk diff --git a/a11y/e-text/gal-a11y-e-text-factory.c b/a11y/e-text/gal-a11y-e-text-factory.c deleted file mode 100644 index e1f835e912..0000000000 --- a/a11y/e-text/gal-a11y-e-text-factory.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> -#include "text/e-text.h" -#include "gal-a11y-e-text-factory.h" -#include "gal-a11y-e-text.h" - -#define CS_CLASS(factory) (G_TYPE_INSTANCE_GET_CLASS ((factory), C_TYPE_STREAM, GalA11yETextFactoryClass)) -static AtkObjectFactoryClass *parent_class; -#define PARENT_TYPE (ATK_TYPE_OBJECT_FACTORY) - -/* Static functions */ - -static GType -gal_a11y_e_text_factory_get_accessible_type (void) -{ - return GAL_A11Y_TYPE_E_TEXT; -} - -static AtkObject* -gal_a11y_e_text_factory_create_accessible (GObject *obj) -{ - AtkObject *atk_object; - - g_return_val_if_fail (E_IS_TEXT (obj), NULL); - - atk_object = g_object_new (GAL_A11Y_TYPE_E_TEXT, NULL); - atk_object_initialize (atk_object, obj); - - return atk_object; -} - -static void -gal_a11y_e_text_factory_class_init (GalA11yETextFactoryClass *klass) -{ - AtkObjectFactoryClass *factory_class = ATK_OBJECT_FACTORY_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - factory_class->create_accessible = gal_a11y_e_text_factory_create_accessible; - factory_class->get_accessible_type = gal_a11y_e_text_factory_get_accessible_type; -} - -static void -gal_a11y_e_text_factory_init (GalA11yETextFactory *factory) -{ -} - -/** - * gal_a11y_e_text_factory_get_type: - * @void: - * - * Registers the &GalA11yETextFactory class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yETextFactory class. - **/ -GType -gal_a11y_e_text_factory_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (GalA11yETextFactoryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gal_a11y_e_text_factory_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yETextFactory), - 0, - (GInstanceInitFunc) gal_a11y_e_text_factory_init, - NULL /* value_text */ - }; - - type = g_type_register_static (PARENT_TYPE, "GalA11yETextFactory", &info, 0); - } - - return type; -} diff --git a/a11y/e-text/gal-a11y-e-text-factory.h b/a11y/e-text/gal-a11y-e-text-factory.h deleted file mode 100644 index ce4d4d0a65..0000000000 --- a/a11y/e-text/gal-a11y-e-text-factory.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_TEXT_FACTORY_H__ -#define __GAL_A11Y_E_TEXT_FACTORY_H__ - -#include <glib-object.h> -#include <atk/atkobjectfactory.h> - -#define GAL_A11Y_TYPE_E_TEXT_FACTORY (gal_a11y_e_text_factory_get_type ()) -#define GAL_A11Y_E_TEXT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TEXT_FACTORY, GalA11yETextFactory)) -#define GAL_A11Y_E_TEXT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TEXT_FACTORY, GalA11yETextFactoryClass)) -#define GAL_A11Y_IS_E_TEXT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TEXT_FACTORY)) -#define GAL_A11Y_IS_E_TEXT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TEXT_FACTORY)) - -typedef struct _GalA11yETextFactory GalA11yETextFactory; -typedef struct _GalA11yETextFactoryClass GalA11yETextFactoryClass; - -struct _GalA11yETextFactory { - AtkObjectFactory object; -}; - -struct _GalA11yETextFactoryClass { - AtkObjectFactoryClass parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_text_factory_get_type (void); - -#endif /* ! __GAL_A11Y_E_TEXT_FACTORY_H__ */ diff --git a/a11y/e-text/gal-a11y-e-text.c b/a11y/e-text/gal-a11y-e-text.c deleted file mode 100644 index 4eeb7811fc..0000000000 --- a/a11y/e-text/gal-a11y-e-text.c +++ /dev/null @@ -1,1134 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <string.h> - -#include <gtk/gtk.h> - -#include "a11y/gal-a11y-util.h" -#include "text/e-text.h" -#include "text/e-text-model-repos.h" - -#include "gal-a11y-e-text.h" -#include "gal-a11y-e-text-factory.h" - -#define CS_CLASS(a11y) (G_TYPE_INSTANCE_GET_CLASS ((a11y), C_TYPE_STREAM, GalA11yETextClass)) -static GObjectClass *parent_class; -static AtkComponentIface *component_parent_iface; -static GType parent_type; -static gint priv_offset; -static GQuark quark_accessible_object = 0; -#define GET_PRIVATE(object) ((GalA11yETextPrivate *) (((char *) object) + priv_offset)) -#define PARENT_TYPE (parent_type) - -struct _GalA11yETextPrivate { - int dummy; -}; - -static void -et_dispose (GObject *object) -{ - if (parent_class->dispose) - parent_class->dispose (object); -} - -/* Static functions */ - -static void -et_get_extents (AtkComponent *component, - gint *x, - gint *y, - gint *width, - gint *height, - AtkCoordType coord_type) -{ - EText *item = E_TEXT (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (component))); - double real_width; - double real_height; - int fake_width; - int fake_height; - - if (component_parent_iface && - component_parent_iface->get_extents) - component_parent_iface->get_extents (component, - x, - y, - &fake_width, - &fake_height, - coord_type); - - g_object_get (item, - "text_width", &real_width, - "text_height", &real_height, - NULL); - - if (width) - *width = real_width; - if (height) - *height = real_height; -} - -static const gchar * -et_get_full_text (AtkText *text) -{ - EText *etext = E_TEXT (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text))); - ETextModel *model; - const char *full_text; - - g_object_get (etext, "model", &model, NULL); - - full_text = e_text_model_get_text (model); - - return full_text; -} - -static void -et_set_full_text (AtkEditableText *text, - const char *full_text) -{ - EText *etext = E_TEXT (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text))); - ETextModel *model; - - g_object_get (etext, "model", &model, NULL); - - e_text_model_set_text (model, full_text); -} - -static gchar * -et_get_text (AtkText *text, - gint start_offset, - gint end_offset) -{ - gint start, end, real_start, real_end, len; - const char *full_text = et_get_full_text (text); - if (full_text == NULL) - return NULL; - len = g_utf8_strlen (full_text, -1); - - start = MIN (MAX (0, start_offset), len); - end = MIN (MAX (-1, end_offset), len); - - if (end_offset == -1) - end = strlen (full_text); - else - end = g_utf8_offset_to_pointer (full_text, end) - full_text; - - start = g_utf8_offset_to_pointer (full_text, start) - full_text; - - real_start = MIN (start, end); - real_end = MAX (start, end); - - return g_strndup (full_text + real_start, real_end - real_start); -} - -static gboolean -is_a_seperator (gunichar c) -{ - return g_unichar_ispunct(c) || g_unichar_isspace(c); -} - -static gint -find_word_start (const char *text, - gint begin_offset, - gint step) -{ - gint offset; - char *at_offset; - gunichar current, previous; - gint len; - - offset = begin_offset; - len = g_utf8_strlen (text, -1); - - while (offset > 0 && offset < len) { - at_offset = g_utf8_offset_to_pointer (text, offset); - current = g_utf8_get_char_validated (at_offset, -1); - at_offset = g_utf8_offset_to_pointer (text, offset-1); - previous = g_utf8_get_char_validated (at_offset, -1); - if ((! is_a_seperator (current)) && is_a_seperator (previous)) - break; - offset += step; - } - - return offset; -} - -static gint -find_word_end (const char *text, - gint begin_offset, - gint step) -{ - gint offset; - char *at_offset; - gunichar current, previous; - gint len; - - offset = begin_offset; - len = g_utf8_strlen (text, -1); - - while (offset > 0 && offset < len) { - at_offset = g_utf8_offset_to_pointer (text, offset); - current = g_utf8_get_char_validated (at_offset, -1); - at_offset = g_utf8_offset_to_pointer (text, offset-1); - previous = g_utf8_get_char_validated (at_offset, -1); - if (is_a_seperator (current) && (! is_a_seperator (previous))) - break; - offset += step; - } - - return offset; -} - -static gint -find_sentence_start (const char *text, - gint begin_offset, - gint step) -{ - gint offset, last_word_end, len; - char *at_offset; - gunichar ch; - int i; - - offset = find_word_start (text, begin_offset, step); - len = g_utf8_strlen (text, -1); - - while (offset>0 && offset <len) { - last_word_end = find_word_end (text, offset - 1, -1); - if (last_word_end == 0) - break; - for (i = last_word_end; i < offset; i++) { - at_offset = g_utf8_offset_to_pointer (text, i); - ch = g_utf8_get_char_validated (at_offset, -1); - if (ch == '.' || ch == '!' || ch == '?') - return offset; - } - - offset = find_word_start (text, offset + step, step); - } - - return offset; -} - -static gint -find_sentence_end (const char *text, - gint begin_offset, - gint step) -{ - gint offset; - char *at_offset; - gunichar previous; - gint len; - - offset = begin_offset; - len = g_utf8_strlen (text, -1); - - while (offset > 0 && offset < len) { - at_offset = g_utf8_offset_to_pointer (text, offset - 1); - previous = g_utf8_get_char_validated (at_offset, -1); - if (previous == '.' || previous == '!' || previous == '?') - break; - offset += step; - } - - return offset; -} - -static gint -find_line_start (const char *text, - gint begin_offset, - gint step) -{ - gint offset; - char *at_offset; - gunichar previous; - gint len; - - offset = begin_offset; - len = g_utf8_strlen (text, -1); - - while (offset > 0 && offset < len) { - at_offset = g_utf8_offset_to_pointer (text, offset - 1); - previous = g_utf8_get_char_validated (at_offset, -1); - if (previous == '\n' || previous == '\r') - break; - offset += step; - } - - return offset; -} - -static gint -find_line_end (const char *text, - gint begin_offset, - gint step) -{ - gint offset; - char *at_offset; - gunichar current; - gint len; - - offset = begin_offset; - len = g_utf8_strlen (text, -1); - - while (offset >= 0 && offset < len) { - at_offset = g_utf8_offset_to_pointer (text, offset); - current = g_utf8_get_char_validated (at_offset, -1); - if (current == '\n' || current == '\r') - break; - offset += step; - } - - return offset; -} - -static gchar * -et_get_text_after_offset (AtkText *text, - gint offset, - AtkTextBoundary boundary_type, - gint *start_offset, - gint *end_offset) -{ - gint start, end, len; - const char *full_text = et_get_full_text (text); - g_return_val_if_fail (full_text, NULL); - - switch (boundary_type) - { - case ATK_TEXT_BOUNDARY_CHAR: - start = offset + 1; - end = offset + 2; - break; - case ATK_TEXT_BOUNDARY_WORD_START: - start = find_word_start (full_text, offset + 1, 1); - end = find_word_start (full_text, start + 1, 1); - break; - case ATK_TEXT_BOUNDARY_WORD_END: - start = find_word_end (full_text, offset + 1, 1); - end = find_word_end (full_text, start + 1, 1); - break; - case ATK_TEXT_BOUNDARY_SENTENCE_START: - start = find_sentence_start (full_text, offset + 1, 1); - end = find_sentence_start (full_text, start + 1, 1); - break; - case ATK_TEXT_BOUNDARY_SENTENCE_END: - start = find_sentence_end (full_text, offset + 1, 1); - end = find_sentence_end (full_text, start + 1, 1); - break; - case ATK_TEXT_BOUNDARY_LINE_START: - start = find_line_start (full_text, offset + 1, 1); - end = find_line_start (full_text, start + 1, 1); - break; - case ATK_TEXT_BOUNDARY_LINE_END: - start = find_line_end (full_text, offset + 1, 1); - end = find_line_end (full_text, start + 1, 1); - break; - default: - return NULL; - } - - len = g_utf8_strlen (full_text, -1); - if (start_offset) - *start_offset = MIN (MAX (0, start), len); - if (end_offset) - *end_offset = MIN (MAX (0, end), len); - return et_get_text (text, start, end); -} - -static gchar * -et_get_text_at_offset (AtkText *text, - gint offset, - AtkTextBoundary boundary_type, - gint *start_offset, - gint *end_offset) -{ - gint start, end, len; - const char *full_text = et_get_full_text (text); - g_return_val_if_fail (full_text, NULL); - - switch (boundary_type) - { - case ATK_TEXT_BOUNDARY_CHAR: - start = offset; - end = offset + 1; - break; - case ATK_TEXT_BOUNDARY_WORD_START: - start = find_word_start (full_text, offset - 1, -1); - end = find_word_start (full_text, offset, 1); - break; - case ATK_TEXT_BOUNDARY_WORD_END: - start = find_word_end (full_text, offset, -1); - end = find_word_end (full_text, offset + 1, 1); - break; - case ATK_TEXT_BOUNDARY_SENTENCE_START: - start = find_sentence_start (full_text, offset - 1, -1); - end = find_sentence_start (full_text, offset, 1); - break; - case ATK_TEXT_BOUNDARY_SENTENCE_END: - start = find_sentence_end (full_text, offset, -1); - end = find_sentence_end (full_text, offset + 1, 1); - break; - case ATK_TEXT_BOUNDARY_LINE_START: - start = find_line_start (full_text, offset - 1, -1); - end = find_line_start (full_text, offset, 1); - break; - case ATK_TEXT_BOUNDARY_LINE_END: - start = find_line_end (full_text, offset, -1); - end = find_line_end (full_text, offset + 1, 1); - break; - default: - return NULL; - } - - len = g_utf8_strlen (full_text, -1); - if (start_offset) - *start_offset = MIN (MAX (0, start), len); - if (end_offset) - *end_offset = MIN (MAX (0, end), len); - return et_get_text (text, start, end); -} - -static gunichar -et_get_character_at_offset (AtkText *text, - gint offset) -{ - const char *full_text = et_get_full_text (text); - char *at_offset; - - at_offset = g_utf8_offset_to_pointer (full_text, offset); - return g_utf8_get_char_validated (at_offset, -1); -} - - -static gchar* -et_get_text_before_offset (AtkText *text, - gint offset, - AtkTextBoundary boundary_type, - gint *start_offset, - gint *end_offset) -{ - gint start, end, len; - const char *full_text = et_get_full_text (text); - g_return_val_if_fail (full_text, NULL); - - switch (boundary_type) - { - case ATK_TEXT_BOUNDARY_CHAR: - start = offset - 1; - end = offset; - break; - case ATK_TEXT_BOUNDARY_WORD_START: - end = find_word_start (full_text, offset - 1, -1); - start = find_word_start (full_text, end - 1, -1) ; - break; - case ATK_TEXT_BOUNDARY_WORD_END: - end = find_word_end (full_text, offset, -1); - start = find_word_end (full_text, end - 1, -1); - break; - case ATK_TEXT_BOUNDARY_SENTENCE_START: - end = find_sentence_start (full_text, offset, -1); - start = find_sentence_start (full_text, end - 1, -1); - break; - case ATK_TEXT_BOUNDARY_SENTENCE_END: - end = find_sentence_end (full_text, offset, -1); - start = find_sentence_end (full_text, end - 1, -1); - break; - case ATK_TEXT_BOUNDARY_LINE_START: - end = find_line_start (full_text, offset, -1); - start = find_line_start (full_text, end - 1, -1); - break; - case ATK_TEXT_BOUNDARY_LINE_END: - end = find_line_end (full_text, offset, -1); - start = find_line_end (full_text, end - 1, -1); - break; - default: - return NULL; - } - - len = g_utf8_strlen (full_text, -1); - if (start_offset) - *start_offset = MIN (MAX (0, start), len); - if (end_offset) - *end_offset = MIN (MAX (0, end), len); - return et_get_text (text, start, end); -} - -static gint -et_get_caret_offset (AtkText *text) -{ - GObject *obj; - EText *etext; - int offset; - - g_return_val_if_fail (ATK_IS_GOBJECT_ACCESSIBLE(text), -1); - obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text)); - if (obj == NULL) - return -1; - - g_return_val_if_fail (E_IS_TEXT (obj), -1); - etext = E_TEXT (obj); - - g_object_get (etext, "cursor_pos", &offset, NULL); - return offset; -} - - -static AtkAttributeSet* -et_get_run_attributes (AtkText *text, - gint offset, - gint *start_offset, - gint *end_offset) -{ - /* Unimplemented */ - return NULL; -} - - -static AtkAttributeSet* -et_get_default_attributes (AtkText *text) -{ - /* Unimplemented */ - return NULL; -} - - -static void -et_get_character_extents (AtkText *text, - gint offset, - gint *x, - gint *y, - gint *width, - gint *height, - AtkCoordType coords) -{ - GObject *obj; - EText *etext; - GnomeCanvas *canvas; - gint x_widget, y_widget, x_window, y_window; - GdkWindow *window; - GtkWidget *widget; - PangoRectangle pango_pos; - - g_return_if_fail (ATK_IS_GOBJECT_ACCESSIBLE(text)); - obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text)); - if (obj == NULL) - return; - g_return_if_fail (E_IS_TEXT (obj)); - etext = E_TEXT(obj); - canvas = GNOME_CANVAS_ITEM(etext)->canvas; - widget = GTK_WIDGET(canvas); - window = widget->window; - gdk_window_get_origin (window, &x_widget, &y_widget); - - pango_layout_index_to_pos (etext->layout, offset, &pango_pos); - pango_pos.x = PANGO_PIXELS (pango_pos.x); - pango_pos.y = PANGO_PIXELS (pango_pos.y); - pango_pos.width = (pango_pos.width + PANGO_SCALE / 2) / PANGO_SCALE; - pango_pos.height = (pango_pos.height + PANGO_SCALE / 2) / PANGO_SCALE; - - *x = pango_pos.x + x_widget; - *y = pango_pos.y + y_widget; - - *width = pango_pos.width; - *height = pango_pos.height; - - if (etext->draw_borders) { - *x += 3; /*BORDER_INDENT;*/ - *y += 3; /*BORDER_INDENT;*/ - } - - *x += etext->xofs; - *y += etext->yofs; - - if (etext->editing) { - *x -= etext->xofs_edit; - *y -= etext->yofs_edit; - } - - *x += etext->cx; - *y += etext->cy; - - if (coords == ATK_XY_WINDOW) { - window = gdk_window_get_toplevel (window); - gdk_window_get_origin (window, &x_window, &y_window); - *x -= x_window; - *y -= y_window; - } - else if (coords == ATK_XY_SCREEN) { - } - else { - *x = 0; - *y = 0; - *height = 0; - *width = 0; - } -} - - -static gint -et_get_character_count (AtkText *text) -{ - const char *full_text = et_get_full_text (text); - - return g_utf8_strlen (full_text, -1); -} - - -static gint -et_get_offset_at_point (AtkText *text, - gint x, - gint y, - AtkCoordType coords) -{ - GObject *obj; - EText *etext; - GnomeCanvas *canvas; - gint x_widget, y_widget, x_window, y_window; - GdkWindow *window; - GtkWidget *widget; - int index; - int trailing; - - g_return_val_if_fail (ATK_IS_GOBJECT_ACCESSIBLE(text), -1); - obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text)); - if (obj == NULL) - return -1; - g_return_val_if_fail (E_IS_TEXT (obj), -1); - etext = E_TEXT(obj); - canvas = GNOME_CANVAS_ITEM(etext)->canvas; - widget = GTK_WIDGET(canvas); - window = widget->window; - gdk_window_get_origin (window, &x_widget, &y_widget); - - if (coords == ATK_XY_SCREEN) { - x = x - x_widget; - y = y - y_widget; - } - else if (coords == ATK_XY_WINDOW) { - window = gdk_window_get_toplevel (window); - gdk_window_get_origin (window, &x_window, &y_window); - x = x - x_widget + x_window; - y = y - y_widget + y_window; - } - else - return -1; - - if (etext->draw_borders) { - x -= 3; /*BORDER_INDENT;*/ - y -= 3; /*BORDER_INDENT;*/ - } - - x -= etext->xofs; - y -= etext->yofs; - - if (etext->editing) { - x += etext->xofs_edit; - y += etext->yofs_edit; - } - - x -= etext->cx; - y -= etext->cy; - - pango_layout_xy_to_index (etext->layout, - x * PANGO_SCALE - PANGO_SCALE / 2, - y * PANGO_SCALE - PANGO_SCALE / 2, - &index, - &trailing); - - return g_utf8_pointer_to_offset (etext->text, etext->text + index + trailing); -} - - -static gint -et_get_n_selections (AtkText *text) -{ - EText *etext = E_TEXT (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text))); - if (etext->selection_start != - etext->selection_end) - return 1; - return 0; -} - - -static gchar* -et_get_selection (AtkText *text, - gint selection_num, - gint *start_offset, - gint *end_offset) -{ - gint start, end, real_start, real_end, len; - EText *etext; - if (selection_num == 0) { - const char *full_text = et_get_full_text (text); - if (full_text == NULL) - return NULL; - len = g_utf8_strlen (full_text, -1); - etext = E_TEXT (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text))); - start = MIN (etext->selection_start, etext->selection_end); - end = MAX (etext->selection_start, etext->selection_end); - start = MIN (MAX (0, start), len); - end = MIN (MAX (0, end), len); - if (start != end) { - if (start_offset) - *start_offset = start; - if (end_offset) - *end_offset = end; - real_start = g_utf8_offset_to_pointer (full_text, start) - full_text; - real_end = g_utf8_offset_to_pointer (full_text, end) - full_text; - return g_strndup (full_text + real_start, real_end - real_start); - } - } - - return NULL; -} - - -static gboolean -et_add_selection (AtkText *text, - gint start_offset, - gint end_offset) -{ - GObject *obj; - EText *etext; - - g_return_val_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (text), FALSE); - obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text)); - if (obj == NULL) - return FALSE; - g_return_val_if_fail (E_IS_TEXT (obj), FALSE); - etext = E_TEXT (obj); - - g_return_val_if_fail (start_offset >= 0, FALSE); - g_return_val_if_fail (start_offset >= -1, FALSE); - if (end_offset == -1) - end_offset = et_get_character_count (text); - - if (start_offset != end_offset) { - gint real_start, real_end; - real_start = MIN (start_offset, end_offset); - real_end = MAX (start_offset, end_offset); - etext->selection_start = real_start; - etext->selection_end = real_end; - - gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (etext)); - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (etext)); - - g_signal_emit_by_name (ATK_OBJECT (text), "text_selection_changed"); - - return TRUE; - } - - return FALSE; -} - - -static gboolean -et_remove_selection (AtkText *text, - gint selection_num) -{ - GObject *obj; - EText *etext; - - g_return_val_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (text), FALSE); - obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text)); - if (obj == NULL) - return FALSE; - g_return_val_if_fail (E_IS_TEXT (obj), FALSE); - etext = E_TEXT (obj); - - if (selection_num == 0 - && etext->selection_start != etext->selection_end) { - etext->selection_end = etext->selection_start; - g_signal_emit_by_name (ATK_OBJECT(text), "text_selection_changed"); - return TRUE; - } - - return FALSE; -} - - -static gboolean -et_set_selection (AtkText *text, - gint selection_num, - gint start_offset, - gint end_offset) -{ - GObject *obj; - - g_return_val_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (text), FALSE); - obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text)); - if (obj == NULL) - return FALSE; - g_return_val_if_fail (E_IS_TEXT (obj), FALSE); - if (selection_num == 0) - return et_add_selection (text, start_offset, end_offset); - return FALSE; -} - - -static gboolean -et_set_caret_offset (AtkText *text, - gint offset) -{ - GObject *obj; - EText *etext; - - g_return_val_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (text), FALSE); - obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text)); - if (obj == NULL) - return FALSE; - - g_return_val_if_fail (E_IS_TEXT (obj), FALSE); - etext = E_TEXT (obj); - - if (offset < -1) - return FALSE; - else { - ETextEventProcessorCommand command; - - if (offset == -1) - offset = et_get_character_count (text); - - command.action = E_TEP_MOVE; - command.position = E_TEP_VALUE; - command.value = offset; - command.time = GDK_CURRENT_TIME; - g_signal_emit_by_name (etext->tep, "command", &command); - return TRUE; - } -} - -static gboolean -et_set_run_attributes (AtkEditableText *text, - AtkAttributeSet *attrib_set, - gint start_offset, - gint end_offset) -{ - /* Unimplemented */ - return FALSE; -} - -static void -et_set_text_contents (AtkEditableText *text, - const gchar *string) -{ - et_set_full_text (text, string); -} - -static void -et_insert_text (AtkEditableText *text, - const gchar *string, - gint length, - gint *position) -{ - /* Utf8 unimplemented */ - char *result; - - const char *full_text = et_get_full_text (ATK_TEXT (text)); - if (full_text == NULL) - return; - - result = g_strdup_printf ("%.*s%.*s%s", *position, full_text, length, string, full_text + *position); - - et_set_full_text (text, result); - - *position += length; - - g_free (result); -} - -static void -et_copy_text (AtkEditableText *text, - gint start_pos, - gint end_pos) -{ - GObject *obj; - EText *etext; - - g_return_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (text)); - obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text)); - if (obj == NULL) - return; - - g_return_if_fail (E_IS_TEXT (obj)); - etext = E_TEXT (obj); - - if (start_pos != end_pos) { - etext->selection_start = start_pos; - etext->selection_end = end_pos; - e_text_copy_clipboard (etext); - } -} - -static void -et_delete_text (AtkEditableText *text, - gint start_pos, - gint end_pos) -{ - GObject *obj; - EText *etext; - - g_return_if_fail (ATK_IS_GOBJECT_ACCESSIBLE(text)); - obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text)); - if (obj == NULL) - return; - - g_return_if_fail (E_IS_TEXT (obj)); - etext = E_TEXT (obj); - - etext->selection_start = start_pos; - etext->selection_end = end_pos; - - e_text_delete_selection (etext); -} - -static void -et_cut_text (AtkEditableText *text, - gint start_pos, - gint end_pos) -{ - et_copy_text (text, start_pos, end_pos); - et_delete_text (text, start_pos, end_pos); -} - -static void -et_paste_text (AtkEditableText *text, - gint position) -{ - GObject *obj; - EText *etext; - - g_return_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (text)); - obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text)); - if (obj == NULL) - return; - - g_return_if_fail (E_IS_TEXT (obj)); - etext = E_TEXT (obj); - - g_object_set (etext, "cursor_pos", position, NULL); - e_text_paste_clipboard (etext); -} - -static void -et_atk_component_iface_init (AtkComponentIface *iface) -{ - iface->get_extents = et_get_extents; -} - -static void -et_atk_text_iface_init (AtkTextIface *iface) -{ - iface->get_text = et_get_text; - iface->get_text_after_offset = et_get_text_after_offset; - iface->get_text_at_offset = et_get_text_at_offset; - iface->get_character_at_offset = et_get_character_at_offset; - iface->get_text_before_offset = et_get_text_before_offset; - iface->get_caret_offset = et_get_caret_offset; - iface->get_run_attributes = et_get_run_attributes; - iface->get_default_attributes = et_get_default_attributes; - iface->get_character_extents = et_get_character_extents; - iface->get_character_count = et_get_character_count; - iface->get_offset_at_point = et_get_offset_at_point; - iface->get_n_selections = et_get_n_selections; - iface->get_selection = et_get_selection; - iface->add_selection = et_add_selection; - iface->remove_selection = et_remove_selection; - iface->set_selection = et_set_selection; - iface->set_caret_offset = et_set_caret_offset; -} - -static void -et_atk_editable_text_iface_init (AtkEditableTextIface *iface) -{ - iface->set_run_attributes = et_set_run_attributes; - iface->set_text_contents = et_set_text_contents; - iface->insert_text = et_insert_text; - iface->copy_text = et_copy_text; - iface->cut_text = et_cut_text; - iface->delete_text = et_delete_text; - iface->paste_text = et_paste_text; -} - -static void -_et_reposition_cb (ETextModel *model, - ETextModelReposFn fn, - gpointer repos_data, - gpointer user_data) -{ - AtkObject *accessible; - AtkText *text; - - accessible = ATK_OBJECT (user_data); - text = ATK_TEXT (accessible); - - if (fn == e_repos_delete_shift) { - EReposDeleteShift *info = (EReposDeleteShift *) repos_data; - g_signal_emit_by_name (text, "text-changed::delete", info->pos, info->len); - } - else if (fn == e_repos_insert_shift) { - EReposInsertShift *info = (EReposInsertShift *) repos_data; - g_signal_emit_by_name (text, "text-changed::insert", info->pos, info->len); - } -} - -static void -_et_command_cb (ETextEventProcessor *tep, - ETextEventProcessorCommand *command, - gpointer user_data) -{ - AtkObject *accessible; - AtkText *text; - - accessible = ATK_OBJECT (user_data); - text = ATK_TEXT (accessible); - - switch (command->action) { - case E_TEP_MOVE: - g_signal_emit_by_name (text, "text-caret-moved", et_get_caret_offset (text)); - break; - case E_TEP_SELECT: - g_signal_emit_by_name (text, "text-selection-changed"); - break; - default: - break; - } -} - -static void -et_real_initialize (AtkObject *obj, - gpointer data) -{ - EText *etext; - - ATK_OBJECT_CLASS (parent_class)->initialize (obj, data); - - g_return_if_fail (GAL_A11Y_IS_E_TEXT (obj)); - g_return_if_fail (E_IS_TEXT (data)); - - etext = E_TEXT (data); - - /* Set up signal callbacks */ - g_signal_connect (etext->model, "reposition", - G_CALLBACK (_et_reposition_cb), obj); - - if (etext->tep) - g_signal_connect_after (etext->tep, "command", - (GCallback) _et_command_cb, obj); - - obj->role = ATK_ROLE_TEXT; -} - -static void -et_class_init (GalA11yETextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass); - - quark_accessible_object = g_quark_from_static_string ("gtk-accessible-object"); - parent_class = g_type_class_ref (PARENT_TYPE); - component_parent_iface = g_type_interface_peek(parent_class, ATK_TYPE_COMPONENT); - object_class->dispose = et_dispose; - atk_class->initialize = et_real_initialize; -} - -static void -et_init (GalA11yEText *a11y) -{ -#if 0 - GalA11yETextPrivate *priv; - - priv = GET_PRIVATE (a11y); -#endif -} - -/** - * gal_a11y_e_text_get_type: - * @void: - * - * Registers the &GalA11yEText class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GalA11yEText class. - **/ -GType -gal_a11y_e_text_get_type (void) -{ - static GType type = 0; - - if (!type) { - AtkObjectFactory *factory; - - GTypeInfo info = { - sizeof (GalA11yETextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) et_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GalA11yEText), - 0, - (GInstanceInitFunc) et_init, - NULL /* value_text */ - }; - - static const GInterfaceInfo atk_component_info = { - (GInterfaceInitFunc) et_atk_component_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - static const GInterfaceInfo atk_text_info = { - (GInterfaceInitFunc) et_atk_text_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - static const GInterfaceInfo atk_editable_text_info = { - (GInterfaceInitFunc) et_atk_editable_text_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - factory = atk_registry_get_factory (atk_get_default_registry (), GNOME_TYPE_CANVAS_ITEM); - parent_type = atk_object_factory_get_accessible_type (factory); - - type = gal_a11y_type_register_static_with_private (PARENT_TYPE, "GalA11yEText", &info, 0, - sizeof (GalA11yETextPrivate), &priv_offset); - - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, &atk_component_info); - g_type_add_interface_static (type, ATK_TYPE_TEXT, &atk_text_info); - g_type_add_interface_static (type, ATK_TYPE_EDITABLE_TEXT, &atk_editable_text_info); - } - - return type; -} - -void -gal_a11y_e_text_init (void) -{ - if (atk_get_root ()) - atk_registry_set_factory_type (atk_get_default_registry (), - E_TYPE_TEXT, - gal_a11y_e_text_factory_get_type ()); - -} - diff --git a/a11y/e-text/gal-a11y-e-text.h b/a11y/e-text/gal-a11y-e-text.h deleted file mode 100644 index 5cebd0ff83..0000000000 --- a/a11y/e-text/gal-a11y-e-text.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_A11Y_E_TEXT_H__ -#define __GAL_A11Y_E_TEXT_H__ - -#include <glib-object.h> -#include <table/e-table-item.h> - -#define GAL_A11Y_TYPE_E_TEXT (gal_a11y_e_text_get_type ()) -#define GAL_A11Y_E_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TEXT, GalA11yEText)) -#define GAL_A11Y_E_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TEXT, GalA11yETextClass)) -#define GAL_A11Y_IS_E_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TEXT)) -#define GAL_A11Y_IS_E_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TEXT)) - -typedef struct _GalA11yEText GalA11yEText; -typedef struct _GalA11yETextClass GalA11yETextClass; -typedef struct _GalA11yETextPrivate GalA11yETextPrivate; - -/* This struct should actually be larger as this isn't what we derive from. - * The GalA11yETextPrivate comes right after the parent class structure. - **/ -struct _GalA11yEText { - AtkObject object; -}; - -struct _GalA11yETextClass { - AtkObject parent_class; -}; - - -/* Standard Glib function */ -GType gal_a11y_e_text_get_type (void); - -void gal_a11y_e_text_init (void); - -#endif /* ! __GAL_A11Y_E_TEXT_H__ */ diff --git a/a11y/widgets/Makefile.am b/a11y/widgets/Makefile.am deleted file mode 100644 index fbb8b68916..0000000000 --- a/a11y/widgets/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ - -# for debug -#A11Y_CFLAGS += -pedantic -ansi -DACC_DEBUG -Werror - -if OS_WIN32 -WIN32_BOOTSTRAP_LIBS = $(top_builddir)/win32/libemiscwidgets.la -endif - -privsolib_LTLIBRARIES = libevolution-widgets-a11y.la - -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-a11y\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/a11y \ - -I$(top_srcdir)/widgets \ - $(E_WIDGETS_CFLAGS) - -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_LDFLAGS = $(NO_UNDEFINED) - -libevolution_widgets_a11y_la_LIBADD = \ - $(WIN32_BOOTSTRAP_LIBS) \ - $(top_builddir)/a11y/libevolution-a11y.la \ - $(top_builddir)/e-util/libeutil.la \ - $(E_WIDGETS_LIBS) - --include $(top_srcdir)/git.mk diff --git a/a11y/widgets/ea-calendar-cell.c b/a11y/widgets/ea-calendar-cell.c deleted file mode 100644 index 9cd3a58622..0000000000 --- a/a11y/widgets/ea-calendar-cell.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <gtk/gtk.h> -#include <e-util/e-util.h> -#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 void ea_calendar_cell_init (EaCalendarCell *a11y); - -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); -static gint ea_calendar_cell_get_index_in_parent (AtkObject *accessible); -static AtkStateSet *ea_calendar_cell_ref_state_set (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 gboolean component_interface_grab_focus (AtkComponent *component); - -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) ea_calendar_cell_init, /* 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; - class->get_index_in_parent = ea_calendar_cell_get_index_in_parent; - class->ref_state_set = ea_calendar_cell_ref_state_set; -} - -static void -ea_calendar_cell_init (EaCalendarCell *a11y) -{ - a11y->state_set = atk_state_set_new (); - atk_state_set_add_state (a11y->state_set, ATK_STATE_TRANSIENT); - atk_state_set_add_state (a11y->state_set, ATK_STATE_ENABLED); - atk_state_set_add_state (a11y->state_set, ATK_STATE_SENSITIVE); - atk_state_set_add_state (a11y->state_set, ATK_STATE_SELECTABLE); - atk_state_set_add_state (a11y->state_set, ATK_STATE_SHOWING); - atk_state_set_add_state (a11y->state_set, ATK_STATE_FOCUSABLE); -} - -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) -{ - G_OBJECT_CLASS (parent_class)->finalize (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)); -} - -static gint -ea_calendar_cell_get_index_in_parent (AtkObject *accessible) -{ - GObject *g_obj; - ECalendarCell *cell; - AtkObject *parent; - - g_return_val_if_fail (EA_IS_CALENDAR_CELL (accessible), -1); - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible)); - if (!g_obj) - return -1; - cell = E_CALENDAR_CELL (g_obj); - parent = atk_object_get_parent (accessible); - return atk_table_get_index_at (ATK_TABLE (parent), - cell->row, cell->column); -} - -static AtkStateSet * -ea_calendar_cell_ref_state_set (AtkObject *accessible) -{ - EaCalendarCell *atk_cell = EA_CALENDAR_CELL (accessible); - - g_return_val_if_fail (atk_cell->state_set, NULL); - - g_object_ref(atk_cell->state_set); - - return atk_cell->state_set; - -} - -/* Atk Component Interface */ - -static void -atk_component_interface_init (AtkComponentIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->get_extents = component_interface_get_extents; - iface->grab_focus = component_interface_grab_focus; -} - -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; -} - -static gboolean -component_interface_grab_focus (AtkComponent *component) -{ - GObject *g_obj; - GtkWidget *toplevel; - AtkObject *ea_calitem; - ECalendarItem *calitem; - EaCalendarCell *a11y; - gint index; - - a11y = EA_CALENDAR_CELL (component); - ea_calitem = ea_calendar_cell_get_parent (ATK_OBJECT (a11y)); - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(ea_calitem)); - calitem = E_CALENDAR_ITEM (g_obj); - - index = atk_object_get_index_in_parent (ATK_OBJECT (a11y)); - - atk_selection_clear_selection (ATK_SELECTION (ea_calitem)); - atk_selection_add_selection (ATK_SELECTION (ea_calitem), index); - - gtk_widget_grab_focus (GTK_WIDGET (GNOME_CANVAS_ITEM (calitem)->canvas)); - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (GNOME_CANVAS_ITEM (calitem)->canvas)); - if (toplevel && GTK_WIDGET_TOPLEVEL (toplevel)) - gtk_window_present (GTK_WINDOW (toplevel)); - - return TRUE; - -} diff --git a/a11y/widgets/ea-calendar-cell.h b/a11y/widgets/ea-calendar-cell.h deleted file mode 100644 index a07b7e8bbc..0000000000 --- a/a11y/widgets/ea-calendar-cell.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#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; - AtkStateSet *state_set; -}; - -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__ */ diff --git a/a11y/widgets/ea-calendar-item.c b/a11y/widgets/ea-calendar-item.c deleted file mode 100644 index a3da175df1..0000000000 --- a/a11y/widgets/ea-calendar-item.c +++ /dev/null @@ -1,1314 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <stdio.h> -#include <time.h> -#include <string.h> -#include <libgnomecanvas/gnome-canvas.h> -#include <glib.h> -#include <e-util/e-util.h> -#include <glib/gi18n.h> -#include <libedataserver/e-data-server-util.h> -#include "ea-calendar-item.h" -#include "ea-calendar-cell.h" -#include "ea-cell-table.h" - -#define EA_CALENDAR_COLUMN_NUM E_CALENDAR_COLS_PER_MONTH - -/* EaCalendarItem */ -static void ea_calendar_item_class_init (EaCalendarItemClass *klass); -static void ea_calendar_item_finalize (GObject *object); - -static G_CONST_RETURN gchar* ea_calendar_item_get_name (AtkObject *accessible); -static G_CONST_RETURN gchar* ea_calendar_item_get_description (AtkObject *accessible); -static gint ea_calendar_item_get_n_children (AtkObject *accessible); -static AtkObject *ea_calendar_item_ref_child (AtkObject *accessible, gint index); -static AtkStateSet* ea_calendar_item_ref_state_set (AtkObject *accessible); - -/* atk table interface */ -static void atk_table_interface_init (AtkTableIface *iface); -static gint table_interface_get_index_at (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_column_at_index (AtkTable *table, - gint index); -static gint table_interface_get_row_at_index (AtkTable *table, - gint index); -static AtkObject* table_interface_ref_at (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_n_rows (AtkTable *table); -static gint table_interface_get_n_columns (AtkTable *table); -static gint table_interface_get_column_extent_at (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_row_extent_at (AtkTable *table, - gint row, - gint column); - -static gboolean table_interface_is_row_selected (AtkTable *table, - gint row); -static gboolean table_interface_is_column_selected (AtkTable *table, - gint row); -static gboolean table_interface_is_selected (AtkTable *table, - gint row, - gint column); -static gint table_interface_get_selected_rows (AtkTable *table, - gint **rows_selected); -static gint table_interface_get_selected_columns (AtkTable *table, - gint **columns_selected); -static gboolean table_interface_add_row_selection (AtkTable *table, gint row); -static gboolean table_interface_remove_row_selection (AtkTable *table, - gint row); -static gboolean table_interface_add_column_selection (AtkTable *table, - gint column); -static gboolean table_interface_remove_column_selection (AtkTable *table, - gint column); -static AtkObject* table_interface_get_row_header (AtkTable *table, gint row); -static AtkObject* table_interface_get_column_header (AtkTable *table, - gint in_col); -static AtkObject* table_interface_get_caption (AtkTable *table); - -static G_CONST_RETURN gchar* -table_interface_get_column_description (AtkTable *table, gint in_col); - -static G_CONST_RETURN gchar* -table_interface_get_row_description (AtkTable *table, gint row); - -static AtkObject* table_interface_get_summary (AtkTable *table); - -/* atk selection interface */ -static void atk_selection_interface_init (AtkSelectionIface *iface); -static gboolean selection_interface_add_selection (AtkSelection *selection, - gint i); -static gboolean selection_interface_clear_selection (AtkSelection *selection); -static AtkObject* selection_interface_ref_selection (AtkSelection *selection, - gint i); -static gint selection_interface_get_selection_count (AtkSelection *selection); -static gboolean selection_interface_is_child_selected (AtkSelection *selection, - gint i); - -/* callbacks */ -static void selection_preview_change_cb (ECalendarItem *calitem); -static void date_range_changed_cb (ECalendarItem *calitem); - -/* helpers */ -static EaCellTable *ea_calendar_item_get_cell_data (EaCalendarItem *ea_calitem); -static void ea_calendar_item_destory_cell_data (EaCalendarItem *ea_calitem); -static gboolean ea_calendar_item_get_column_label (EaCalendarItem *ea_calitem, - gint column, - gchar *buffer, - gint buffer_size); -static gboolean ea_calendar_item_get_row_label (EaCalendarItem *ea_calitem, - gint row, - gchar *buffer, - gint buffer_size); -static gboolean e_calendar_item_get_offset_for_date (ECalendarItem *calitem, - gint year, gint month, gint day, - gint *offset); -static void ea_calendar_set_focus_object (EaCalendarItem *ea_calitem, - AtkObject *item_cell); - -#ifdef ACC_DEBUG -static gint n_ea_calendar_item_created = 0; -static gint n_ea_calendar_item_destroyed = 0; -#endif - -static gpointer parent_class = NULL; - -GType -ea_calendar_item_get_type (void) -{ - static GType type = 0; - AtkObjectFactory *factory; - GTypeQuery query; - GType derived_atk_type; - - if (!type) { - static GTypeInfo tinfo = { - sizeof (EaCalendarItemClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) ea_calendar_item_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EaCalendarItem), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - static const GInterfaceInfo atk_table_info = { - (GInterfaceInitFunc) atk_table_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - static const GInterfaceInfo atk_selection_info = { - (GInterfaceInitFunc) atk_selection_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - /* - * Figure out the size of the class and instance - * we are run-time deriving from (GailCanvasItem, in this case) - */ - - factory = atk_registry_get_factory (atk_get_default_registry (), - GNOME_TYPE_CANVAS_ITEM); - derived_atk_type = atk_object_factory_get_accessible_type (factory); - g_type_query (derived_atk_type, &query); - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - type = g_type_register_static (derived_atk_type, - "EaCalendarItem", &tinfo, 0); - g_type_add_interface_static (type, ATK_TYPE_TABLE, - &atk_table_info); - g_type_add_interface_static (type, ATK_TYPE_SELECTION, - &atk_selection_info); - } - - return type; -} - -static void -ea_calendar_item_class_init (EaCalendarItemClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); - - gobject_class->finalize = ea_calendar_item_finalize; - parent_class = g_type_class_peek_parent (klass); - - class->get_name = ea_calendar_item_get_name; - class->get_description = ea_calendar_item_get_description; - class->ref_state_set = ea_calendar_item_ref_state_set; - - class->get_n_children = ea_calendar_item_get_n_children; - class->ref_child = ea_calendar_item_ref_child; -} - -AtkObject* -ea_calendar_item_new (GObject *obj) -{ - gpointer object; - AtkObject *atk_object; - AtkObject *item_cell; - - g_return_val_if_fail (E_IS_CALENDAR_ITEM (obj), NULL); - object = g_object_new (EA_TYPE_CALENDAR_ITEM, NULL); - atk_object = ATK_OBJECT (object); - atk_object_initialize (atk_object, obj); - atk_object->role = ATK_ROLE_CALENDAR; - - item_cell = atk_selection_ref_selection (ATK_SELECTION (atk_object), - 0); - if (item_cell) - ea_calendar_set_focus_object (EA_CALENDAR_ITEM (atk_object), item_cell); - -#ifdef ACC_DEBUG - ++n_ea_calendar_item_created; - g_print ("ACC_DEBUG: n_ea_calendar_item_created = %d\n", - n_ea_calendar_item_created); -#endif - /* connect signal handlers */ - g_signal_connect (obj, "selection_preview_changed", - G_CALLBACK (selection_preview_change_cb), - atk_object); - g_signal_connect (obj, "date_range_changed", - G_CALLBACK (date_range_changed_cb), - atk_object); - - return atk_object; -} - -static void -ea_calendar_item_finalize (GObject *object) -{ - EaCalendarItem *ea_calitem; - - g_return_if_fail (EA_IS_CALENDAR_ITEM (object)); - - ea_calitem = EA_CALENDAR_ITEM (object); - - /* Free the allocated cell data */ - ea_calendar_item_destory_cell_data (ea_calitem); - - G_OBJECT_CLASS (parent_class)->finalize (object); -#ifdef ACC_DEBUG - ++n_ea_calendar_item_destroyed; - printf ("ACC_DEBUG: n_ea_calendar_item_destroyed = %d\n", - n_ea_calendar_item_destroyed); -#endif -} - -static G_CONST_RETURN gchar* -ea_calendar_item_get_name (AtkObject *accessible) -{ - GObject *g_obj; - ECalendarItem *calitem; - gint start_year, start_month, start_day; - gint end_year, end_month, end_day; - gchar *name_str = NULL; - gchar buffer_start[128] = ""; - gchar buffer_end[128] = ""; - struct tm day_start = { 0 }; - struct tm day_end = { 0 }; - - g_return_val_if_fail (EA_IS_CALENDAR_ITEM (accessible), NULL); - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible)); - if (!g_obj) - return NULL; - g_return_val_if_fail (E_IS_CALENDAR_ITEM (g_obj), NULL); - - calitem = E_CALENDAR_ITEM (g_obj); - if (e_calendar_item_get_date_range (calitem, - &start_year, &start_month, &start_day, - &end_year, &end_month, &end_day)) { - - day_start.tm_year = start_year - 1900; - day_start.tm_mon = start_month; - day_start.tm_mday = start_day; - day_start.tm_isdst = -1; - e_utf8_strftime (buffer_start, sizeof (buffer_start), _("%d %B %Y"), &day_start); - - day_end.tm_year = end_year - 1900; - day_end.tm_mon = end_month; - day_end.tm_mday = end_day; - day_end.tm_isdst = -1; - e_utf8_strftime (buffer_end, sizeof (buffer_end), _("%d %B %Y"), &day_end); - - name_str = g_strdup_printf (_("Calendar: from %s to %s"), buffer_start, buffer_end); - } - -#if 0 - if (e_calendar_item_get_selection (calitem, &select_start, &select_end)) { - GDate select_start, select_end; - gint year1, year2, month1, month2, day1, day2; - - year1 = g_date_get_year (&select_start); - month1 = g_date_get_month (&select_start); - day1 = g_date_get_day (&select_start); - - year2 = g_date_get_year (&select_end); - month2 = g_date_get_month (&select_end); - day2 = g_date_get_day (&select_end); - - sprintf (new_name + strlen (new_name), - " : current selection: from %d-%d-%d to %d-%d-%d.", - year1, month1, day1, - year2, month2, day2); - } -#endif - - ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name_str); - g_free (name_str); - - return accessible->name; -} - -static G_CONST_RETURN gchar* -ea_calendar_item_get_description (AtkObject *accessible) -{ - if (accessible->description) - return accessible->description; - - return _("evolution calendar item"); -} - -static AtkStateSet* -ea_calendar_item_ref_state_set (AtkObject *accessible) -{ - AtkStateSet *state_set; - GObject *g_obj; - - state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible); - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible)); - if (!g_obj) - return state_set; - - atk_state_set_add_state (state_set, ATK_STATE_ENABLED); - atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE); - - return state_set; -} - -static gint -ea_calendar_item_get_n_children (AtkObject *accessible) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - ECalendarItem *calitem; - gint n_children = 0; - gint start_year, start_month, start_day; - gint end_year, end_month, end_day; - GDate *start_date, *end_date; - - g_return_val_if_fail (EA_IS_CALENDAR_ITEM (accessible), -1); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - calitem = E_CALENDAR_ITEM (g_obj); - if (!e_calendar_item_get_date_range (calitem, &start_year, - &start_month, &start_day, - &end_year, &end_month, - &end_day)) - return 0; - - start_date = g_date_new_dmy (start_day, start_month + 1, start_year); - end_date = g_date_new_dmy (end_day, end_month + 1, end_year); - - n_children = g_date_days_between (start_date, end_date) + 1; - g_free (start_date); - g_free (end_date); - return n_children; -} - -static AtkObject * -ea_calendar_item_ref_child (AtkObject *accessible, gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - ECalendarItem *calitem; - gint n_children; - ECalendarCell *cell; - EaCellTable *cell_data; - EaCalendarItem *ea_calitem; - - g_return_val_if_fail (EA_IS_CALENDAR_ITEM (accessible), NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - calitem = E_CALENDAR_ITEM (g_obj); - - n_children = ea_calendar_item_get_n_children (accessible); - if (index < 0 || index >= n_children) - return NULL; - - ea_calitem = EA_CALENDAR_ITEM (accessible); - cell_data = ea_calendar_item_get_cell_data (ea_calitem); - if (!cell_data) - return NULL; - - cell = ea_cell_table_get_cell_at_index (cell_data, index); - if (!cell) { - cell = e_calendar_cell_new (calitem, - index / EA_CALENDAR_COLUMN_NUM, - index % EA_CALENDAR_COLUMN_NUM); - ea_cell_table_set_cell_at_index (cell_data, index, cell); - g_object_unref (cell); - } - -#ifdef ACC_DEBUG - g_print ("AccDebug: ea_calendar_item children[%d]=%p\n", index, - (gpointer)cell); -#endif - return g_object_ref (atk_gobject_accessible_for_object (G_OBJECT(cell))); -} - -/* atk table interface */ - -static void -atk_table_interface_init (AtkTableIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->ref_at = table_interface_ref_at; - - iface->get_n_rows = table_interface_get_n_rows; - iface->get_n_columns = table_interface_get_n_columns; - iface->get_index_at = table_interface_get_index_at; - iface->get_column_at_index = table_interface_get_column_at_index; - iface->get_row_at_index = table_interface_get_row_at_index; - iface->get_column_extent_at = table_interface_get_column_extent_at; - iface->get_row_extent_at = table_interface_get_row_extent_at; - - iface->is_selected = table_interface_is_selected; - iface->get_selected_rows = table_interface_get_selected_rows; - iface->get_selected_columns = table_interface_get_selected_columns; - iface->is_row_selected = table_interface_is_row_selected; - iface->is_column_selected = table_interface_is_column_selected; - iface->add_row_selection = table_interface_add_row_selection; - iface->remove_row_selection = table_interface_remove_row_selection; - iface->add_column_selection = table_interface_add_column_selection; - iface->remove_column_selection = table_interface_remove_column_selection; - - iface->get_row_header = table_interface_get_row_header; - iface->get_column_header = table_interface_get_column_header; - iface->get_caption = table_interface_get_caption; - iface->get_summary = table_interface_get_summary; - iface->get_row_description = table_interface_get_row_description; - iface->get_column_description = table_interface_get_column_description; -} - -static AtkObject* -table_interface_ref_at (AtkTable *table, - gint row, - gint column) -{ - gint index; - - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (table); - index = EA_CALENDAR_COLUMN_NUM * row + column; - return ea_calendar_item_ref_child (ATK_OBJECT (ea_calitem), index); -} - -static gint -table_interface_get_n_rows (AtkTable *table) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (table); - gint n_children; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - n_children = ea_calendar_item_get_n_children (ATK_OBJECT (ea_calitem)); - return (n_children - 1) / EA_CALENDAR_COLUMN_NUM + 1; -} - -static gint -table_interface_get_n_columns (AtkTable *table) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - return EA_CALENDAR_COLUMN_NUM; -} - -static gint -table_interface_get_index_at (AtkTable *table, - gint row, - gint column) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - return row * EA_CALENDAR_COLUMN_NUM + column; -} - -static gint -table_interface_get_column_at_index (AtkTable *table, - gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (table); - gint n_children; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - n_children = ea_calendar_item_get_n_children (ATK_OBJECT (ea_calitem)); - if (index >= 0 && index < n_children) - return index % EA_CALENDAR_COLUMN_NUM; - return -1; -} - -static gint -table_interface_get_row_at_index (AtkTable *table, - gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (table); - gint n_children; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return -1; - - n_children = ea_calendar_item_get_n_children (ATK_OBJECT (ea_calitem)); - if (index >= 0 && index < n_children) - return index / EA_CALENDAR_COLUMN_NUM; - return -1; -} - -static gint -table_interface_get_column_extent_at (AtkTable *table, - gint row, - gint column) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - ECalendarItem *calitem; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - calitem = E_CALENDAR_ITEM (g_obj); - return calitem->cell_width; -} - -static gint -table_interface_get_row_extent_at (AtkTable *table, - gint row, gint column) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - ECalendarItem *calitem; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (table); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - calitem = E_CALENDAR_ITEM (g_obj); - return calitem->cell_height; -} - -/* any day in the row is selected, the row is selected */ -static gboolean -table_interface_is_row_selected (AtkTable *table, - gint row) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - gint n_rows; - ECalendarItem *calitem; - gint row_index_start, row_index_end; - gint sel_index_start, sel_index_end; - - GDate start_date, end_date; - - g_return_val_if_fail (EA_IS_CALENDAR_ITEM (table), FALSE); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (table); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - n_rows = table_interface_get_n_rows (table); - if (row < 0 || row >= n_rows) - return FALSE; - - row_index_start = row * EA_CALENDAR_COLUMN_NUM; - row_index_end = row_index_start + EA_CALENDAR_COLUMN_NUM - 1; - - calitem = E_CALENDAR_ITEM (g_obj); - if (!e_calendar_item_get_selection (calitem, &start_date, &end_date)) - return FALSE; - - e_calendar_item_get_offset_for_date (calitem, - g_date_get_year (&start_date), - g_date_get_month (&start_date), - g_date_get_day (&start_date), - &sel_index_start); - e_calendar_item_get_offset_for_date (calitem, - g_date_get_year (&end_date), - g_date_get_month (&end_date), - g_date_get_day (&end_date), - &sel_index_end); - - if ((sel_index_start < row_index_start && - sel_index_end >= row_index_start) || - (sel_index_start >= row_index_start && - sel_index_start <= row_index_end)) - return TRUE; - return FALSE; -} - -static gboolean -table_interface_is_selected (AtkTable *table, - gint row, - gint column) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - gint n_rows, n_columns; - ECalendarItem *calitem; - gint index; - gint sel_index_start, sel_index_end; - - GDate start_date, end_date; - - g_return_val_if_fail (EA_IS_CALENDAR_ITEM (table), FALSE); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (table); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - n_rows = table_interface_get_n_rows (table); - if (row < 0 || row >= n_rows) - return FALSE; - n_columns = table_interface_get_n_columns (table); - if (column < 0 || column >= n_columns) - return FALSE; - - index = table_interface_get_index_at (table, row, column); - - calitem = E_CALENDAR_ITEM (g_obj); - if (!e_calendar_item_get_selection (calitem, &start_date, &end_date)) - return FALSE; - - e_calendar_item_get_offset_for_date (calitem, - g_date_get_year (&start_date), - g_date_get_month (&start_date), - g_date_get_day (&start_date), - &sel_index_start); - e_calendar_item_get_offset_for_date (calitem, - g_date_get_year (&end_date), - g_date_get_month (&end_date), - g_date_get_day (&end_date), &sel_index_end); - - if (sel_index_start <= index && sel_index_end >= index) - return TRUE; - return FALSE; -} - -static gboolean -table_interface_is_column_selected (AtkTable *table, - gint column) -{ - return FALSE; -} - -static gint -table_interface_get_selected_rows (AtkTable *table, - gint **rows_selected) -{ - *rows_selected = NULL; - return -1; -} - -static gint -table_interface_get_selected_columns (AtkTable *table, - gint **columns_selected) -{ - *columns_selected = NULL; - return -1; -} - -static gboolean -table_interface_add_row_selection (AtkTable *table, - gint row) -{ - return FALSE; -} - -static gboolean -table_interface_remove_row_selection (AtkTable *table, - gint row) -{ - return FALSE; -} - -static gboolean -table_interface_add_column_selection (AtkTable *table, - gint column) -{ - return FALSE; -} - -static gboolean -table_interface_remove_column_selection (AtkTable *table, - gint column) -{ - /* FIXME: NOT IMPLEMENTED */ - return FALSE; -} - -static AtkObject* -table_interface_get_row_header (AtkTable *table, - gint row) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -static AtkObject* -table_interface_get_column_header (AtkTable *table, - gint in_col) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -static AtkObject* -table_interface_get_caption (AtkTable *table) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -static G_CONST_RETURN gchar* -table_interface_get_column_description (AtkTable *table, gint in_col) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (table); - const gchar *description = NULL; - EaCellTable *cell_data; - gint n_columns; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - n_columns = table_interface_get_n_columns (table); - if (in_col < 0 || in_col >= n_columns) - return NULL; - cell_data = ea_calendar_item_get_cell_data (ea_calitem); - if (!cell_data) - return NULL; - - description = ea_cell_table_get_column_label (cell_data, in_col); - if (!description) { - gchar buffer[128] = "column description"; - ea_calendar_item_get_column_label (ea_calitem, in_col, - buffer, sizeof (buffer)); - ea_cell_table_set_column_label (cell_data, in_col, buffer); - description = ea_cell_table_get_column_label (cell_data, - in_col); - } - return description; -} - -static G_CONST_RETURN gchar* -table_interface_get_row_description (AtkTable *table, gint row) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (table); - const gchar *description = NULL; - EaCellTable *cell_data; - gint n_rows; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - n_rows = table_interface_get_n_rows (table); - if (row < 0 || row >= n_rows) - return NULL; - cell_data = ea_calendar_item_get_cell_data (ea_calitem); - if (!cell_data) - return NULL; - - description = ea_cell_table_get_row_label (cell_data, row); - if (!description) { - gchar buffer[128] = "row description"; - ea_calendar_item_get_row_label (ea_calitem, row, - buffer, sizeof (buffer)); - ea_cell_table_set_row_label (cell_data, row, buffer); - description = ea_cell_table_get_row_label (cell_data, - row); - } - return description; -} - -static AtkObject* -table_interface_get_summary (AtkTable *table) -{ - /* FIXME: NOT IMPLEMENTED */ - return NULL; -} - -/* atkselection interface */ - -static void -atk_selection_interface_init (AtkSelectionIface *iface) -{ - g_return_if_fail (iface != NULL); - - iface->add_selection = selection_interface_add_selection; - iface->clear_selection = selection_interface_clear_selection; - iface->ref_selection = selection_interface_ref_selection; - iface->get_selection_count = selection_interface_get_selection_count; - iface->is_child_selected = selection_interface_is_child_selected; -} - -static gboolean -selection_interface_add_selection (AtkSelection *selection, gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - ECalendarItem *calitem; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (selection); - gint year, month, day; - GDate start_date, end_date; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - calitem = E_CALENDAR_ITEM (g_obj); - if (!e_calendar_item_get_date_for_offset (calitem, index, - &year, &month, &day)) - return FALSE; - - /* FIXME: not support mulit-selection */ - g_date_set_dmy (&start_date, day, month + 1, year); - end_date = start_date; - e_calendar_item_set_selection (calitem, &start_date, &end_date); - return TRUE; -} - -static gboolean -selection_interface_clear_selection (AtkSelection *selection) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - ECalendarItem *calitem; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (selection); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - calitem = E_CALENDAR_ITEM (g_obj); - e_calendar_item_set_selection (calitem, NULL, NULL); - - return TRUE; -} - -static AtkObject* -selection_interface_ref_selection (AtkSelection *selection, gint i) -{ - GObject *g_obj; - ECalendarItem *calitem; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (selection); - gint count, sel_offset; - GDate start_date, end_date; - - count = selection_interface_get_selection_count (selection); - if (i < 0 || i >= count) - return NULL; - - g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (ea_calitem)); - - calitem = E_CALENDAR_ITEM (g_obj); - if (!e_calendar_item_get_selection (calitem, &start_date, &end_date)) - return NULL; - if (!e_calendar_item_get_offset_for_date (calitem, - g_date_get_year (&start_date), - g_date_get_month (&start_date) - 1, - g_date_get_day (&start_date), - &sel_offset)) - return NULL; - - return ea_calendar_item_ref_child (ATK_OBJECT (selection), sel_offset + i); -} - -static gint -selection_interface_get_selection_count (AtkSelection *selection) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - ECalendarItem *calitem; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (selection); - GDate start_date, end_date; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return 0; - - calitem = E_CALENDAR_ITEM (g_obj); - if (e_calendar_item_get_selection (calitem, &start_date, &end_date)) - return g_date_days_between (&start_date, &end_date) + 1; - else - return 0; -} - -static gboolean -selection_interface_is_child_selected (AtkSelection *selection, gint index) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaCalendarItem* ea_calitem = EA_CALENDAR_ITEM (selection); - gint row, column, n_children; - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - n_children = atk_object_get_n_accessible_children (ATK_OBJECT (selection)); - if (index < 0 || index >= n_children) - return FALSE; - - row = index / EA_CALENDAR_COLUMN_NUM; - column = index % EA_CALENDAR_COLUMN_NUM; - - return table_interface_is_selected (ATK_TABLE (selection), row, column); -} - -/* callbacks */ - -static void -selection_preview_change_cb (ECalendarItem *calitem) -{ - AtkObject *atk_obj; - AtkObject *item_cell; - - g_return_if_fail (E_IS_CALENDAR_ITEM (calitem)); - atk_obj = atk_gobject_accessible_for_object (G_OBJECT (calitem)); - ea_calendar_item_destory_cell_data (EA_CALENDAR_ITEM (atk_obj)); - - /* only deal with the first selected child, for now */ - item_cell = atk_selection_ref_selection (ATK_SELECTION (atk_obj), - 0); - - if (item_cell) - ea_calendar_set_focus_object (EA_CALENDAR_ITEM (atk_obj), item_cell); - - g_signal_emit_by_name (atk_obj, - "active-descendant-changed", - item_cell); - g_signal_emit_by_name (atk_obj, "selection_changed"); -} - -static void -date_range_changed_cb (ECalendarItem *calitem) -{ - AtkObject *atk_obj; - AtkObject *item_cell; - - g_return_if_fail (E_IS_CALENDAR_ITEM (calitem)); - atk_obj = atk_gobject_accessible_for_object (G_OBJECT (calitem)); - ea_calendar_item_destory_cell_data (EA_CALENDAR_ITEM (atk_obj)); - - item_cell = atk_selection_ref_selection (ATK_SELECTION (atk_obj), - 0); - if (item_cell) - ea_calendar_set_focus_object (EA_CALENDAR_ITEM (atk_obj), item_cell); - - g_signal_emit_by_name (atk_obj, "model_changed"); -} - -/* helpers */ - -static EaCellTable * -ea_calendar_item_get_cell_data (EaCalendarItem *ea_calitem) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - EaCellTable *cell_data; - - g_return_val_if_fail (ea_calitem, NULL); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return NULL; - - cell_data = g_object_get_data (G_OBJECT(ea_calitem), - "ea-calendar-cell-table"); - - if (!cell_data) { - gint n_cells = ea_calendar_item_get_n_children (ATK_OBJECT(ea_calitem)); - cell_data = ea_cell_table_create (n_cells/EA_CALENDAR_COLUMN_NUM, - EA_CALENDAR_COLUMN_NUM, - FALSE); - g_object_set_data (G_OBJECT(ea_calitem), - "ea-calendar-cell-table", cell_data); - } - return cell_data; -} - -static void -ea_calendar_item_destory_cell_data (EaCalendarItem *ea_calitem) -{ - EaCellTable *cell_data; - - g_return_if_fail (ea_calitem); - - cell_data = g_object_get_data (G_OBJECT(ea_calitem), - "ea-calendar-cell-table"); - if (cell_data) { - g_object_set_data (G_OBJECT(ea_calitem), - "ea-calendar-cell-table", NULL); - ea_cell_table_destroy (cell_data); - } -} - -static gboolean -ea_calendar_item_get_row_label (EaCalendarItem *ea_calitem, gint row, - gchar *buffer, gint buffer_size) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - ECalendarItem *calitem; - gint index, week_num; - gint year, month, day; - - g_return_val_if_fail (ea_calitem, FALSE); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - calitem = E_CALENDAR_ITEM (g_obj); - - index = atk_table_get_index_at (ATK_TABLE (ea_calitem), row, 0); - if (!e_calendar_item_get_date_for_offset (calitem, index, - &year, &month, &day)) - return FALSE; - - week_num = e_calendar_item_get_week_number (calitem, - day, month, year); - - g_snprintf (buffer, buffer_size, "week number : %d", week_num); - return TRUE; -} - -static gboolean -ea_calendar_item_get_column_label (EaCalendarItem *ea_calitem, gint column, - gchar *buffer, gint buffer_size) -{ - AtkGObjectAccessible *atk_gobj; - GObject *g_obj; - ECalendarItem *calitem; - const gchar *abbr_name; - - g_return_val_if_fail (ea_calitem, FALSE); - - atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_calitem); - g_obj = atk_gobject_accessible_get_object (atk_gobj); - if (!g_obj) - return FALSE; - - /* Columns are 0 = Monday ... 6 = Sunday */ - calitem = E_CALENDAR_ITEM (g_obj); - abbr_name = e_get_weekday_name (column + 1, TRUE); - g_strlcpy (buffer, abbr_name, buffer_size); - - return TRUE; -} - -/* the coordinate the e-calendar canvas coord */ -gboolean -e_calendar_item_get_day_extents (ECalendarItem *calitem, - gint year, gint month, gint date, - gint *x, gint *y, - gint *width, gint *height) -{ - GnomeCanvasItem *item; - GtkWidget *widget; - GtkStyle *style; - PangoFontDescription *font_desc; - PangoContext *pango_context; - PangoFontMetrics *font_metrics; - gint char_height, xthickness, ythickness, text_y; - gint new_year, new_month, num_months, months_offset; - gint month_x, month_y, month_cell_x, month_cell_y; - gint month_row, month_col; - gint day_row, day_col; - gint days_from_week_start; - - g_return_val_if_fail (E_IS_CALENDAR_ITEM (calitem), FALSE); - - item = GNOME_CANVAS_ITEM (calitem); - widget = GTK_WIDGET (item->canvas); - style = widget->style; - - /* Set up Pango prerequisites */ - font_desc = calitem->font_desc; - if (!font_desc) - font_desc = style->font_desc; - pango_context = gtk_widget_get_pango_context (widget); - font_metrics = pango_context_get_metrics (pango_context, font_desc, - pango_context_get_language (pango_context)); - - char_height = - PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + - PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)); - - xthickness = style->xthickness; - ythickness = style->ythickness; - - new_year = year; - new_month = month; - e_calendar_item_normalize_date (calitem, &new_year, &new_month); - num_months = calitem->rows * calitem->cols; - months_offset = (new_year - calitem->year) * 12 - + new_month - calitem->month; - - if (months_offset > num_months || months_offset < 0) - return FALSE; - - month_row = months_offset / calitem->cols; - month_col = months_offset % calitem->cols; - - month_x = item->x1 + xthickness + calitem->x_offset - + month_col * calitem->month_width; - month_y = item->y1 + ythickness + month_row * calitem->month_height; - - month_cell_x = month_x + E_CALENDAR_ITEM_XPAD_BEFORE_WEEK_NUMBERS - + calitem->month_lpad + E_CALENDAR_ITEM_XPAD_BEFORE_CELLS; - text_y = month_y + ythickness * 2 - + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME - + char_height + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME - + E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS + calitem->month_tpad; - - month_cell_y = text_y + char_height - + E_CALENDAR_ITEM_YPAD_BELOW_DAY_LETTERS + 1 - + E_CALENDAR_ITEM_YPAD_ABOVE_CELLS; - - days_from_week_start = - e_calendar_item_get_n_days_from_week_start (calitem, new_year, - new_month); - day_row = (date + days_from_week_start - 1) / EA_CALENDAR_COLUMN_NUM; - day_col = (date + days_from_week_start - 1) % EA_CALENDAR_COLUMN_NUM; - - *x = month_cell_x + day_col * calitem->cell_width; - *y = month_cell_y + day_row * calitem->cell_height; - *width = calitem->cell_width; - *height = calitem->cell_height; - - return TRUE; -} - -/* month is from 0 to 11 */ -gboolean -e_calendar_item_get_date_for_offset (ECalendarItem *calitem, gint day_offset, - gint *year, gint *month, gint *day) -{ - gint start_year, start_month, start_day; - gint end_year, end_month, end_day; - GDate *start_date; - - g_return_val_if_fail (E_IS_CALENDAR_ITEM (calitem), FALSE); - - if (!e_calendar_item_get_date_range (calitem, &start_year, - &start_month, &start_day, - &end_year, &end_month, - &end_day)) - return FALSE; - - start_date = g_date_new_dmy (start_day, start_month + 1, start_year); - - g_date_add_days (start_date, day_offset); - - *year = g_date_get_year (start_date); - *month = g_date_get_month (start_date) - 1; - *day = g_date_get_day (start_date); - - return TRUE; -} - -/* the arg month is from 0 to 11 */ -static gboolean -e_calendar_item_get_offset_for_date (ECalendarItem *calitem, - gint year, gint month, gint day, - gint *offset) -{ - gint start_year, start_month, start_day; - gint end_year, end_month, end_day; - GDate *start_date, *end_date; - - *offset = 0; - g_return_val_if_fail (E_IS_CALENDAR_ITEM (calitem), FALSE); - - if (!e_calendar_item_get_date_range (calitem, &start_year, - &start_month, &start_day, - &end_year, &end_month, - &end_day)) - return FALSE; - - start_date = g_date_new_dmy (start_day, start_month + 1, start_year); - end_date = g_date_new_dmy (day, month + 1, year); - - *offset = g_date_days_between (start_date, end_date); - g_free (start_date); - g_free (end_date); - - return TRUE; -} - -gint -e_calendar_item_get_n_days_from_week_start (ECalendarItem *calitem, - gint year, gint month) -{ - struct tm tmp_tm; - gint start_weekday, days_from_week_start; - - memset (&tmp_tm, 0, sizeof (tmp_tm)); - tmp_tm.tm_year = year - 1900; - tmp_tm.tm_mon = month; - tmp_tm.tm_mday = 1; - tmp_tm.tm_isdst = -1; - mktime (&tmp_tm); - start_weekday = (tmp_tm.tm_wday + 6) % 7; /* 0 to 6 */ - days_from_week_start = (start_weekday + 7 - calitem->week_start_day) - % 7; - return days_from_week_start; -} - -static void -ea_calendar_set_focus_object (EaCalendarItem *ea_calitem, AtkObject *item_cell) -{ - AtkStateSet *state_set, *old_state_set; - AtkObject *old_cell; - - old_cell = (AtkObject *)g_object_get_data (G_OBJECT(ea_calitem), "gail-focus-object"); - if (old_cell && EA_IS_CALENDAR_CELL (old_cell)) { - old_state_set = atk_object_ref_state_set (old_cell); - atk_state_set_remove_state (old_state_set, ATK_STATE_FOCUSED); - g_object_unref (old_state_set); - } - if (old_cell) - g_object_unref (old_cell); - - state_set = atk_object_ref_state_set (item_cell); - atk_state_set_add_state (state_set, ATK_STATE_FOCUSED); - g_object_set_data (G_OBJECT(ea_calitem), "gail-focus-object", item_cell); - g_object_unref (state_set); -} diff --git a/a11y/widgets/ea-calendar-item.h b/a11y/widgets/ea-calendar-item.h deleted file mode 100644 index 87b825b479..0000000000 --- a/a11y/widgets/ea-calendar-item.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_CALENDAR_ITEM_H__ -#define __EA_CALENDAR_ITEM_H__ - -#include <atk/atkgobjectaccessible.h> -#include <misc/e-calendar-item.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define EA_TYPE_CALENDAR_ITEM (ea_calendar_item_get_type ()) -#define EA_CALENDAR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_CALENDAR_ITEM, EaCalendarItem)) -#define EA_CALENDAR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_CALENDAR_ITEM, EaCalendarItemClass)) -#define EA_IS_CALENDAR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_CALENDAR_ITEM)) -#define EA_IS_CALENDAR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_CALENDAR_ITEM)) -#define EA_CALENDAR_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_CALENDAR_ITEM, EaCalendarItemClass)) - -typedef struct _EaCalendarItem EaCalendarItem; -typedef struct _EaCalendarItemClass EaCalendarItemClass; - -struct _EaCalendarItem -{ - AtkGObjectAccessible parent; -}; - -GType ea_calendar_item_get_type (void); - -struct _EaCalendarItemClass -{ - AtkGObjectAccessibleClass parent_class; -}; - -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_n_days_from_week_start (ECalendarItem *calitem, - gint year, gint month); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __EA_CALENDAR_ITEM_H__ */ diff --git a/a11y/widgets/ea-widgets.c b/a11y/widgets/ea-widgets.c deleted file mode 100644 index e9e170a8d3..0000000000 --- a/a11y/widgets/ea-widgets.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "ea-factory.h" -#include "widgets/ea-calendar-item.h" -#include "ea-widgets.h" - -EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new) - -void e_calendar_item_a11y_init (void) -{ - EA_SET_FACTORY (e_calendar_item_get_type (), ea_calendar_item); -} diff --git a/a11y/widgets/ea-widgets.h b/a11y/widgets/ea-widgets.h deleted file mode 100644 index d19c908293..0000000000 --- a/a11y/widgets/ea-widgets.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -/* Evolution Accessibility -*/ - -#ifndef _EA_WIDGETS_H__ -#define _EA_WIDGETS_H__ - -void e_calendar_item_a11y_init (void); - -#endif /* _EA_WIDGETS_H__ */ |