Updated Polish translation
[platform/upstream/atk.git] / atk / atksocket.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright (C) 2009 Novell, 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 "atk.h"
21 #include "atksocket.h"
22
23 G_DEFINE_TYPE (AtkSocket, atk_socket, ATK_TYPE_OBJECT);
24
25 static void atk_socket_class_init (AtkSocketClass *klass);
26
27 static void
28 atk_socket_init (AtkSocket* obj)
29 {
30   obj->embedded_plug_id = NULL;
31 }
32
33 static void
34 atk_socket_class_init (AtkSocketClass* klass)
35 {
36   klass->embed = NULL;
37 }
38
39 AtkObject*
40 atk_socket_new (void)
41 {
42   AtkObject* accessible;
43   
44   accessible = g_object_new (ATK_TYPE_SOCKET, NULL);
45   g_return_val_if_fail (accessible != NULL, NULL);
46
47   accessible->role = ATK_ROLE_FILLER;
48   accessible->layer = ATK_LAYER_WIDGET;
49   
50   return accessible;
51 }
52
53 /**
54  * atk_socket_embed:
55  * @obj: an #AtkSocket
56  * @plug_id: the ID of an #AtkPlug
57  *
58  * Embeds the children of an #AtkPlug as the children of the #AtkSocket.  The
59  * plug may be in the same process or in a different process.
60  **/
61 void
62 atk_socket_embed (AtkSocket* obj, gchar* plug_id)
63 {
64   AtkSocketClass *klass;
65
66   g_return_if_fail (plug_id != NULL);
67   g_return_if_fail (ATK_IS_SOCKET (obj));
68
69   klass = g_type_class_peek (ATK_TYPE_SOCKET);
70   if (klass && klass->embed)
71     {
72       if (obj->embedded_plug_id)
73         g_free (obj->embedded_plug_id);
74       obj->embedded_plug_id = g_strdup (plug_id);
75       (klass->embed) (obj, plug_id);
76     }
77 }
78
79 /**
80  * atk_socket_is_occupied:
81  * @obj: an #AtkSocket
82  *
83  * Determines whether or not the socket has an embedded plug.
84  *
85  * Returns: TRUE if a plug is embedded in the socket
86  **/
87 gboolean
88 atk_socket_is_occupied (AtkSocket* obj)
89 {
90   g_return_val_if_fail (ATK_IS_SOCKET (obj), FALSE);
91
92   return (obj->embedded_plug_id != NULL);
93 }