1 /*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU Lesser General Public License as published by
4 * the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful, but
7 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9 * for more details.
10 *
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, see <http://www.gnu.org/licenses/>.
13 *
14 *
15 * Authors:
16 * Leon Zhang <leon.zhang@sun.com>
17 *
18 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
19 *
20 */
21
22 #include "evolution-config.h"
23
24 #include "e-util/e-util.h"
25
26 #include "ea-addressbook.h"
27 #include "ea-minicard.h"
28 #include "ea-minicard-view.h"
29 #include "ea-addressbook-view.h"
30
31 EA_FACTORY_GOBJECT (EA_TYPE_MINICARD, ea_minicard, ea_minicard_new)
32 EA_FACTORY_GOBJECT (EA_TYPE_MINICARD_VIEW, ea_minicard_view, ea_minicard_view_new)
33 EA_FACTORY_GOBJECT (EA_TYPE_AB_VIEW, ea_ab_view, ea_ab_view_new)
34
35 static gboolean ea_addressbook_focus_watcher (GSignalInvocationHint *ihint,
36 guint n_param_values,
37 const GValue *param_values,
38 gpointer data);
39
e_minicard_a11y_init(void)40 void e_minicard_a11y_init (void)
41 {
42 EA_SET_FACTORY (e_minicard_get_type (), ea_minicard);
43 }
44
e_minicard_view_a11y_init(void)45 void e_minicard_view_a11y_init (void)
46 {
47 EA_SET_FACTORY (e_minicard_view_get_type (), ea_minicard_view);
48
49 if (atk_get_root ()) {
50 g_signal_add_emission_hook (
51 g_signal_lookup ("event",
52 e_minicard_get_type ()),
53 0, ea_addressbook_focus_watcher,
54 NULL, (GDestroyNotify) NULL);
55 }
56 }
57
eab_view_a11y_init(void)58 void eab_view_a11y_init (void)
59 {
60 EA_SET_FACTORY (E_TYPE_ADDRESSBOOK_VIEW, ea_ab_view);
61 }
62
63 static gboolean
ea_addressbook_focus_watcher(GSignalInvocationHint * ihint,guint n_param_values,const GValue * param_values,gpointer data)64 ea_addressbook_focus_watcher (GSignalInvocationHint *ihint,
65 guint n_param_values,
66 const GValue *param_values,
67 gpointer data)
68 {
69 GObject *object;
70 GdkEvent *event;
71 AtkObject *ea_event = NULL;
72
73 object = g_value_get_object (param_values + 0);
74 event = g_value_get_boxed (param_values + 1);
75
76 if (E_IS_MINICARD (object)) {
77 GnomeCanvasItem *item = GNOME_CANVAS_ITEM (object);
78 ea_event = atk_gobject_accessible_for_object (object);
79 if (event->type == GDK_FOCUS_CHANGE) {
80 if (E_IS_MINICARD (item->canvas->focused_item))
81 atk_object_notify_state_change (ea_event,
82 ATK_STATE_FOCUSED,
83 event->focus_change.in);
84 }
85 }
86
87 return TRUE;
88 }
89