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