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

            
22
#include "atkhyperlinkimpl.h"
23
#include <string.h>
24

            
25
/**
26
 * AtkHyperlinImpl:
27
 *
28
 * An interface from which the AtkHyperlink
29
 *  associated with an AtkObject may be obtained.
30
 *
31
 * AtkHyperlinkImpl allows AtkObjects to refer to their associated
32
 * AtkHyperlink instance, if one exists.  AtkHyperlinkImpl differs
33
 * from AtkHyperlink in that AtkHyperlinkImpl is an interface, whereas
34
 * AtkHyperlink is a object type.  The AtkHyperlinkImpl interface
35
 * allows a client to query an AtkObject for the availability of an
36
 * associated AtkHyperlink instance, and obtain that instance.  It is
37
 * thus particularly useful in cases where embedded content or inline
38
 * content within a text object is present, since the embedding text
39
 * object implements AtkHypertext and the inline/embedded objects are
40
 * exposed as children which implement AtkHyperlinkImpl, in addition
41
 * to their being obtainable via AtkHypertext:getLink followed by
42
 * AtkHyperlink:getObject.
43
 *
44
 * The AtkHyperlinkImpl interface should be supported by objects
45
 * exposed within the hierarchy as children of an AtkHypertext
46
 * container which correspond to "links" or embedded content within
47
 * the text.  HTML anchors are not, for instance, normally exposed
48
 * this way, but embedded images and components which appear inline in
49
 * the content of a text object are. The AtkHyperlinkIface interface
50
 * allows a means of determining which children are hyperlinks in this
51
 * sense of the word, and for obtaining their corresponding
52
 * AtkHyperlink object, from which the embedding range, URI, etc. can
53
 * be obtained.
54
 *
55
 * To some extent this interface exists because, for historical
56
 * reasons, AtkHyperlink was defined as an object type, not an
57
 * interface.  Thus, in order to interact with AtkObjects via
58
 * AtkHyperlink semantics, a new interface was required.
59
 */
60

            
61
GType
62
1541
atk_hyperlink_impl_get_type (void)
63
{
64
  static GType type = 0;
65

            
66
1541
  if (!type)
67
    {
68
146
      GTypeInfo tinfo = {
69
        sizeof (AtkHyperlinkImplIface),
70
        (GBaseInitFunc) NULL,
71
        (GBaseFinalizeFunc) NULL,
72

            
73
      };
74

            
75
146
      type = g_type_register_static (G_TYPE_INTERFACE, "AtkHyperlinkImpl", &tinfo, 0);
76
    }
77

            
78
1541
  return type;
79
}
80

            
81
/**
82
 * atk_hyperlink_impl_get_hyperlink:
83
 * @impl: a #GObject instance that implements AtkHyperlinkImplIface
84
 *
85
 * Gets the hyperlink associated with this object.
86
 *
87
 * Returns: (transfer full):  an AtkHyperlink object which points to this
88
 * implementing AtkObject.
89
 *
90
 * Since: 1.12
91
 **/
92
AtkHyperlink *
93
atk_hyperlink_impl_get_hyperlink (AtkHyperlinkImpl *impl)
94
{
95
  AtkHyperlinkImplIface *iface;
96

            
97
  g_return_val_if_fail (impl != NULL, NULL);
98
  g_return_val_if_fail (ATK_IS_HYPERLINK_IMPL (impl), NULL);
99

            
100
  iface = ATK_HYPERLINK_IMPL_GET_IFACE (impl);
101

            
102
  if (iface->get_hyperlink)
103
    {
104
      return (iface->get_hyperlink) (impl);
105
    }
106
  return NULL;
107
}