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 "config.h"
21

            
22
#include "atkmisc.h"
23

            
24
/**
25
 * AtkMisc:
26
 *
27
 * A set of ATK utility functions for thread locking
28
 *
29
 * A set of utility functions for thread locking. This interface and
30
 * all his related methods are deprecated since 2.12.
31
 */
32

            
33
static void atk_misc_class_init (AtkMiscClass *klass);
34

            
35
GType
36
atk_misc_get_type (void)
37
{
38
  static GType type = 0;
39

            
40
  if (!type)
41
    {
42
      static const GTypeInfo typeInfo = {
43
        sizeof (AtkMiscClass),
44
        (GBaseInitFunc) NULL,
45
        (GBaseFinalizeFunc) NULL,
46
        (GClassInitFunc) atk_misc_class_init,
47
        (GClassFinalizeFunc) NULL,
48
        NULL,
49
        sizeof (AtkMisc),
50
        0,
51
        (GInstanceInitFunc) NULL,
52
      };
53
      type = g_type_register_static (G_TYPE_OBJECT, "AtkMisc", &typeInfo, 0);
54
    }
55
  return type;
56
}
57

            
58
static void
59
atk_misc_class_init (AtkMiscClass *klass)
60
{
61
  klass->threads_enter = NULL;
62
  klass->threads_leave = NULL;
63
}
64

            
65
/**
66
 * atk_misc_threads_enter:
67
 * @misc: an AtkMisc instance for this application.
68
 *
69
 * Take the thread mutex for the GUI toolkit,
70
 * if one exists.
71
 * (This method is implemented by the toolkit ATK implementation layer;
72
 *  for instance, for GTK+, GAIL implements this via GDK_THREADS_ENTER).
73
 *
74
 * Deprecated: Since 2.12.
75
 *
76
 * Since: 1.13
77
 *
78
 **/
79
void
80
atk_misc_threads_enter (AtkMisc *misc)
81
{
82
  AtkMiscClass *klass;
83

            
84
  if (misc == NULL)
85
    return;
86

            
87
  klass = ATK_MISC_GET_CLASS (misc);
88

            
89
  if (klass->threads_enter)
90
    {
91
      klass->threads_enter (misc);
92
    }
93
}
94

            
95
/**
96
 * atk_misc_threads_leave:
97
 * @misc: an AtkMisc instance for this application.
98
 *
99
 * Release the thread mutex for the GUI toolkit,
100
 * if one exists. This method, and atk_misc_threads_enter,
101
 * are needed in some situations by threaded application code which
102
 * services ATK requests, since fulfilling ATK requests often
103
 * requires calling into the GUI toolkit.  If a long-running or
104
 * potentially blocking call takes place inside such a block, it should
105
 * be bracketed by atk_misc_threads_leave/atk_misc_threads_enter calls.
106
 * (This method is implemented by the toolkit ATK implementation layer;
107
 *  for instance, for GTK+, GAIL implements this via GDK_THREADS_LEAVE).
108
 *
109
 * Deprecated: Since 2.12.
110
 *
111
 * Since: 1.13
112
 *
113
 **/
114
void
115
atk_misc_threads_leave (AtkMisc *misc)
116
{
117
  AtkMiscClass *klass;
118

            
119
  if (misc == NULL)
120
    return;
121

            
122
  klass = ATK_MISC_GET_CLASS (misc);
123

            
124
  if (klass->threads_leave)
125
    {
126
      klass->threads_leave (misc);
127
    }
128
}
129

            
130
AtkMisc *atk_misc_instance = NULL;
131

            
132
/**
133
 * atk_misc_get_instance:
134
 *
135
 * Obtain the singleton instance of AtkMisc for this application.
136
 *
137
 * Since: 1.13
138
 *
139
 * Deprecated: Since 2.12.
140
 *
141
 * Returns: The singleton instance of AtkMisc for this application.
142
 *
143
 **/
144
const AtkMisc *
145
atk_misc_get_instance (void)
146
{
147
  return atk_misc_instance;
148
}