]> Pileus Git - ~andy/gtk/blob - gtk/gtkaccessible.c
Fixes #136082 and #135265, patch by Morten Welinder.
[~andy/gtk] / gtk / gtkaccessible.c
1 /* GTK - The GIMP Toolkit
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 #include <string.h>
22
23 #include "gtkwidget.h"
24 #include "gtkaccessible.h"
25
26 static void gtk_accessible_class_init (GtkAccessibleClass *klass);
27
28 static void gtk_accessible_real_connect_widget_destroyed (GtkAccessible *accessible);
29
30 GType
31 gtk_accessible_get_type (void)
32 {
33   static GType accessible_type = 0;
34
35   if (!accessible_type)
36     {
37       static const GTypeInfo accessible_info =
38       {
39         sizeof (GtkAccessibleClass),
40         NULL,           /* base_init */
41         NULL,           /* base_finalize */
42         (GClassInitFunc) gtk_accessible_class_init,
43         NULL,           /* class_finalize */
44         NULL,           /* class_data */
45         sizeof (GtkAccessible),
46         16,             /* n_preallocs */
47         (GInstanceInitFunc) NULL,
48       };
49
50       accessible_type =
51         g_type_register_static (ATK_TYPE_OBJECT, "GtkAccessible",
52                                 &accessible_info, 0);
53     }
54
55   return accessible_type;
56 }
57
58 static void
59 gtk_accessible_class_init (GtkAccessibleClass *klass)
60 {
61   klass->connect_widget_destroyed = gtk_accessible_real_connect_widget_destroyed;
62 }
63
64 /**
65  * gtk_accessible_connect_widget_destroyed
66  * @accessible: a #GtkAccessible
67  *
68  * This function specifies the callback function to be called when the widget
69  * corresponding to a GtkAccessible is destroyed.
70  */
71 void
72 gtk_accessible_connect_widget_destroyed (GtkAccessible *accessible)
73 {
74   GtkAccessibleClass *class;
75
76   g_return_if_fail (GTK_IS_ACCESSIBLE (accessible));
77
78   class = GTK_ACCESSIBLE_GET_CLASS (accessible);
79
80   if (class->connect_widget_destroyed)
81     class->connect_widget_destroyed (accessible);
82 }
83
84 static void
85 gtk_accessible_real_connect_widget_destroyed (GtkAccessible *accessible)
86 {
87   if (accessible->widget)
88   {
89     g_signal_connect (accessible->widget,
90                       "destroy",
91                       G_CALLBACK (gtk_widget_destroyed),
92                       &accessible->widget);
93   }
94 }