atktext: Fixing some typos on atk_text_get_text_at_offset deprecation
[atk.git] / atk / atkeditabletext.c
blob1ff6ed8e5f505e49e49d2bd21c40af1945c3e185
1 /* ATK - The Accessibility Toolkit for GTK+
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library 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.
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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library 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.
20 #include "atkeditabletext.h"
22 /**
23 * SECTION:atkeditabletext
24 * @Short_description: The ATK interface implemented by components
25 * containing user-editable text content.
26 * @Title:AtkEditableText
28 * #AtkEditableText should be implemented by UI components which
29 * contain text which the user can edit, via the #AtkObject
30 * corresponding to that component (see #AtkObject).
32 * #AtkEditableText is a subclass of #AtkText, and as such, an object
33 * which implements #AtkEditableText is by definition an #AtkText
34 * implementor as well.
36 * See also: #AtkText
39 GType
40 atk_editable_text_get_type (void)
42 static GType type = 0;
44 if (!type) {
45 static const GTypeInfo tinfo =
47 sizeof (AtkEditableTextIface),
48 (GBaseInitFunc) NULL,
49 (GBaseFinalizeFunc) NULL,
53 type = g_type_register_static (G_TYPE_INTERFACE, "AtkEditableText", &tinfo, 0);
56 return type;
59 /**
60 *atk_editable_text_set_run_attributes:
61 *@text: an #AtkEditableText
62 *@attrib_set: an #AtkAttributeSet
63 *@start_offset: start of range in which to set attributes
64 *@end_offset: end of range in which to set attributes
66 *Sets the attributes for a specified range. See the ATK_ATTRIBUTE
67 *macros (such as #ATK_ATTRIBUTE_LEFT_MARGIN) for examples of attributes
68 *that can be set. Note that other attributes that do not have corresponding
69 *ATK_ATTRIBUTE macros may also be set for certain text widgets.
71 *Returns: %TRUE if attributes successfully set for the specified
72 *range, otherwise %FALSE
73 **/
74 gboolean
75 atk_editable_text_set_run_attributes (AtkEditableText *text,
76 AtkAttributeSet *attrib_set,
77 gint start_offset,
78 gint end_offset)
80 AtkEditableTextIface *iface;
82 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (text), FALSE);
84 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
86 if (iface->set_run_attributes)
88 return (*(iface->set_run_attributes)) (text, attrib_set, start_offset, end_offset);
90 else
92 return FALSE;
97 /**
98 * atk_editable_text_set_text_contents:
99 * @text: an #AtkEditableText
100 * @string: string to set for text contents of @text
102 * Set text contents of @text.
104 void
105 atk_editable_text_set_text_contents (AtkEditableText *text,
106 const gchar *string)
108 AtkEditableTextIface *iface;
110 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
112 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
114 if (iface->set_text_contents)
115 (*(iface->set_text_contents)) (text, string);
119 * atk_editable_text_insert_text:
120 * @text: an #AtkEditableText
121 * @string: the text to insert
122 * @length: the length of text to insert, in bytes
123 * @position: The caller initializes this to
124 * the position at which to insert the text. After the call it
125 * points at the position after the newly inserted text.
127 * Insert text at a given position.
129 void
130 atk_editable_text_insert_text (AtkEditableText *text,
131 const gchar *string,
132 gint length,
133 gint *position)
135 AtkEditableTextIface *iface;
137 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
139 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
141 if (iface->insert_text)
142 (*(iface->insert_text)) (text, string, length, position);
146 * atk_editable_text_copy_text:
147 * @text: an #AtkEditableText
148 * @start_pos: start position
149 * @end_pos: end position
151 * Copy text from @start_pos up to, but not including @end_pos
152 * to the clipboard.
154 void
155 atk_editable_text_copy_text (AtkEditableText *text,
156 gint start_pos,
157 gint end_pos)
159 AtkEditableTextIface *iface;
161 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
163 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
165 if (iface->copy_text)
166 (*(iface->copy_text)) (text, start_pos, end_pos);
170 * atk_editable_text_cut_text:
171 * @text: an #AtkEditableText
172 * @start_pos: start position
173 * @end_pos: end position
175 * Copy text from @start_pos up to, but not including @end_pos
176 * to the clipboard and then delete from the widget.
178 void
179 atk_editable_text_cut_text (AtkEditableText *text,
180 gint start_pos,
181 gint end_pos)
183 AtkEditableTextIface *iface;
185 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
187 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
189 if (iface->cut_text)
190 (*(iface->cut_text)) (text, start_pos, end_pos);
194 * atk_editable_text_delete_text:
195 * @text: an #AtkEditableText
196 * @start_pos: start position
197 * @end_pos: end position
199 * Delete text @start_pos up to, but not including @end_pos.
201 void
202 atk_editable_text_delete_text (AtkEditableText *text,
203 gint start_pos,
204 gint end_pos)
206 AtkEditableTextIface *iface;
208 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
210 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
212 if (iface->delete_text)
213 (*(iface->delete_text)) (text, start_pos, end_pos);
217 * atk_editable_text_paste_text:
218 * @text: an #AtkEditableText
219 * @position: position to paste
221 * Paste text from clipboard to specified @position.
223 void
224 atk_editable_text_paste_text (AtkEditableText *text,
225 gint position)
227 AtkEditableTextIface *iface;
229 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
231 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
233 if (iface->paste_text)
234 (*(iface->paste_text)) (text, position);