summaryrefslogtreecommitdiff
path: root/atspi/atspi-hypertext.c
blob: 748d2721e995942a1aa7da68ae3467fed17b4da7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * AT-SPI - Assistive Technology Service Provider Interface
 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
 *
 * Copyright 2001, 2002 Sun Microsystems Inc.,
 * Copyright 2001, 2002 Ximian, Inc.
 * Copyright 2010, 2011 Novell, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include "atspi-private.h"

/**
 * atspi_hypertext_get_n_links:
 * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
 *
 * Gets the total number of #AtspiHyperlink objects that an
 * #AtspiHypertext implementor has.
 *
 * Returns: a #gint indicating the number of #AtspiHyperlink objects
 *        of the #AtspiHypertext implementor, or -1 if
 *        the number cannot be determined (for example, if the
 *        #AtspiHypertext object is so large that it is not
 *        all currently in the memory cache).
 **/
gint
atspi_hypertext_get_n_links (AtspiHypertext *obj, GError **error)
{
  dbus_int32_t retval = 0;

  g_return_val_if_fail (obj != NULL, FALSE);

  _atspi_dbus_call (obj, atspi_interface_hypertext, "GetNLinks", error, "=>i", &retval);

  return retval;
}

/**
 * atspi_hypertext_get_link:
 * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
 * @link_index: a (zero-index) #gint indicating which hyperlink to query.
 *
 * Gets the #AtspiHyperlink object at a specified index.
 *
 * Returns: (transfer full): the #AtspiHyperlink object specified by
 *          @link_index.
 **/
AtspiHyperlink *
atspi_hypertext_get_link (AtspiHypertext *obj, gint link_index, GError **error)
{
  dbus_int32_t d_link_index = link_index;
  DBusMessage *reply;
	
  g_return_val_if_fail (obj != NULL, NULL);

  reply = _atspi_dbus_call_partial (obj, atspi_interface_hypertext, "GetLink", error, "i", d_link_index);

  return _atspi_dbus_return_hyperlink_from_message (reply);
}

/**
 * atspi_hypertext_get_link_index:
 * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
 * @character_offset: a #gint specifying the character offset to query.
 *
 * Gets the index of the #AtspiHyperlink object at a specified
 *        character offset.
 *
 * Returns: the linkIndex of the #AtspiHyperlink active at
 *        character offset @character_offset, or -1 if there is
 *        no hyperlink at the specified character offset.
 **/
int
atspi_hypertext_get_link_index (AtspiHypertext *obj,
                                gint             character_offset,
                                GError **error)
{
  dbus_int32_t d_character_offset = character_offset;
  dbus_int32_t retval = -1;

  g_return_val_if_fail (obj != NULL, -1);

  _atspi_dbus_call (obj, atspi_interface_hypertext, "GetLinkIndex", error, "i=>i", d_character_offset, &retval);

  return retval;
}

static void
atspi_hypertext_base_init (AtspiHypertext *klass)
{
}

GType
atspi_hypertext_get_type (void)
{
  static GType type = 0;

  if (!type) {
    static const GTypeInfo tinfo =
    {
      sizeof (AtspiHypertext),
      (GBaseInitFunc) atspi_hypertext_base_init,
      (GBaseFinalizeFunc) NULL,
    };

    type = g_type_register_static (G_TYPE_INTERFACE, "AtspiHypertext", &tinfo, 0);

  }
  return type;
}