Some attribute-related fixes
[platform/upstream/at-spi2-core.git] / atspi / atspi-text.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #include "atspi-private.h"
25
26 AtspiRange *
27 atspi_range_copy (AtspiRange *src)
28 {
29   AtspiRange *dst = g_new (AtspiRange, 1);
30
31   if (dst)
32   {
33     dst->start_offset = src->start_offset;
34     dst->end_offset = src->end_offset;
35   }
36   return dst;
37 }
38
39 G_DEFINE_BOXED_TYPE (AtspiRange, atspi_range, atspi_range_copy, g_free)
40
41 static AtspiTextRange *
42 atspi_text_range_copy (AtspiTextRange *src)
43 {
44   AtspiTextRange *dst = g_new (AtspiTextRange, 1);
45
46   if (dst)
47   {
48     dst->content = g_strdup (src->content);
49     dst->start_offset = src->start_offset;
50     dst->end_offset = src->end_offset;
51   }
52   return dst;
53 }
54
55 static void
56 atspi_text_range_free (AtspiTextRange *range)
57 {
58   g_free (range->content);
59   g_free (range);
60 }
61
62 G_DEFINE_BOXED_TYPE (AtspiTextRange, atspi_text_range, atspi_text_range_copy,
63                      atspi_text_range_free)
64
65 /**
66  * atspi_text_get_character_count:
67  * @obj: a pointer to the #AtspiText object to query.
68  *
69  * Get the character count of an #AccessibleText object.
70  *
71  * Returns: a long integer indicating the total number of
72  *              characters in the #AccessibleText object.
73  **/
74 gint
75 atspi_text_get_character_count (AtspiText *obj, GError **error)
76 {
77   dbus_int32_t retval;
78
79   g_return_val_if_fail (obj != NULL, -1);
80
81   _atspi_dbus_get_property (obj, atspi_interface_text, "CharacterCount", error, "i", &retval);
82
83   return retval;
84 }
85
86 /**
87  * atspi_text_get_text:
88  * @obj: a pointer to the #AtspiText object to query.
89  * @start_offset: a #long indicating the start of the desired text range.
90  * @end_offset: a #long indicating the first character past the desired range.
91  *
92  * Get a range of text from an #AtspiText object.  The number of bytes
93  *          in the returned string may exceed end_offset-start_offset, since
94  *          UTF-8 is a variable-width encoding.
95  *
96  * Returns: a text string containing characters from @start_offset
97  *          to @end_offset-1, inclusive, encoded as UTF-8.
98  **/
99 gchar *
100 atspi_text_get_text (AtspiText *obj,
101                         gint start_offset,
102                         gint end_offset,
103                         GError **error)
104 {
105   gchar *retval;
106   dbus_int32_t d_start_offset = start_offset, d_end_offset = end_offset;
107
108   g_return_val_if_fail (obj != NULL, NULL);
109
110   _atspi_dbus_call (obj, atspi_interface_text, "GetText", error, "ii=>s", start_offset, end_offset, &retval);
111
112   return retval;
113 }
114
115 /**
116  * atspi_text_get_caret_offset:
117  * @obj: a pointer to the #AtspiText object to query.
118  *
119  * Get the current offset of the text caret in an #AtspiText object.
120  *
121  * Returns: a long integer indicating the current position of the text caret.
122  **/
123 gint
124 atspi_text_get_caret_offset (AtspiText *obj, GError **error)
125 {
126   dbus_int32_t retval = -1;
127
128   g_return_val_if_fail (obj != NULL, -1);
129
130   _atspi_dbus_get_property (obj, atspi_interface_text, "CaretOffset", error, "i", &retval);
131
132   return retval;
133 }
134
135 /**
136  * atspi_text_get_attributes:
137  * @obj: a pointer to the #AtspiText object to query.
138  * @offset: a long integer indicating the offset from which the attribute
139  *        search is based.
140  * @start_offset: (out): a #gint indicating the start of the desired text
141  *                range.
142  * @end_offset: (out): a #gint indicating the first character past the desired
143  *              range.
144  *
145  * Get the attributes applied to a range of text from an #AtspiText
146  *          object, and the bounds of the range.
147  *          The text attributes correspond to CSS attributes where possible,
148  *
149  * Returns: (element-type gchar* gchar*) (transfer full): a #GHashTable
150  *          describing the attributes at the given character offset
151  **/
152 GHashTable *
153 atspi_text_get_attributes (AtspiText *obj,
154                            gint offset,
155                            gint *start_offset,
156                            gint *end_offset,
157                            GError **error)
158 {
159   dbus_int32_t d_offset = offset;
160   dbus_int32_t d_start_offset, d_end_offset;
161   GHashTable *hash;
162   DBusMessage *reply;
163   DBusMessageIter iter;
164   GHashTable *ret;
165
166   if (obj == NULL)
167    return NULL;
168
169   reply = _atspi_dbus_call_partial (obj, atspi_interface_text, "GetAttributes", error, "i", d_offset);
170   _ATSPI_DBUS_CHECK_SIG (reply, "a{ss}ii", ret)
171
172   dbus_message_iter_init (reply, &iter);
173   ret = _atspi_dbus_hash_from_iter (&iter);
174   dbus_message_iter_next (&iter);
175
176   dbus_message_iter_get_basic (&iter, &d_start_offset);
177   if (start_offset)
178     *start_offset = d_start_offset;
179   dbus_message_iter_next (&iter);
180   dbus_message_iter_get_basic (&iter, &d_end_offset);
181   if (end_offset)
182     *end_offset = d_start_offset;
183
184   dbus_message_unref (reply);
185   return ret;
186 }
187
188 /**
189  * atspi_text_get_attribute_run:
190  * @obj: a pointer to the #AtspiText object to query.
191  * @offset: an integer indicating the offset from which the attribute
192  *        search is based.
193  * @include_defaults: a #bool if False, the call should only return those 
194  *                 attributes which are explicitly set on the current attribute 
195  *                 run, omitting any attributes which are inherited from the 
196  *                 default values.
197  * @start_offset: (out): a #gint indicating the start of the desired text
198  *                range.
199  * @end_offset: (out): a #gint indicating the first character past the desired
200  *              range.
201  *
202  * Returns: (element-type gchar* gchar*) (transfer full): the AttributeSet
203  *          defined at offset, optionally including the 'default' attributes.
204  **/
205 GHashTable *
206 atspi_text_get_attribute_run (AtspiText *obj,
207                               gint offset,
208                               gboolean include_defaults,
209                               gint *start_offset,
210                               gint *end_offset,
211                               GError **error)
212 {
213   dbus_int32_t d_offset = offset;
214   dbus_int32_t d_start_offset, d_end_offset;
215   GHashTable *hash;
216   DBusMessage *reply;
217   DBusMessageIter iter;
218   GHashTable *ret;
219
220   if (obj == NULL)
221    return NULL;
222
223   reply = _atspi_dbus_call_partial (obj, atspi_interface_text,
224                                     "GetAttributeRun", error, "ib", d_offset,
225                                     include_defaults);
226   _ATSPI_DBUS_CHECK_SIG (reply, "a{ss}ii", ret)
227
228   dbus_message_iter_init (reply, &iter);
229   ret = _atspi_dbus_hash_from_iter (&iter);
230   dbus_message_iter_next (&iter);
231
232   dbus_message_iter_get_basic (&iter, &d_start_offset);
233   if (start_offset)
234     *start_offset = d_start_offset;
235   dbus_message_iter_next (&iter);
236   dbus_message_iter_get_basic (&iter, &d_end_offset);
237   if (end_offset)
238     *end_offset = d_end_offset;
239
240   dbus_message_unref (reply);
241   return ret;
242 }
243
244 /**
245  * atspi_text_get_attribute_value:
246  * @obj: a pointer to the #AtspiText object to query.
247  * @offset: The character offset at which to query the attribute.
248  * @attribute_name: The attribute to query.
249  *
250  * Returns: the value of a given attribute at the given offset, or NULL if
251  *          not present.
252  **/
253 gchar *
254 atspi_text_get_attribute_value (AtspiText *obj,
255                                 gint offset,
256                                 gchar *attribute_value,
257                                 GError **error)
258 {
259   gchar *retval = NULL;
260
261   g_return_val_if_fail (obj != NULL, NULL);
262
263   _atspi_dbus_call (obj, atspi_interface_text, "GetAttributeValue", error, "i=>s", offset, &retval);
264
265   return retval;
266 }
267
268 /**
269  * atspi_text_get_default_attributes:
270  * @obj: a pointer to the #AtspiText object to query.
271  *
272  * Get the default attributes applied to an #AtspiText
273  *          object.
274  *          The text attributes correspond to CSS attributes where possible,
275  *          keys and values are delimited from one another via ":", and
276  *          the delimiter between key/value pairs is ";". Thus
277  *          "font-size:10;foreground-color:0,0,0" would be a valid
278  *          return string.  The combination of this attribute set and
279  *          the attributes reported by #atspi_text_getAttributes
280  *          describes the entire set of text attributes over a range.
281  *
282  * Returns: (element-type gchar* gchar*) (transfer full): a #GHashTable
283  *          containing the default attributes applied to a text object,
284  *          (exclusive of explicitly-set attributes), encoded as UTF-8.
285  **/
286 GHashTable *
287 atspi_text_get_default_attributes (AtspiText *obj, GError **error)
288 {
289   DBusMessage *reply;
290
291     g_return_val_if_fail (obj != NULL, NULL);
292
293   reply = _atspi_dbus_call_partial (obj, atspi_interface_text, "GetDefaultAttributes", error, "");
294   return _atspi_dbus_return_hash_from_message (reply);
295 }
296
297
298 /**
299  * atspi_text_set_caret_offset:
300  * @obj: a pointer to the #AtspiText object on which to operate.
301  * @new_offset: the offset to which the text caret is to be moved.
302  *
303  * Set the text caret position for an #AtspiText object.
304  *
305  * Returns: #TRUE if successful, #FALSE otherwise.
306  **/
307 gboolean
308 atspi_text_set_caret_offset (AtspiText *obj,
309                                gint new_offset,
310                                GError **error)
311 {
312   dbus_int32_t d_new_offset = new_offset;
313   dbus_bool_t retval = FALSE;
314
315   g_return_val_if_fail (obj != NULL, FALSE);
316
317   _atspi_dbus_call (obj, atspi_interface_text, "SetCaretOffset", error, "i=>b", d_new_offset, &retval);
318
319   return retval;
320 }
321
322 /**
323  * atspi_text_get_text_before_offset:
324  * @obj: a pointer to the #AtspiText object on which to operate.
325  * @offset: an integer indicating the offset from which the delimiter
326  *        search is based.
327  * @type: an #AtspiTextBoundaryType indicating whether the desired
328  *       text string is a word, sentence, line, or attribute run.
329  *
330  * Get delimited text from an #AtspiText object which precedes a given
331  *          text offset.
332  *
333  * Returns: an #AtspiTextRange containing a UTF-8 string representing the
334  *          delimited text, both of whose delimiting boundaries are before the
335  *          current offset, or an empty string if no such text exists.
336  **/
337 AtspiTextRange *
338 atspi_text_get_text_before_offset (AtspiText *obj,
339                                     gint offset,
340                                     AtspiTextBoundaryType type,
341                                     GError **error)
342 {
343   dbus_int32_t d_offset = offset;
344   dbus_uint32_t d_type = type;
345   dbus_int32_t d_start_offset = -1, d_end_offset = -1;
346   AtspiTextRange *range = g_new0 (AtspiTextRange, 1);
347
348   if (range)
349     range->start_offset = range->end_offset = -1;
350   if (!obj || !range)
351     return range;
352
353   _atspi_dbus_call (obj, atspi_interface_text, "GetTextBeforeOffset", error,
354                     "iu=>sii", d_offset, d_type, &range->content,
355                     &d_start_offset, &d_end_offset);
356
357   range->start_offset = d_start_offset;
358   range->end_offset = d_end_offset;
359
360   return range;
361 }
362
363 /**
364  * atspi_text_get_text_at_offset:
365  * @obj: a pointer to the #AtspiText object on which to operate.
366  * @offset: a long integer indicating the offset from which the delimiter
367  *        search is based.
368  * @type: an #AtspiTextBoundaryType indicating whether the desired
369  *       text string is a word, sentence, line, or attribute run.
370  *
371  * Get delimited text from an #AtspiText object which includes a given
372  *          text offset.
373  *
374  * Returns: an #AtspiTextRange containing a UTF-8 string representing the
375  *          delimited text, whose delimiting boundaries bracket the
376  *          current offset, or an empty string if no such text exists.
377  **/
378 AtspiTextRange *
379 atspi_text_get_text_at_offset (AtspiText *obj,
380                                     gint offset,
381                                     AtspiTextBoundaryType type,
382                                     GError **error)
383 {
384   dbus_int32_t d_offset = offset;
385   dbus_uint32_t d_type = type;
386   dbus_int32_t d_start_offset = -1, d_end_offset = -1;
387   AtspiTextRange *range = g_new0 (AtspiTextRange, 1);
388
389   if (range)
390     range->start_offset = range->end_offset = -1;
391   if (!obj || !range)
392     return range;
393
394   _atspi_dbus_call (obj, atspi_interface_text, "GetTextAtOffset", error,
395                     "iu=>sii", d_offset, d_type, &range->content,
396                     &d_start_offset, &d_end_offset);
397
398   range->start_offset = d_start_offset;
399   range->end_offset = d_end_offset;
400
401   return range;
402 }
403
404 /**
405  * atspi_text_get_text_after_offset:
406  * @obj: a pointer to the #AtspiText object on which to operate.
407  * @offset: an integer indicating the offset from which the delimiter
408  *        search is based.
409  * @type: an #AtspiTextBoundaryType indicating whether the desired
410  *       text string is a word, sentence, line, or attribute run.
411  *
412  * Get delimited text from an #AtspiText object which follows a given
413  *          text offset.
414  *
415  * Returns: an #AtspiTextRange containing a UTF-8 string representing the
416  *          delimited text, both of whose delimiting boundaries are after or
417  *          inclusive of the current offset, or an empty string if no such
418  *          text exists.
419  **/
420 AtspiTextRange *
421 atspi_text_get_text_after_offset (AtspiText *obj,
422                                     gint offset,
423                                     AtspiTextBoundaryType type,
424                                     GError **error)
425 {
426   dbus_int32_t d_offset = offset;
427   dbus_uint32_t d_type = type;
428   dbus_int32_t d_start_offset = -1, d_end_offset = -1;
429   AtspiTextRange *range = g_new0 (AtspiTextRange, 1);
430
431   if (range)
432     range->start_offset = range->end_offset = -1;
433   if (!obj || !range)
434     return range;
435
436   _atspi_dbus_call (obj, atspi_interface_text, "GetTextAfterOffset", error,
437                     "iu=>sii", d_offset, d_type, &range->content,
438                     &d_start_offset, &d_end_offset);
439
440   range->start_offset = d_start_offset;
441   range->end_offset = d_end_offset;
442
443   return range;
444 }
445
446 /**
447  * atspi_text_get_character_at_offset:
448  * @obj: a pointer to the #AtspiText object on which to operate.
449  * @offset: a long integer indicating the text offset where the desired
450  *          character is located.
451  *
452  * Get the character at a given offset for an #AtspiText object.
453  *
454  * Returns: an #unsigned long integer which represents the
455  *        UCS-4 unicode code point of the given character, or
456  *        0xFFFFFFFF if the character in question cannot be represented
457  *        in the UCS-4 encoding.
458  **/
459 guint
460 atspi_text_get_character_at_offset (AtspiText *obj,
461                                      gint offset,
462                                      GError **error)
463 {
464   dbus_int32_t d_offset = offset;
465   dbus_int32_t retval = -1;
466
467   g_return_val_if_fail (obj != NULL, -1);
468
469   _atspi_dbus_call (obj, atspi_interface_text, "GetCharacterAtOffset", error, "i=>i", d_offset, &retval);
470
471   return retval;
472 }
473
474 /**
475  * atspi_text_get_character_extents:
476  * @obj: a pointer to the #AtspiText object on which to operate.
477  * @offset: an integer indicating the offset of the text character for
478  *        whom boundary information is requested.
479  * @type: an #AccessibleCoordType indicating the coordinate system to use
480  *        for the returned values.
481  *
482  * Returns: A #AtspiRect specifying the position and size of the character.
483  *
484  * Get the bounding box containing the glyph representing
485  *        the character at a particular text offset.
486  **/
487 AtspiRect *
488 atspi_text_get_character_extents (AtspiText *obj,
489                                     gint offset,
490                                     AtspiCoordType type,
491                                     GError **error)
492 {
493   dbus_int32_t d_offset = offset;
494   dbus_uint32_t d_type = type;
495   dbus_int32_t d_x, d_y, d_width, d_height;
496   AtspiRect ret;
497
498   ret.x = ret.y = ret.width = ret.height = -1;
499
500   if (obj == NULL)
501     return atspi_rect_copy (&ret);
502
503   _atspi_dbus_call (obj, atspi_interface_text, "GetCharacterExtents", error, "iu=>iiii", d_offset, d_type, &d_x, &d_y, &d_width, &d_height);
504
505   ret.x = d_x;
506   ret.y = d_y;
507   ret.width = d_width;
508   ret.height = d_height;
509   return atspi_rect_copy (&ret);
510 }
511
512 /**
513  * atspi_text_get_offset_at_point:
514  * @obj: a pointer to the #AtspiText object on which to operate.
515  * @x: the x coordinate of the point to be queried.
516  * @y: the y coordinate of the point to be queried.
517  * @type: an #AtspiCoordType indicating the coordinate system in which
518  *       the values should be returned.
519  *
520  * Get the character offset into the text at a given point.
521  *
522  * Returns: the offset (as an integer) at the point (@x, @y)
523  *       in the specified coordinate system.
524  *
525  **/
526 gint
527 atspi_text_get_offset_at_point (AtspiText *obj,
528                                  gint x,
529                                  gint y,
530                                  AtspiCoordType type,
531                                  GError **error)
532 {
533   dbus_int32_t d_x = x, d_y = y;
534   dbus_uint16_t d_type = type;
535   dbus_int32_t retval = -1;
536
537   g_return_val_if_fail (obj != NULL, -1);
538
539   _atspi_dbus_call (obj, atspi_interface_text, "GetOffsetAtPoint", error, "iin=>i", d_x, d_y, d_type, &retval);
540
541   return retval;
542 }
543
544 /**
545  * atspi_text_get_range_extents:
546  * @obj: a pointer to the #AtspiText object on which to operate.
547  * @start_offset: an integer indicating the offset of the first text character for
548  *        whom boundary information is requested.
549  * @end_offset: an integer indicating the offset of the text character
550  *        after the last character for whom boundary information is requested.
551  * @type: an #AtspiCoordType indicating the coordinate system to use
552  *        for the returned values.
553  *
554  * Returns: A #AtspiRect giving the position and size of the specified range
555  *          of text.
556  *
557  * Get the bounding box for text within a range in an  #AtspiText object.
558  **/
559 AtspiRect *
560 atspi_text_get_range_extents (AtspiText *obj,
561                                 gint start_offset,
562                                 gint end_offset,
563                                 AtspiCoordType type,
564                                 GError **error)
565 {
566   dbus_int32_t d_start_offset = start_offset, d_end_offset = end_offset;
567   dbus_int16_t d_type = type;
568   dbus_int32_t d_x, d_y, d_width, d_height;
569   AtspiRect ret;
570
571   ret.x = ret.y = ret.width = ret.height = -1;
572
573   if (obj == NULL)
574     return atspi_rect_copy (&ret);
575
576   _atspi_dbus_call (obj, atspi_interface_text, "GetRangeExtents", error, "iin=>iiii", d_start_offset, d_end_offset, d_type, &d_x, &d_y, &d_width, &d_height);
577
578   ret.x = d_x;
579   ret.y = d_y;
580   ret.width = d_width;
581   ret.height = d_height;
582   return atspi_rect_copy (&ret);
583 }
584
585 /**
586  * atspi_text_get_bounded_ranges:
587  * @obj: a pointer to the #AtspiText object on which to operate.
588  * @x: the 'starting' x coordinate of the bounding box.
589  * @y: the 'starting' y coordinate of the bounding box.
590  * @width: the x extent of the bounding box.
591  * @height: the y extent of the bounding box.
592  * @type: an #AccessibleCoordType indicating the coordinate system to use
593  *        for the returned values.
594  * @clipTypeX: an #AtspiTextClipType indicating how to treat characters that
595  *        intersect the bounding box's x extents.
596  * @clipTypeY: an #AtspiTextClipType indicating how to treat characters that
597  *        intersect the bounding box's y extents.
598  *
599  * Get the ranges of text from an #AtspiText object which lie within the
600  *          bounds defined by (@x, @y) and (@x+@width, @y+@height).
601  *
602  * Returns: (transfer full) (element-type AtspiTextRange*): a null-terminated list of
603  *          pointers to #AtspiTextRange structs detailing the bounded text.
604  **/
605 GArray *
606 atspi_text_get_bounded_ranges (AtspiText *obj,
607                                  gint x,
608                                  gint y,
609                                  gint width,
610                                  gint height,
611                                  AtspiCoordType type,
612                                  AtspiTextClipType clipTypeX,
613                                  AtspiTextClipType clipTypeY,
614                                  GError **error)
615 {
616   dbus_int32_t d_x = x, d_y = y, d_width = width, d_height = height;
617   dbus_uint32_t d_type = type;
618   dbus_uint32_t d_clipTypeX = clipTypeX, d_clipTypeY = clipTypeY;
619   GArray *range_seq;
620
621   g_return_val_if_fail (obj != NULL, NULL);
622
623   _atspi_dbus_call (obj, atspi_interface_text, "GetBoundedRanges", error, "iiiinuu=>a(iisv)", d_x, d_y, d_width, d_height, d_type, d_clipTypeX, d_clipTypeY, &range_seq);
624
625   return range_seq;
626 }
627
628 /**
629  * atspi_text_get_n_selections:
630  * @obj: a pointer to the #AtspiText object on which to operate.
631  *
632  * Get the number of active non-contiguous selections for an
633  *          #AtspiText object.
634  *
635  * Returns: a long integer indicating the current
636  *          number of non-contiguous text selections active
637  *          within an #AtspiText object.
638  **/
639 gint
640 atspi_text_get_n_selections (AtspiText *obj, GError **error)
641 {
642   dbus_int32_t retval;
643
644   g_return_val_if_fail (obj != NULL, -1);
645
646   _atspi_dbus_call (obj, atspi_interface_text, "GetNSelections", error, "i", &retval);
647
648   return retval;
649 }
650
651 /**
652  * atspi_text_get_sSelection:
653  * @obj: a pointer to the #AtspiText object on which to operate.
654  * @selection_num: an integer indicating which selection to query.
655  * @start_offset: a pointer to a long integer into which the start offset
656  *           of the selection will be returned.
657  * @end_offset: a pointer to a long integer into which the start offset
658  *           of the selection will be returned.
659  *
660  * Get the bounds of the @selection_num-th active text selection for an
661  *         #AtspiText object.
662  **/
663 AtspiRange *
664 atspi_text_get_selection (AtspiText *obj,
665                              gint selection_num,
666                              GError **error)
667 {
668   dbus_int32_t d_selection_num = selection_num;
669   dbus_int32_t d_start_offset, d_end_offset;
670   AtspiRange *ret = g_new (AtspiRange, 1);
671
672   if (ret)
673     ret->start_offset = ret->end_offset = -1;
674
675   if (!obj || !ret)
676     return ret;
677
678   _atspi_dbus_call (obj, atspi_interface_text, "GetSelection", error, "i=>ii", d_selection_num, &d_start_offset, &d_end_offset);
679
680   ret->start_offset = d_start_offset;
681   ret->end_offset = d_end_offset;
682   return ret;
683 }
684
685 /**
686  * atspi_text_add_selection:
687  * @obj: a pointer to the #AtspiText object on which to operate.
688  * @start_offset: the starting offset of the desired new selection.
689  * @end_offset: the offset of the first character after the new selection.
690  *
691  * Select some text (add a text selection) in an #AtspiText object.
692  *
693  * Returns: #TRUE if successful, #FALSE otherwise.
694  **/
695 gboolean
696 atspi_text_add_selection (AtspiText *obj,
697                              gint start_offset, gint end_offset,
698                              GError **error)
699 {
700   dbus_int32_t d_start_offset = start_offset, d_end_offset = end_offset;
701   dbus_bool_t retval = FALSE;
702
703   _atspi_dbus_call (obj, atspi_interface_text, "AddSelection", error, "ii=>b", d_start_offset, d_end_offset, &retval);
704
705   return retval;
706 }
707
708 /**
709  * atspi_text_remove_selection:
710  * @obj: a pointer to the #AtspiText object on which to operate.
711  * @selection_num: an integer indicating which (possibly of several)
712  *         text selection to remove.
713  *
714  * De-select a text selection.
715  *
716  * Returns: #TRUE if successful, #FALSE otherwise.
717  **/
718 gboolean
719 atspi_text_remove_selection (AtspiText *obj,
720                                 gint selection_num,
721                                 GError **error)
722 {
723   dbus_int32_t d_selection_num = selection_num;
724   dbus_bool_t retval = FALSE;
725
726   g_return_val_if_fail (obj != NULL, FALSE);
727
728   _atspi_dbus_call (obj, atspi_interface_text, "RemoveSelection", error, "i=>b", d_selection_num, &retval);
729
730   return retval;
731 }
732
733 /**
734  * atspi_text_set_selection:
735  * @obj: a pointer to the #AtspiText object on which to operate.
736  * @selection_num: a zero-offset index indicating which text selection to modify.
737  * @start_offset: a long int, the new starting offset for the selection.
738  * @end_offset: a long int, the desired new offset of the first character
739  *             after the selection.
740  *
741  * Change the bounds of an existing #AtspiText text selection.
742  *
743  * Returns: #TRUE if successful, #FALSE otherwise.
744  **/
745 gboolean
746 atspi_text_set_selection (AtspiText *obj,
747                              gint selection_num,
748                              gint start_offset,
749                              gint end_offset,
750                              GError **error)
751 {
752   dbus_int32_t d_selection_num = selection_num, d_start_offset = start_offset, d_end_offset = end_offset;
753   dbus_bool_t retval = FALSE;
754
755   g_return_val_if_fail (obj != NULL, FALSE);
756
757   _atspi_dbus_call (obj, atspi_interface_text, "SetSelection", error, "iii=>b", d_selection_num, d_start_offset, d_end_offset, &retval);
758
759   return retval;
760 }
761
762 static void
763 atspi_text_base_init (AtspiText *klass)
764 {
765 }
766
767 GType
768 atspi_text_get_type (void)
769 {
770   static GType type = 0;
771
772   if (!type) {
773     static const GTypeInfo tinfo =
774     {
775       sizeof (AtspiText),
776       (GBaseInitFunc) atspi_text_base_init,
777       (GBaseFinalizeFunc) NULL,
778     };
779
780     type = g_type_register_static (G_TYPE_INTERFACE, "AtspiText", &tinfo, 0);
781
782   }
783   return type;
784 }