3 #include "test-simple-table.h"
10 static AtkObject *root;
11 static GList *children;
13 gboolean quit(GIOChannel *source, GIOCondition condition, gpointer data)
15 //g_signal_emit_by_name(root, "children-changed::remove", child);
16 tcsetattr(0, TCSAFLUSH, data);
22 static AtkObjectClass *parent_class = NULL;
24 /**************************************************************************/
25 /**************************************************************************/
27 #define GET_CLASS(instance) G_TYPE_INSTANCE_GET_CLASS (instance, AP_DOCVIEW_TYPE, ApDocViewClass)
29 static gint test_hello_get_n_children(AtkObject * obj)
31 printf("get n children: %p\n", obj);
32 if (obj == root) return g_list_length(children);
36 static AtkStateSet *test_hello_ref_state_set(AtkObject * accessible)
38 AtkStateSet *state_set;
40 state_set = ATK_OBJECT_CLASS(parent_class)->ref_state_set(accessible);
41 //atk_state_set_remove_state(state_set, ATK_STATE_FOCUSABLE);
46 static void test_hello_real_initialize(AtkObject * obj, gpointer data)
48 ATK_OBJECT_CLASS(parent_class)->initialize(obj, data);
49 printf("Initialize: %p\n", obj);
52 static void test_hello_finalize(AtkObject * obj)
54 printf("Finalizing: %p\n", obj);
57 static AtkObject *test_hello_ref_child(AtkObject * obj, gint i)
60 printf("ref child: %p, index %d\n", obj, i);
61 if (obj != root) return NULL;
62 data = g_list_nth_data(children, i);
63 if (data) return ATK_OBJECT(data);
67 static void test_hello_class_init(test_helloClass * klass)
69 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
71 parent_class = (AtkObjectClass *) g_type_class_peek_parent(klass);
72 atk_class->ref_state_set = test_hello_ref_state_set;
73 atk_class->get_n_children = test_hello_get_n_children;
74 atk_class->ref_child = test_hello_ref_child;
75 atk_class->initialize = test_hello_real_initialize;
78 static gint test_hello_get_caret_offset(AtkText * text)
80 test_hello *obj = TEST_HELLO(text);
84 static void atk_text_interface_init (AtkTextIface * iface)
86 g_return_if_fail (iface != NULL);
87 iface->get_caret_offset = test_hello_get_caret_offset;
90 GType test_hello_get_type(void)
92 static GType type = 0;
96 static const GTypeInfo tinfo = {
97 sizeof(test_helloClass),
98 (GBaseInitFunc) NULL, /* base init */
99 (GBaseFinalizeFunc) test_hello_finalize, /* base finalize */
100 (GClassInitFunc) test_hello_class_init, /* class init */
101 (GClassFinalizeFunc) NULL, /* class finalize */
102 NULL, /* class data */
103 sizeof(test_hello), /* instance size */
104 0, /* nb preallocs */
105 (GInstanceInitFunc) NULL, /* instance init */
106 NULL /* value table */
109 static const GInterfaceInfo atk_text_info = {
110 (GInterfaceInitFunc) atk_text_interface_init,
111 (GInterfaceFinalizeFunc) NULL,
116 /* Following code would use the factory to fetch the parent type
117 * based on the atk type associated with GTK_TYPE_WIDGET */
119 AtkObjectFactory *factory;
122 atk_registry_get_factory(atk_get_default_registry(),
124 parent_type = atk_object_factory_get_accessible_type(factory);
127 type = g_type_register_static(atk_object_get_type(),
128 "test_hello", &tinfo, (GTypeFlags) 0);
129 g_type_add_interface_static (type, ATK_TYPE_TEXT, &atk_text_info);
133 static AtkObject *get_root()
138 static void add_child(AtkObject *child)
141 children = g_list_append(children, child);
142 g_signal_emit_by_name(root, "children-changed::add", child);
145 main(int argc, char *argv[])
149 GIOChannel *stdin_channel;
150 struct termios termios, rt;
152 void (*gnome_accessibility_module_init)();
156 klass = g_type_class_ref(ATK_TYPE_UTIL);
157 klass->get_root = get_root;
158 g_type_class_unref(klass);
159 root = g_object_new(TEST_TYPE_HELLO, NULL);
160 table = ATK_OBJECT(g_object_new(TEST_TYPE_SIMPLE_TABLE, NULL));
162 /* The below line isn't really right -- normally gtk will build the path */
163 bridge = g_module_open("/usr/lib/gtk-2.0/modules/libatk-bridge.so", G_MODULE_BIND_LOCAL|G_MODULE_BIND_LAZY);
166 fprintf(stderr, "Couldn't load atk-bridge.so\n");
169 if (!g_module_symbol(bridge, "gnome_accessibility_module_init", (gpointer *)&gnome_accessibility_module_init))
171 fprintf(stderr, "Couldn't find gnome_accessibility_module_init\n"); exit(1);
173 (*gnome_accessibility_module_init)();
174 atk_object_set_name(root, "root object");
176 mainloop = g_main_loop_new (NULL, FALSE);
178 /* Make stdin "raw" so that we will see a key immediately */
179 tcgetattr(0, &termios);
182 tcsetattr(0, TCSAFLUSH, &rt);
183 /* Set a watch on stdin so that we'll know when a key is pressed */
184 stdin_channel = g_io_channel_unix_new(0);
185 g_io_add_watch(stdin_channel, G_IO_IN, quit, &termios);
187 g_main_loop_run (mainloop);