]> Pileus Git - ~andy/gtk/blob - modules/other/gail/gailhtmlboxembedded.c
32778b696356e6b261e68c610dae803f97e585d1
[~andy/gtk] / modules / other / gail / gailhtmlboxembedded.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 "gailhtmlboxembedded.h"
24
25 static void       gail_html_box_embedded_class_init      (GailHtmlBoxEmbeddedClass *klass);
26 static gint       gail_html_box_embedded_get_n_children  (AtkObject             *obj);
27 static AtkObject* gail_html_box_embedded_ref_child       (AtkObject             *obj,
28                                                           gint                  i);
29
30 G_DEFINE_TYPE (GailHtmlBoxEmbedded, gail_html_box_embedded, GAIL_TYPE_HTML_BOX)
31
32 AtkObject*
33 gail_html_box_embedded_new (GObject *obj)
34 {
35   gpointer object;
36   AtkObject *atk_object;
37
38   g_return_val_if_fail (HTML_IS_BOX_EMBEDDED (obj), NULL);
39   object = g_object_new (GAIL_TYPE_HTML_BOX_EMBEDDED, 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_embedded_class_init (GailHtmlBoxEmbeddedClass *klass)
48 {
49   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
50
51   class->get_n_children = gail_html_box_embedded_get_n_children;
52   class->ref_child = gail_html_box_embedded_ref_child;
53 }
54
55 static gint
56 gail_html_box_embedded_get_n_children (AtkObject *obj)
57 {
58   AtkGObject *atk_gobject;
59   HtmlBoxEmbedded *box_embedded;
60   GObject *g_obj;
61
62   g_return_val_if_fail (GAIL_IS_HTML_BOX_EMBEDDED (obj), 0);
63   atk_gobject = ATK_GOBJECT (obj); 
64   g_obj = atk_gobject_get_object (atk_gobject);
65   if (g_obj == NULL)
66     /* State is defunct */
67     return 0;
68
69   g_return_val_if_fail (HTML_IS_BOX_EMBEDDED (g_obj), 0);
70
71   box_embedded = HTML_BOX_EMBEDDED (g_obj);
72   g_return_val_if_fail (box_embedded->widget, 0);
73   return 1;
74 }
75
76 static AtkObject*
77 gail_html_box_embedded_ref_child (AtkObject *obj,
78                                   gint      i)
79 {
80   AtkGObject *atk_gobject;
81   HtmlBoxEmbedded *box_embedded;
82   GObject *g_obj;
83   AtkObject *atk_child;
84
85   g_return_val_if_fail (GAIL_IS_HTML_BOX_EMBEDDED (obj), NULL);
86
87   if (i != 0)
88           return NULL;
89
90   atk_gobject = ATK_GOBJECT (obj);
91   g_obj = atk_gobject_get_object (atk_gobject);
92   if (g_obj == NULL)
93     /* State is defunct */
94     return NULL;
95
96   g_return_val_if_fail (HTML_IS_BOX_EMBEDDED (g_obj), NULL);
97
98   box_embedded = HTML_BOX_EMBEDDED (g_obj);
99   g_return_val_if_fail (box_embedded->widget, NULL);
100
101   atk_child = gtk_widget_get_accessible (box_embedded->widget);
102   g_object_ref (atk_child);
103   atk_object_set_parent (atk_child, obj);
104   return atk_child;
105 }