1 /*
2  * Copyright 2008 Codethink Ltd.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 /* This file contains both declaration and definition of the MyAtkTable,
21  * a GObject that pretends to implement the AtkTableIface interface (it
22  * registers appropriate interface), but provides no implementation for any of the
23  * methods of this interface (NULL-filled vftbl).
24  */
25 
26 #include <glib-object.h>
27 #include <atk/atk.h>
28 
29 #include "my-atk-object.h"
30 #include "my-atk-table.h"
31 
32 ///////////////////////////////////////////////////////////////////////////
33 // Helper functions and data
34 ///////////////////////////////////////////////////////////////////////////
35 void
my_atk_table_select_rows(MyAtkTable * table,gboolean sel_scheme[])36 my_atk_table_select_rows (MyAtkTable* table, gboolean sel_scheme[])
37 {
38     // the function does nothing
39 }
40 
41 void
my_atk_table_select_columns(MyAtkTable * table,gboolean sel_scheme[])42 my_atk_table_select_columns (MyAtkTable* table, gboolean sel_scheme[])
43 {
44     // the function does nothing
45 }
46 
47 ///////////////////////////////////////////////////////////////////////////
48 // Implementation
49 ///////////////////////////////////////////////////////////////////////////
50 static GObjectClass *parent_class_table = NULL;
51 
52 /******************************************************************/
53 static void
table_interface_init(gpointer g_iface,gpointer iface_data)54 table_interface_init (gpointer g_iface, gpointer iface_data)
55 {
56     AtkTableIface *klass = (AtkTableIface *)g_iface;
57 
58     /* set up overrides here */
59     klass-> ref_at =
60         (AtkObject* (*) (AtkTable *table, gint row, gint column)) NULL;
61     klass-> get_index_at =
62         (gint (*) (AtkTable *table, gint row, gint column)) NULL;
63     klass-> get_column_at_index =
64         (gint (*) (AtkTable *table, gint index_)) NULL;
65     klass-> get_row_at_index =
66         (gint (*) (AtkTable *table, gint index_)) NULL;
67     klass-> get_n_columns =
68         (gint (*) (AtkTable *table)) NULL;
69     klass-> get_n_rows =
70         (gint (*) (AtkTable *table)) NULL;
71     klass-> get_column_extent_at =
72         (gint (*) (AtkTable *table, gint row, gint column)) NULL;
73     klass-> get_row_extent_at =
74         (gint (*) (AtkTable *table, gint row, gint column)) NULL;
75     klass-> get_caption =
76         (AtkObject* (*) (AtkTable *table)) NULL;
77     klass-> get_column_description =
78         (const gchar* (*) (AtkTable *table, gint column)) NULL;
79     klass-> get_column_header =
80         (AtkObject* (*) (AtkTable *table, gint column)) NULL;
81     klass-> get_row_description =
82         (const gchar* (*) (AtkTable *table, gint row)) NULL;
83     klass-> get_row_header =
84         (AtkObject* (*) (AtkTable *table, gint row)) NULL;
85     klass-> get_summary =
86         (AtkObject* (*) (AtkTable *table)) NULL;
87     klass-> set_caption =
88         (void (*) (AtkTable *table, AtkObject *caption)) NULL;
89     klass-> set_column_description =
90         (void (*) (AtkTable *table, gint column, const gchar *description)) NULL;
91     klass-> set_column_header =
92         (void (*) (AtkTable *table, gint column, AtkObject *header)) NULL;
93     klass-> set_row_description =
94         (void (*) (AtkTable *table, gint row, const gchar *description)) NULL;
95     klass-> set_row_header =
96         (void (*) (AtkTable *table, gint row, AtkObject *header)) NULL;
97     klass-> set_summary =
98         (void (*) (AtkTable *table, AtkObject *accessible)) NULL;
99     klass-> get_selected_columns =
100         (gint (*) (AtkTable *table, gint **selected)) NULL;
101     klass-> get_selected_rows =
102         (gint (*) (AtkTable *table, gint **selected)) NULL;
103     klass-> is_column_selected =
104         (gboolean (*) (AtkTable *table, gint column)) NULL;
105     klass-> is_row_selected =
106         (gboolean (*) (AtkTable *table, gint row)) NULL;
107     klass-> is_selected =
108         (gboolean (*) (AtkTable *table, gint row, gint column)) NULL;
109     klass-> add_row_selection =
110         (gboolean (*) (AtkTable *table, gint row)) NULL;
111     klass-> remove_row_selection =
112         (gboolean (*) (AtkTable *table, gint row)) NULL;
113     klass-> add_column_selection =
114         (gboolean (*) (AtkTable *table, gint column)) NULL;
115     klass-> remove_column_selection =
116         (gboolean (*) (AtkTable *table, gint column)) NULL;
117 }
118 
119 static void
table_instance_init(GTypeInstance * instance,gpointer g_class)120 table_instance_init (GTypeInstance *instance, gpointer g_class)
121 {
122     MyAtkTable *self = (MyAtkTable *)instance;
123 
124     self->disposed = FALSE;
125 }
126 
127 static void
my_atk_table_dispose(GObject * obj)128 my_atk_table_dispose (GObject *obj)
129 {
130     MyAtkTable *self = (MyAtkTable *)obj;
131 
132     if (self->disposed)
133     {
134         return;
135     }
136 
137     /* Make sure dispose does not run twice. */
138     self->disposed = TRUE;
139 
140     /* Chain up to the parent class */
141     G_OBJECT_CLASS (parent_class_table)->dispose (obj);
142 }
143 
144 static void
my_atk_table_finalize(GObject * obj)145 my_atk_table_finalize (GObject *obj)
146 {
147     /* Chain up to the parent class */
148     G_OBJECT_CLASS (parent_class_table)->finalize (obj);
149 }
150 
151 static void
my_atk_table_class_init(gpointer g_class,gpointer g_class_data)152 my_atk_table_class_init (gpointer g_class, gpointer g_class_data)
153 {
154     GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
155     MyAtkTableClass *klass = MY_ATK_TABLE_CLASS (g_class);
156 
157     gobject_class->dispose = my_atk_table_dispose;
158     gobject_class->finalize = my_atk_table_finalize;
159 
160     parent_class_table = g_type_class_peek_parent (klass);
161 }
162 
163 GType
my_atk_table_get_type(void)164 my_atk_table_get_type (void)
165 {
166     static GType type = 0;
167     if (type == 0)
168     {
169         static const GTypeInfo info =
170         {
171             sizeof (MyAtkTableClass),
172             NULL,   /* base_init */
173             NULL,   /* base_finalize */
174             my_atk_table_class_init, /* class_init */
175             NULL,   /* class_finalize */
176             NULL,   /* class_data */
177             sizeof (MyAtkTable),
178             0,      /* n_preallocs */
179             table_instance_init    /* instance_init */
180         };
181 
182         static const GInterfaceInfo iface_info =
183         {
184             (GInterfaceInitFunc) table_interface_init,    /* interface_init */
185             NULL,                                       /* interface_finalize */
186             NULL                                        /* interface_data */
187         };
188         type = g_type_register_static (MY_TYPE_ATK_OBJECT,
189                                        "MyAtkTableType",
190                                        &info, 0);
191         g_type_add_interface_static (type,
192                                      ATK_TYPE_TABLE,
193                                      &iface_info);
194     }
195     return type;
196 }
197