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 <glib/gi18n.h>
25 #include "ea-addressbook-view.h"
26
27 static const gchar * ea_ab_view_get_name (AtkObject *accessible);
28 static const gchar * ea_ab_view_get_description (AtkObject *accessible);
29
30 static void ea_ab_view_class_init (EAddressbookViewClass *class);
31
32 GType
ea_ab_view_get_type(void)33 ea_ab_view_get_type (void)
34 {
35 static GType type = 0;
36 AtkObjectFactory *factory;
37 GTypeQuery query;
38 GType derived_atk_type;
39
40 if (!type) {
41 static GTypeInfo tinfo = {
42 sizeof (EAddressbookViewClass),
43 (GBaseInitFunc) NULL, /* base_init */
44 (GBaseFinalizeFunc) NULL, /* base_finalize */
45 (GClassInitFunc) ea_ab_view_class_init,
46 (GClassFinalizeFunc) NULL, /* class_finalize */
47 NULL, /* class_data */
48 sizeof (EAddressbookView),
49 0, /* n_preallocs */
50 (GInstanceInitFunc) NULL, /* instance init */
51 NULL /* value table */
52 };
53
54 /*
55 * Figure out the size of the class and instance
56 * we are run-time deriving from (GailWidget, in this case) */
57
58 factory = atk_registry_get_factory (
59 atk_get_default_registry (),
60 GTK_TYPE_EVENT_BOX);
61 derived_atk_type = atk_object_factory_get_accessible_type (factory);
62 g_type_query (derived_atk_type, &query);
63
64 tinfo.class_size = query.class_size;
65 tinfo.instance_size = query.instance_size;
66
67 type = g_type_register_static (
68 derived_atk_type,
69 "EaABView", &tinfo, 0);
70 }
71
72 return type;
73 }
74
75 static void
ea_ab_view_class_init(EAddressbookViewClass * class)76 ea_ab_view_class_init (EAddressbookViewClass *class)
77 {
78 AtkObjectClass *atk_object_class;
79
80 atk_object_class = ATK_OBJECT_CLASS (class);
81 atk_object_class->get_name = ea_ab_view_get_name;
82 atk_object_class->get_description = ea_ab_view_get_description;
83 }
84
85 static const gchar *
ea_ab_view_get_name(AtkObject * accessible)86 ea_ab_view_get_name (AtkObject *accessible)
87 {
88 g_return_val_if_fail (EA_IS_AB_VIEW (accessible), NULL);
89 if (accessible->name)
90 return accessible->name;
91
92 return _("evolution address book");
93 }
94
95 static const gchar *
ea_ab_view_get_description(AtkObject * accessible)96 ea_ab_view_get_description (AtkObject *accessible)
97 {
98 if (accessible->description)
99 return accessible->description;
100
101 return _("evolution address book");
102 }
103
104 AtkObject *
ea_ab_view_new(GObject * obj)105 ea_ab_view_new (GObject *obj)
106 {
107 GObject *object;
108 AtkObject *accessible;
109
110 g_return_val_if_fail (obj != NULL, NULL);
111 g_return_val_if_fail (E_IS_ADDRESSBOOK_VIEW (obj), NULL);
112
113 object = g_object_new (EA_TYPE_AB_VIEW, NULL);
114
115 accessible = ATK_OBJECT (object);
116 atk_object_initialize (accessible, obj);
117 accessible->role = ATK_ROLE_CANVAS;
118
119 return accessible;
120 }
121