Updated Esperanto translation
[gtkhtml.git] / a11y / utils.c
blobb7ad98235fb231f0862913400c2183e4dee9233f
1 /* This file is part of the GtkHTML library.
3 * Copyright 2002 Ximian, Inc.
5 * Author: Radek Doulik
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #include "htmlembedded.h"
25 #include "htmlobject.h"
27 #include "cell.h"
28 #include "image.h"
29 #include "paragraph.h"
30 #include "table.h"
31 #include "text.h"
32 #include "utils.h"
34 static AtkObject *
35 create_accessible (HTMLObject *o,
36 AtkObject *parent)
38 AtkObject *accessible = NULL;
40 switch (HTML_OBJECT_TYPE (o)) {
41 case HTML_TYPE_CLUEFLOW:
42 accessible = html_a11y_paragraph_new (o);
43 break;
44 case HTML_TYPE_TEXT:
45 accessible = html_a11y_text_new (o);
46 break;
47 case HTML_TYPE_IMAGE:
48 accessible = html_a11y_image_new (o);
49 break;
50 case HTML_TYPE_TABLE:
51 accessible = html_a11y_table_new (o);
52 break;
53 case HTML_TYPE_TABLECELL:
54 accessible = html_a11y_cell_new (o);
55 break;
56 case HTML_TYPE_RULE:
57 accessible = html_a11y_new (o, ATK_ROLE_SEPARATOR);
58 break;
59 case HTML_TYPE_EMBEDDED:
60 case HTML_TYPE_SELECT:
61 case HTML_TYPE_RADIO:
62 case HTML_TYPE_OBJECT:
63 case HTML_TYPE_TEXTAREA:
64 case HTML_TYPE_TEXTINPUT:
65 case HTML_TYPE_BUTTON:
66 case HTML_TYPE_CHECKBOX:
67 case HTML_TYPE_IFRAME:
68 if (HTML_EMBEDDED (o)-> widget) {
69 accessible = gtk_widget_get_accessible (HTML_EMBEDDED (o)->widget);
71 if (HTML_EMBEDDED (o)->name) {
72 if ((accessible != NULL) && (atk_object_get_name (accessible) == NULL))
73 atk_object_set_name (accessible, HTML_EMBEDDED (o)->name);
76 break;
77 case HTML_TYPE_TEXTSLAVE: /* ignore */
78 break;
79 default:
80 accessible = html_a11y_new (o, ATK_ROLE_UNKNOWN);
81 break;
84 if (accessible && parent) {
85 /* printf ("set parent of %p to %p\n", accessible, parent); */
86 atk_object_set_parent (accessible, parent);
89 return accessible;
92 static void
93 acc_unref (gpointer data)
95 AtkStateSet * ss;
97 g_object_set_data (G_OBJECT (data), HTML_ID, NULL);
98 ss = atk_object_ref_state_set (data);
100 atk_state_set_add_state (ss, ATK_STATE_DEFUNCT);
101 atk_object_notify_state_change (data, ATK_STATE_DEFUNCT, TRUE);
102 g_object_unref (G_OBJECT (data));
105 AtkObject *
106 html_utils_get_accessible (HTMLObject *o,
107 AtkObject *parent)
109 AtkObject *accessible;
111 g_return_val_if_fail (o != NULL, NULL);
113 accessible = html_object_get_data_nocp (o, ACCESSIBLE_ID);
115 if (!accessible) {
116 accessible = create_accessible (o, parent);
117 if (accessible) {
118 g_object_ref (accessible);
119 html_object_set_data_full_nocp (o, ACCESSIBLE_ID, accessible, acc_unref);
123 return accessible;