]> Pileus Git - ~andy/gtk/blob - modules/other/gail/gailhtmlboxblock.c
gail: No need to include modules/other in CFLAGS anymore
[~andy/gtk] / modules / other / gail / gailhtmlboxblock.c
1 /* GAIL - The GNOME Accessibility Implementation Library
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser 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  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "config.h"
21
22 #include <libgtkhtml/gtkhtml.h>
23 #include "gailhtmlboxblock.h"
24
25 static void       gail_html_box_block_class_init      (GailHtmlBoxBlockClass *klass);
26 static gint       gail_html_box_block_get_n_children  (AtkObject             *obj);
27 static AtkObject* gail_html_box_block_ref_child       (AtkObject             *obj,
28                                                        gint                  i);
29
30 G_DEFINE_TYPE (GailHtmlBoxBlock, gail_html_box_block, GAIL_TYPE_HTML_BOX)
31
32 AtkObject*
33 gail_html_box_block_new (GObject *obj)
34 {
35   GObject *object;
36   AtkObject *atk_object;
37
38   g_return_val_if_fail (HTML_IS_BOX_BLOCK (obj), NULL);
39   object = g_object_new (GAIL_TYPE_HTML_BOX_BLOCK, NULL);
40   atk_object = ATK_OBJECT (object);
41   atk_object_initialize (atk_object, obj);
42   atk_object->role = ATK_ROLE_PANEL;
43   return atk_object;
44 }
45
46 static void
47 gail_html_box_block_class_init (GailHtmlBoxBlockClass *klass)
48 {
49   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
50
51   class->get_n_children = gail_html_box_block_get_n_children;
52   class->ref_child = gail_html_box_block_ref_child;
53 }
54
55 static gint
56 gail_html_box_block_get_n_children (AtkObject *obj)
57 {
58   AtkGObject *atk_gobject;
59   HtmlBox *box;
60   gint n_children = 0;
61   GObject *g_obj;
62
63   g_return_val_if_fail (GAIL_IS_HTML_BOX_BLOCK (obj), 0);
64   atk_gobject = ATK_GOBJECT (obj); 
65   g_obj = atk_gobject_get_object (atk_gobject);
66   if (g_obj == NULL)
67     return 0;
68
69   g_return_val_if_fail (HTML_IS_BOX (g_obj), 0);
70   box = HTML_BOX (g_obj);
71
72   if (box)
73     {
74       HtmlBox *child;
75
76       child = box->children;
77
78       while (child)
79         {
80           n_children++;
81           child = child->next;
82         }
83     }
84   return n_children;
85 }
86
87 static AtkObject *
88 gail_html_box_block_ref_child (AtkObject *obj,
89                                gint      i)
90 {
91   AtkGObject *atk_gobject;
92   GObject *g_obj;
93   HtmlBox *box;
94   AtkObject *atk_child = NULL;
95   gint n_children = 0;
96
97   g_return_val_if_fail (GAIL_IS_HTML_BOX_BLOCK (obj), NULL);
98   atk_gobject = ATK_GOBJECT (obj); 
99   g_obj = atk_gobject_get_object (atk_gobject);
100   if (g_obj == NULL)
101     return NULL;
102
103   g_return_val_if_fail (HTML_IS_BOX (g_obj), NULL);
104   box = HTML_BOX (g_obj);
105
106   if (box)
107     {
108       HtmlBox *child;
109
110       child = box->children;
111
112       while (child)
113         {
114           if (n_children == i)
115             {
116               atk_child = atk_gobject_get_accessible (G_OBJECT (child));
117               g_object_ref (atk_child);
118               break;
119             }
120           n_children++;
121           child = child->next;
122         }
123     }
124   return atk_child;
125 }