bdfe6c1da3a2ab0cf0d51658201fb0bf7f19a2d8
[platform/upstream/atk.git] / atk / atkhyperlinkimpl.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2006 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 <string.h>
21 #include "atkhyperlinkimpl.h"
22
23 /**
24  * SECTION:atkhyperlinkimpl
25  * @Short_description: An interface from which the AtkHyperlink
26  *  associated with an AtkObject may be obtained.
27  * @Title:AtkHyperlinImpl
28  *
29  * AtkHyperlinkImpl allows AtkObjects to refer to their associated
30  * AtkHyperlink instance, if one exists.  AtkHyperlinkImpl differs
31  * from AtkHyperlink in that AtkHyperlinkImpl is an interface, whereas
32  * AtkHyperlink is a object type.  The AtkHyperlinkImpl interface
33  * allows a client to query an AtkObject for the availability of an
34  * associated AtkHyperlink instance, and obtain that instance.  It is
35  * thus particularly useful in cases where embedded content or inline
36  * content within a text object is present, since the embedding text
37  * object implements AtkHypertext and the inline/embedded objects are
38  * exposed as children which implement AtkHyperlinkImpl, in addition
39  * to their being obtainable via AtkHypertext:getLink followed by
40  * AtkHyperlink:getObject.
41  *
42  * The AtkHyperlinkImpl interface should be supported by objects
43  * exposed within the hierarchy as children of an AtkHypertext
44  * container which correspond to "links" or embedded content within
45  * the text.  HTML anchors are not, for instance, normally exposed
46  * this way, but embedded images and components which appear inline in
47  * the content of a text object are. The AtkHyperlinkIface interface
48  * allows a means of determining which children are hyperlinks in this
49  * sense of the word, and for obtaining their corresponding
50  * AtkHyperlink object, from which the embedding range, URI, etc. can
51  * be obtained.
52  *
53  * To some extent this interface exists because, for historical
54  * reasons, AtkHyperlink was defined as an object type, not an
55  * interface.  Thus, in order to interact with AtkObjects via
56  * AtkHyperlink semantics, a new interface was required.
57  */
58
59 GType
60 atk_hyperlink_impl_get_type (void)
61 {
62   static GType type = 0;
63
64   if (!type) {
65     GTypeInfo tinfo =
66     {
67       sizeof (AtkHyperlinkImplIface),
68       (GBaseInitFunc) NULL,
69       (GBaseFinalizeFunc) NULL,
70
71     };
72
73     type = g_type_register_static (G_TYPE_INTERFACE, "AtkHyperlinkImpl", &tinfo, 0);
74   }
75
76   return type;
77 }
78
79 /**
80  * atk_hyperlink_impl_get_hyperlink:
81  * @impl: a #GObject instance that implements AtkHyperlinkImplIface
82  *
83  * Gets the hyperlink associated with this object.
84  *
85  * Returns: (transfer full):  an AtkHyperlink object which points to this
86  * implementing AtkObject.
87  *
88  * Since: 1.12
89  **/
90 AtkHyperlink *
91 atk_hyperlink_impl_get_hyperlink (AtkHyperlinkImpl *impl)
92 {
93   AtkHyperlinkImplIface *iface;
94
95   g_return_val_if_fail (impl != NULL, NULL);
96   g_return_val_if_fail (ATK_IS_HYPERLINK_IMPL (impl), NULL);
97
98   iface = ATK_HYPERLINK_IMPL_GET_IFACE (impl);
99
100   if (iface->get_hyperlink)
101     {
102       return (iface->get_hyperlink) (impl);
103     }
104   return NULL;
105 }
106