Added AtkMisc class, uprev for gnome-2.17.5, and release.
[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 static void atk_misc_class_init (AtkMiscClass *klass);
23
24 GType
25 atk_misc_get_type (void)
26 {
27   static GType type = 0;
28
29   if (!type)
30     {
31       static const GTypeInfo typeInfo =
32       {
33         sizeof (AtkMiscClass),
34         (GBaseInitFunc) NULL,
35         (GBaseFinalizeFunc) NULL,
36         (GClassInitFunc) atk_misc_class_init,
37         (GClassFinalizeFunc) NULL,
38         NULL,
39         sizeof (AtkMisc),
40         0,
41         (GInstanceInitFunc) NULL,
42       } ;
43       type = g_type_register_static (G_TYPE_OBJECT, "AtkMisc", &typeInfo, 0) ;
44     }
45   return type;
46 }
47
48 static void
49 atk_misc_class_init (AtkMiscClass *klass)
50 {
51   klass->threads_enter = NULL;
52   klass->threads_leave = NULL;
53 }
54
55 /**
56  * atk_misc_threads_enter:
57  * @misc: an AtkMisc instance for this application. 
58  *
59  * Take the thread mutex for the GUI toolkit, 
60  * if one exists. 
61  * (This method is implemented by the toolkit ATK implementation layer;
62  *  for instance, for GTK+, GAIL implements this via GDK_THREADS_ENTER).
63  *
64  * Since: ATK 1.13
65  *
66  **/
67 void
68 atk_misc_threads_enter (AtkMisc *misc)
69 {
70   AtkMiscClass *klass = g_type_class_ref (ATK_TYPE_MISC);
71   if (klass->threads_enter)
72     {
73       klass->threads_enter (misc);
74     }
75   g_type_class_unref (klass);
76 }
77
78 /**
79  * atk_misc_threads_leave:
80  * @misc: an AtkMisc instance for this application. 
81  *
82  * Release the thread mutex for the GUI toolkit, 
83  * if one exists. This method, and atk_misc_threads_enter, 
84  * are needed in some situations by threaded application code which 
85  * services ATK requests, since fulfilling ATK requests often
86  * requires calling into the GUI toolkit.  If a long-running or
87  * potentially blocking call takes place inside such a block, it should
88  * be bracketed by atk_misc_threads_leave/atk_misc_threads_enter calls.
89  * (This method is implemented by the toolkit ATK implementation layer;
90  *  for instance, for GTK+, GAIL implements this via GDK_THREADS_LEAVE).
91  *
92  * Since: ATK 1.13
93  *
94  **/
95 void
96 atk_misc_threads_leave (AtkMisc *misc)
97 {
98   AtkMiscClass *klass = g_type_class_ref (ATK_TYPE_MISC);
99   if (klass->threads_leave)
100     {
101       klass->threads_leave (misc);
102     }
103   g_type_class_unref (klass);
104 }
105
106 AtkMisc *atk_misc_instance = NULL;
107
108 /**
109  * atk_misc_get_instance:
110  *
111  * Obtain the singleton instance of AtkMisc for this application.
112  * 
113  * Since: ATK 1.13
114  *
115  * Returns: The singleton instance of AtkMisc for this application.
116  *
117  **/
118 const AtkMisc *
119 atk_misc_get_instance (void)
120 {
121   return atk_misc_instance;
122 }