]> Pileus Git - ~andy/gtk/blob - gtk/gtkaccessible.c
bgo#622371 - Add gtk_accessible_set_widget() - the widget field was GSEAL()ed.
[~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 "gtkintl.h"
25 #include "gtkaccessible.h"
26 #include "gtkalias.h"
27
28 /**
29  * SECTION:gtkaccessible
30  * @Short_description: Accessibility support for widgets
31  * @Title: GtkAccessible
32  */
33
34
35 static void gtk_accessible_real_connect_widget_destroyed (GtkAccessible *accessible);
36
37 G_DEFINE_TYPE (GtkAccessible, gtk_accessible, ATK_TYPE_OBJECT)
38
39 static void
40 gtk_accessible_init (GtkAccessible *object)
41 {
42 }
43
44 static void
45 gtk_accessible_class_init (GtkAccessibleClass *klass)
46 {
47   klass->connect_widget_destroyed = gtk_accessible_real_connect_widget_destroyed;
48 }
49
50 /**
51  * gtk_accessible_set_widget:
52  * @accessible: a #GtkAccessible
53  * @widget: a #GtkWidget
54  *
55  * Sets the #GtkWidget corresponding to the #GtkAccessible.
56  *
57  * Since: 2.22
58  **/
59 void
60 gtk_accessible_set_widget (GtkAccessible *accessible,
61                            GtkWidget     *widget)
62 {
63   g_return_val_if_fail (GTK_IS_ACCESSIBLE (accessible), NULL);
64   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
65
66   accessible->widget = widget;
67 }
68
69 /**
70  * gtk_accessible_get_widget:
71  * @accessible: a #GtkAccessible
72  *
73  * Gets the #GtkWidget corresponding to the #GtkAccessible. The returned widget
74  * does not have a reference added, so you do not need to unref it.
75  *
76  * Returns: (transfer none): pointer to the #GtkWidget corresponding to
77  *   the #GtkAccessible, or %NULL.
78  *
79  * Since: 2.22
80  **/
81 GtkWidget*
82 gtk_accessible_get_widget (GtkAccessible *accessible)
83 {
84   g_return_val_if_fail (GTK_IS_ACCESSIBLE (accessible), NULL);
85
86   return accessible->widget;
87 }
88
89 /**
90  * gtk_accessible_connect_widget_destroyed
91  * @accessible: a #GtkAccessible
92  *
93  * This function specifies the callback function to be called when the widget
94  * corresponding to a GtkAccessible is destroyed.
95  */
96 void
97 gtk_accessible_connect_widget_destroyed (GtkAccessible *accessible)
98 {
99   GtkAccessibleClass *class;
100
101   g_return_if_fail (GTK_IS_ACCESSIBLE (accessible));
102
103   class = GTK_ACCESSIBLE_GET_CLASS (accessible);
104
105   if (class->connect_widget_destroyed)
106     class->connect_widget_destroyed (accessible);
107 }
108
109 static void
110 gtk_accessible_real_connect_widget_destroyed (GtkAccessible *accessible)
111 {
112   if (accessible->widget)
113   {
114     g_signal_connect (accessible->widget,
115                       "destroy",
116                       G_CALLBACK (gtk_widget_destroyed),
117                       &accessible->widget);
118   }
119 }
120
121 #define __GTK_ACCESSIBLE_C__
122 #include "gtkaliasdef.c"