From f0d3f3afdfa314e1e8cd7d8da790878008a46aad Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 24 Jun 2009 12:59:33 -0400 Subject: Radically reorganize source code. - Collect all shell modules into a new top-level 'modules' directory: $(top_srcdir)/modules/addressbook $(top_srcdir)/modules/calendar $(top_srcdir)/modules/mail Nothing is allowed to link to these, not plugins nor other modules. THIS SOLVES BUG #571275 AND OPENS THE DOOR TO PORTING TO MAC OS X. - Mimic the libevolution-mail-shared library from master (except drop the "shared" suffix) and have libevolution-mail-importers and all mail-related plugins link to it. - Discard the a11y subdirectories and have the files live alongside their counterpart widgets. --- addressbook/gui/widgets/Makefile.am | 16 +- addressbook/gui/widgets/a11y/ea-addressbook-view.c | 123 ------ addressbook/gui/widgets/a11y/ea-addressbook-view.h | 57 --- addressbook/gui/widgets/a11y/ea-addressbook.c | 84 ----- addressbook/gui/widgets/a11y/ea-addressbook.h | 33 -- addressbook/gui/widgets/a11y/ea-minicard-view.c | 413 --------------------- addressbook/gui/widgets/a11y/ea-minicard-view.h | 59 --- addressbook/gui/widgets/a11y/ea-minicard.c | 273 -------------- addressbook/gui/widgets/a11y/ea-minicard.h | 58 --- addressbook/gui/widgets/e-addressbook-view.c | 2 +- addressbook/gui/widgets/e-minicard-view.c | 2 +- addressbook/gui/widgets/e-minicard.c | 2 +- addressbook/gui/widgets/ea-addressbook-view.c | 123 ++++++ addressbook/gui/widgets/ea-addressbook-view.h | 57 +++ addressbook/gui/widgets/ea-addressbook.c | 84 +++++ addressbook/gui/widgets/ea-addressbook.h | 33 ++ addressbook/gui/widgets/ea-minicard-view.c | 413 +++++++++++++++++++++ addressbook/gui/widgets/ea-minicard-view.h | 59 +++ addressbook/gui/widgets/ea-minicard.c | 273 ++++++++++++++ addressbook/gui/widgets/ea-minicard.h | 58 +++ 20 files changed, 1111 insertions(+), 1111 deletions(-) delete mode 100644 addressbook/gui/widgets/a11y/ea-addressbook-view.c delete mode 100644 addressbook/gui/widgets/a11y/ea-addressbook-view.h delete mode 100644 addressbook/gui/widgets/a11y/ea-addressbook.c delete mode 100644 addressbook/gui/widgets/a11y/ea-addressbook.h delete mode 100644 addressbook/gui/widgets/a11y/ea-minicard-view.c delete mode 100644 addressbook/gui/widgets/a11y/ea-minicard-view.h delete mode 100644 addressbook/gui/widgets/a11y/ea-minicard.c delete mode 100644 addressbook/gui/widgets/a11y/ea-minicard.h create mode 100644 addressbook/gui/widgets/ea-addressbook-view.c create mode 100644 addressbook/gui/widgets/ea-addressbook-view.h create mode 100644 addressbook/gui/widgets/ea-addressbook.c create mode 100644 addressbook/gui/widgets/ea-addressbook.h create mode 100644 addressbook/gui/widgets/ea-minicard-view.c create mode 100644 addressbook/gui/widgets/ea-minicard-view.h create mode 100644 addressbook/gui/widgets/ea-minicard.c create mode 100644 addressbook/gui/widgets/ea-minicard.h (limited to 'addressbook/gui/widgets') diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am index 45c0b0cba3..e940065833 100644 --- a/addressbook/gui/widgets/Makefile.am +++ b/addressbook/gui/widgets/Makefile.am @@ -52,14 +52,14 @@ libeabwidgets_la_SOURCES = \ gal-view-minicard.h \ gal-view-factory-minicard.c \ gal-view-factory-minicard.h \ - a11y/ea-minicard.c \ - a11y/ea-minicard.h \ - a11y/ea-minicard-view.c \ - a11y/ea-minicard-view.h \ - a11y/ea-addressbook-view.c \ - a11y/ea-addressbook-view.h \ - a11y/ea-addressbook.c \ - a11y/ea-addressbook.h + 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 libeabwidgets_la_LIBADD = \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ diff --git a/addressbook/gui/widgets/a11y/ea-addressbook-view.c b/addressbook/gui/widgets/a11y/ea-addressbook-view.c deleted file mode 100644 index b2d7ebb171..0000000000 --- a/addressbook/gui/widgets/a11y/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 - * - * - * Authors: - * Leon Zhang - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include - -#include -#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/addressbook/gui/widgets/a11y/ea-addressbook-view.h b/addressbook/gui/widgets/a11y/ea-addressbook-view.h deleted file mode 100644 index 4607746337..0000000000 --- a/addressbook/gui/widgets/a11y/ea-addressbook-view.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 - * - * - * Authors: - * Leon Zhang - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_ADDRESSBOOK_VIEW_H__ -#define __EA_ADDRESSBOOK_VIEW_H__ - -#include -#include "e-addressbook-view.h" - -G_BEGIN_DECLS - -#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); - -G_END_DECLS - - -#endif /* __EA_ADDRESSBOOK_VIEW_H__ */ diff --git a/addressbook/gui/widgets/a11y/ea-addressbook.c b/addressbook/gui/widgets/a11y/ea-addressbook.c deleted file mode 100644 index 14fc4c1ca3..0000000000 --- a/addressbook/gui/widgets/a11y/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 - * - * - * Authors: - * Leon Zhang - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include -#include "a11y/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/addressbook/gui/widgets/a11y/ea-addressbook.h b/addressbook/gui/widgets/a11y/ea-addressbook.h deleted file mode 100644 index 97b691dc18..0000000000 --- a/addressbook/gui/widgets/a11y/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 - * - * - * Authors: - * Leon Zhang - * - * 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/addressbook/gui/widgets/a11y/ea-minicard-view.c b/addressbook/gui/widgets/a11y/ea-minicard-view.c deleted file mode 100644 index b35f64ae5e..0000000000 --- a/addressbook/gui/widgets/a11y/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 - * - * - * Authors: - * Leon Zhang < leon.zhang@sun.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include -#include -#include -#include -#include "ea-minicard.h" -#include "ea-minicard-view.h" -#include "eab-gui-util.h" -#include "e-addressbook-view.h" - -static const gchar * 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/addressbook/gui/widgets/a11y/ea-minicard-view.h b/addressbook/gui/widgets/a11y/ea-minicard-view.h deleted file mode 100644 index c564dac8c8..0000000000 --- a/addressbook/gui/widgets/a11y/ea-minicard-view.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 - * - * - * Authors: - * Leon Zhang - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_MINICARD_VIEW_H__ -#define __EA_MINICARD_VIEW_H__ - -#include -#include "e-minicard-view.h" - -G_BEGIN_DECLS - -#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); - -G_END_DECLS - - -#endif /* __EA_MINICARD_VIEW_H__ */ diff --git a/addressbook/gui/widgets/a11y/ea-minicard.c b/addressbook/gui/widgets/a11y/ea-minicard.c deleted file mode 100644 index b1b1ebbe33..0000000000 --- a/addressbook/gui/widgets/a11y/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 - * - * - * Authors: - * Leon Zhang - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include -#include -#include -#include "ea-minicard.h" -#include "ea-minicard-view.h" -#include "e-minicard.h" - -static const gchar * 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/addressbook/gui/widgets/a11y/ea-minicard.h b/addressbook/gui/widgets/a11y/ea-minicard.h deleted file mode 100644 index 879463b629..0000000000 --- a/addressbook/gui/widgets/a11y/ea-minicard.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 - * - * - * Authors: - * Leon Zhang - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EA_MINICARD_H__ -#define __EA_MINICARD_H__ - -#include -#include "e-minicard.h" -#include "e-minicard-label.h" - -G_BEGIN_DECLS - -#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); - -G_END_DECLS - - -#endif /* __EA_MINICARD_H__ */ diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 5df049dbe6..ae79ead397 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -33,7 +33,7 @@ #include #include "addressbook/printing/e-contact-print.h" -#include "a11y/ea-addressbook.h" +#include "ea-addressbook.h" #include "e-util/e-print.h" #include "e-util/e-util.h" diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c index ece8d84654..6ee55f8b9f 100644 --- a/addressbook/gui/widgets/e-minicard-view.c +++ b/addressbook/gui/widgets/e-minicard-view.c @@ -34,7 +34,7 @@ #include #include #include "e-util/e-util.h" -#include "a11y/ea-addressbook.h" +#include "ea-addressbook.h" static void e_minicard_view_drag_data_get(GtkWidget *widget, GdkDragContext *context, diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index 2d9deeecbc..a8b6554888 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -38,7 +38,7 @@ #include #include #include -#include "a11y/ea-addressbook.h" +#include "ea-addressbook.h" static void e_minicard_init (EMinicard *card); static void e_minicard_class_init (EMinicardClass *class); diff --git a/addressbook/gui/widgets/ea-addressbook-view.c b/addressbook/gui/widgets/ea-addressbook-view.c new file mode 100644 index 0000000000..b2d7ebb171 --- /dev/null +++ b/addressbook/gui/widgets/ea-addressbook-view.c @@ -0,0 +1,123 @@ +/* + * 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 + * + * + * Authors: + * Leon Zhang + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include + +#include +#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/addressbook/gui/widgets/ea-addressbook-view.h b/addressbook/gui/widgets/ea-addressbook-view.h new file mode 100644 index 0000000000..4607746337 --- /dev/null +++ b/addressbook/gui/widgets/ea-addressbook-view.h @@ -0,0 +1,57 @@ +/* + * 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 + * + * + * Authors: + * Leon Zhang + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef __EA_ADDRESSBOOK_VIEW_H__ +#define __EA_ADDRESSBOOK_VIEW_H__ + +#include +#include "e-addressbook-view.h" + +G_BEGIN_DECLS + +#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); + +G_END_DECLS + + +#endif /* __EA_ADDRESSBOOK_VIEW_H__ */ diff --git a/addressbook/gui/widgets/ea-addressbook.c b/addressbook/gui/widgets/ea-addressbook.c new file mode 100644 index 0000000000..14fc4c1ca3 --- /dev/null +++ b/addressbook/gui/widgets/ea-addressbook.c @@ -0,0 +1,84 @@ +/* + * 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 + * + * + * Authors: + * Leon Zhang + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include +#include "a11y/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/addressbook/gui/widgets/ea-addressbook.h b/addressbook/gui/widgets/ea-addressbook.h new file mode 100644 index 0000000000..97b691dc18 --- /dev/null +++ b/addressbook/gui/widgets/ea-addressbook.h @@ -0,0 +1,33 @@ +/* + * 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 + * + * + * Authors: + * Leon Zhang + * + * 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/addressbook/gui/widgets/ea-minicard-view.c b/addressbook/gui/widgets/ea-minicard-view.c new file mode 100644 index 0000000000..b35f64ae5e --- /dev/null +++ b/addressbook/gui/widgets/ea-minicard-view.c @@ -0,0 +1,413 @@ +/* + * 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 + * + * + * Authors: + * Leon Zhang < leon.zhang@sun.com> + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include +#include +#include +#include +#include "ea-minicard.h" +#include "ea-minicard-view.h" +#include "eab-gui-util.h" +#include "e-addressbook-view.h" + +static const gchar * 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/addressbook/gui/widgets/ea-minicard-view.h b/addressbook/gui/widgets/ea-minicard-view.h new file mode 100644 index 0000000000..c564dac8c8 --- /dev/null +++ b/addressbook/gui/widgets/ea-minicard-view.h @@ -0,0 +1,59 @@ +/* + * 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 + * + * + * Authors: + * Leon Zhang + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef __EA_MINICARD_VIEW_H__ +#define __EA_MINICARD_VIEW_H__ + +#include +#include "e-minicard-view.h" + +G_BEGIN_DECLS + +#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); + +G_END_DECLS + + +#endif /* __EA_MINICARD_VIEW_H__ */ diff --git a/addressbook/gui/widgets/ea-minicard.c b/addressbook/gui/widgets/ea-minicard.c new file mode 100644 index 0000000000..b1b1ebbe33 --- /dev/null +++ b/addressbook/gui/widgets/ea-minicard.c @@ -0,0 +1,273 @@ +/* + * 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 + * + * + * Authors: + * Leon Zhang + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include +#include +#include +#include "ea-minicard.h" +#include "ea-minicard-view.h" +#include "e-minicard.h" + +static const gchar * 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/addressbook/gui/widgets/ea-minicard.h b/addressbook/gui/widgets/ea-minicard.h new file mode 100644 index 0000000000..879463b629 --- /dev/null +++ b/addressbook/gui/widgets/ea-minicard.h @@ -0,0 +1,58 @@ +/* + * 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 + * + * + * Authors: + * Leon Zhang + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef __EA_MINICARD_H__ +#define __EA_MINICARD_H__ + +#include +#include "e-minicard.h" +#include "e-minicard-label.h" + +G_BEGIN_DECLS + +#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); + +G_END_DECLS + + +#endif /* __EA_MINICARD_H__ */ -- cgit v1.2.3