b6aaeea91e4d9dc592691a48dda0cdcdb6de9aae
[platform/upstream/atk.git] / atk / atkmisc.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2007 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 "atkmisc.h"
21
22 /**
23  * SECTION:atkmisc
24  * @Short_description: A set of ATK utility functions for thread locking
25  * @Title:AtkMisc
26  *
27  * A set of utility functions for thread locking. This interface and
28  * all his related methods are deprecated since 2.12.
29  */
30
31 static void atk_misc_class_init (AtkMiscClass *klass);
32
33 GType
34 atk_misc_get_type (void)
35 {
36   static GType type = 0;
37
38   if (!type)
39     {
40       static const GTypeInfo typeInfo =
41       {
42         sizeof (AtkMiscClass),
43         (GBaseInitFunc) NULL,
44         (GBaseFinalizeFunc) NULL,
45         (GClassInitFunc) atk_misc_class_init,
46         (GClassFinalizeFunc) NULL,
47         NULL,
48         sizeof (AtkMisc),
49         0,
50         (GInstanceInitFunc) NULL,
51       } ;
52       type = g_type_register_static (G_TYPE_OBJECT, "AtkMisc", &typeInfo, 0) ;
53     }
54   return type;
55 }
56
57 static void
58 atk_misc_class_init (AtkMiscClass *klass)
59 {
60   klass->threads_enter = NULL;
61   klass->threads_leave = NULL;
62 }
63
64 /**
65  * atk_misc_threads_enter:
66  * @misc: an AtkMisc instance for this application. 
67  *
68  * Take the thread mutex for the GUI toolkit, 
69  * if one exists. 
70  * (This method is implemented by the toolkit ATK implementation layer;
71  *  for instance, for GTK+, GAIL implements this via GDK_THREADS_ENTER).
72  *
73  * Deprecated: Since 2.12.
74  *
75  * Since: 1.13
76  *
77  **/
78 void
79 atk_misc_threads_enter (AtkMisc *misc)
80 {
81   AtkMiscClass *klass;
82
83   if (misc == NULL)
84     return;
85
86   klass = ATK_MISC_GET_CLASS (misc);
87
88   if (klass->threads_enter)
89     {
90       klass->threads_enter (misc);
91     }
92 }
93
94 /**
95  * atk_misc_threads_leave:
96  * @misc: an AtkMisc instance for this application. 
97  *
98  * Release the thread mutex for the GUI toolkit, 
99  * if one exists. This method, and atk_misc_threads_enter, 
100  * are needed in some situations by threaded application code which 
101  * services ATK requests, since fulfilling ATK requests often
102  * requires calling into the GUI toolkit.  If a long-running or
103  * potentially blocking call takes place inside such a block, it should
104  * be bracketed by atk_misc_threads_leave/atk_misc_threads_enter calls.
105  * (This method is implemented by the toolkit ATK implementation layer;
106  *  for instance, for GTK+, GAIL implements this via GDK_THREADS_LEAVE).
107  *
108  * Deprecated: Since 2.12.
109  *
110  * Since: 1.13
111  *
112  **/
113 void
114 atk_misc_threads_leave (AtkMisc *misc)
115 {
116   AtkMiscClass *klass;
117
118   if (misc == NULL)
119     return;
120
121   klass = ATK_MISC_GET_CLASS (misc);
122
123   if (klass->threads_leave)
124     {
125       klass->threads_leave (misc);
126     }
127 }
128
129 AtkMisc *atk_misc_instance = NULL;
130
131 /**
132  * atk_misc_get_instance:
133  *
134  * Obtain the singleton instance of AtkMisc for this application.
135  * 
136  * Since: 1.13
137  *
138  * Deprecated: Since 2.12.
139  *
140  * Returns: The singleton instance of AtkMisc for this application.
141  *
142  **/
143 const AtkMisc *
144 atk_misc_get_instance (void)
145 {
146   return atk_misc_instance;
147 }