Version 0.7
[atk.git] / atk / atkeditabletext.c
blob92360c1ca78d0b064c59340cc7370979b02ec797
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"
23 GType
24 atk_editable_text_get_type ()
26 static GType type = 0;
28 if (!type) {
29 static const GTypeInfo tinfo =
31 sizeof (AtkEditableTextIface),
32 (GBaseInitFunc) NULL,
33 (GBaseFinalizeFunc) NULL,
37 type = g_type_register_static (G_TYPE_INTERFACE, "AtkEditableText", &tinfo, 0);
40 return type;
43 /**
44 *atk_editable_text_set_run_attributes:
45 *@text: an #AtkEditableText
46 *@attrib_set: an #AtkAttributeSet
47 *@start_offset: start of range in which to set attributes
48 *@end_offset: end of range in which to set attributes
50 *Sets the attributes for a specified range. See the ATK_ATTRIBUTE
51 *macros (such as #ATK_ATTRIBUTE_LEFT_MARGIN) for examples of attributes
52 *that can be set. Note that other attributes that do not have corresponding
53 *ATK_ATTRIBUTE macros may also be set for certain text widgets.
55 *Returns: %TRUE if attributes successfully set for the specified
56 *range, otherwise %FALSE
57 **/
58 gboolean
59 atk_editable_text_set_run_attributes (AtkEditableText *text,
60 AtkAttributeSet *attrib_set,
61 gint start_offset,
62 gint end_offset)
64 AtkEditableTextIface *iface;
66 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (text), FALSE);
68 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
70 if (iface->set_run_attributes)
72 return (*(iface->set_run_attributes)) (text, attrib_set, start_offset, end_offset);
74 else
76 return FALSE;
81 /**
82 * atk_editable_text_set_text_contents:
83 * @text: an #AtkEditableText
84 * @string: string to set for text contents of @text
86 * Set text contents of @text.
87 **/
88 void
89 atk_editable_text_set_text_contents (AtkEditableText *text,
90 const gchar *string)
92 AtkEditableTextIface *iface;
94 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
96 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
98 if (iface->set_text_contents)
99 (*(iface->set_text_contents)) (text, string);
103 * atk_editable_text_insert_text:
104 * @text: an #AtkEditableText
105 * @string: the text to insert
106 * @length: the length of text to insert, in bytes
107 * @position: The caller initializes this to
108 * the position at which to insert the text. After the call it
109 * points at the position after the newly inserted text.
111 * Insert text at a given position.
113 void
114 atk_editable_text_insert_text (AtkEditableText *text,
115 const gchar *string,
116 gint length,
117 gint *position)
119 AtkEditableTextIface *iface;
121 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
123 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
125 if (iface->insert_text)
126 (*(iface->insert_text)) (text, string, length, position);
130 * atk_editable_text_copy_text:
131 * @text: an #AtkEditableText
132 * @start_pos: start position
133 * @end_pos: end position
135 * Copy text from @start_pos up to, but not including @end_pos
136 * to the clipboard.
138 void
139 atk_editable_text_copy_text (AtkEditableText *text,
140 gint start_pos,
141 gint end_pos)
143 AtkEditableTextIface *iface;
145 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
147 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
149 if (iface->copy_text)
150 (*(iface->copy_text)) (text, start_pos, end_pos);
154 * atk_editable_text_cut_text:
155 * @text: an #AtkEditableText
156 * @start_pos: start position
157 * @end_pos: end position
159 * Copy text from @start_pos up to, but not including @end_pos
160 * to the clipboard and then delete from the widget.
162 void
163 atk_editable_text_cut_text (AtkEditableText *text,
164 gint start_pos,
165 gint end_pos)
167 AtkEditableTextIface *iface;
169 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
171 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
173 if (iface->cut_text)
174 (*(iface->cut_text)) (text, start_pos, end_pos);
178 * atk_editable_text_delete_text:
179 * @text: an #AtkEditableText
180 * @start_pos: start position
181 * @end_pos: end position
183 * Delete text @start_pos up to, but not including @end_pos.
185 void
186 atk_editable_text_delete_text (AtkEditableText *text,
187 gint start_pos,
188 gint end_pos)
190 AtkEditableTextIface *iface;
192 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
194 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
196 if (iface->delete_text)
197 (*(iface->delete_text)) (text, start_pos, end_pos);
201 * atk_editable_text_paste_text:
202 * @text: an #AtkEditableText
203 * @position: position to paste
205 * Paste text from clipboard to specified @position.
207 void
208 atk_editable_text_paste_text (AtkEditableText *text,
209 gint position)
211 AtkEditableTextIface *iface;
213 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
215 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
217 if (iface->paste_text)
218 (*(iface->paste_text)) (text, position);