Always emit children-changed, property-change, and state-changed events
[platform/core/uifw/at-spi2-atk.git] / cspi / spi-editabletext.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 <cspi/spi-private.h>
25
26 /**
27  * AccessibleEditableText_ref:
28  * @obj: a pointer to the #AccessibleEditableText object on which to operate.
29  *
30  * Increment the reference count for an #AccessibleEditableText object.
31  *       Since AccessibleEditableText is derived from AccessibleText,
32  *       this is the same as AccessibleText_ref().
33  **/
34 void
35 AccessibleEditableText_ref (AccessibleEditableText *obj)
36 {
37   cspi_object_ref (obj);
38 }
39
40 /**
41  * AccessibleEditableText_unref:
42  * @obj: a pointer to the #AccessibleEditableText object on which to operate.
43  *
44  * Decrement the reference count for an #AccessibleEdiitableText object.
45  *       Since AccessibleEditableText is derived from AccessibleText,
46  *       this is the same as AccessibleText_unref().
47  **/
48 void
49 AccessibleEditableText_unref (AccessibleEditableText *obj)
50 {
51   cspi_object_unref (obj);
52 }
53
54 /**
55  * AccessibleEditableText_setAttributes:
56  * @obj: a pointer to the #AccessibleEditableText object to modify.
57  * @attributes: a character string indicating the attributes to apply to the range,
58  *        delimited by ':'.
59  * @startOffset: a #long indicating the start of the desired text range.
60  * @endOffset: a #long indicating the first character past the desired range.
61  *
62  * Set the attributes applied to a range of text from an #AccessibleEditableText
63  *          object, and the bounds of the range.
64  *
65  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
66  **/
67 SPIBoolean
68 AccessibleEditableText_setAttributes (AccessibleEditableText *obj,
69                                       const char *attributes,
70                                       long int startPos,
71                                       long int endPos)
72 {
73   dbus_int32_t d_startPos = startPos, d_endPos = endPos;
74   dbus_bool_t retval;
75
76   cspi_return_val_if_fail (obj != NULL, FALSE);
77
78   cspi_dbus_call (obj, spi_interface_editable_text, "setAttributes", NULL, "sii=>b", attributes, d_startPos, d_endPos, &retval);
79
80   cspi_return_val_if_ev ("setAttributes", FALSE);
81
82   return retval;
83 }
84
85 /**
86  * AccessibleEditableText_setTextContents:
87  * @obj: a pointer to the #AccessibleEditableText object to modify.
88  * @newContents: a character string, encoded in UTF-8, which is to
89  *      become the new text contents of the #AccessibleEditableText object.
90  *
91  * Replace the entire text contents of an #AccessibleEditableText object.
92  *
93  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
94  **/
95 SPIBoolean
96 AccessibleEditableText_setTextContents (AccessibleEditableText *obj,
97                                         const char *newContents)
98 {
99   dbus_bool_t retval;
100
101   cspi_return_val_if_fail (obj != NULL, FALSE);
102
103   cspi_dbus_call (obj, spi_interface_editable_text, "setTextContents", NULL, "s=>b", newContents, &retval);
104
105   cspi_return_val_if_ev ("setTextContents", FALSE);
106
107   return retval;
108 }
109
110 /**
111  * AccessibleEditableText_insertText:
112  * @obj: a pointer to the #AccessibleEditableText object to modify.
113  * @position: an integer indicating the character offset at which to insert
114  *       the new text.  
115  * @text: a char* pointer to the text to insert, in UTF-8 encoding.
116  * @length: (frankly I'm not sure this parameter should be here)
117  *
118  * Insert text into an #AccessibleEditableText object.
119  * As with all character offsets, the specified @position may not be the
120  *       same as the resulting byte offset, since the text is in a
121  *       variable-width encoding.
122  *
123  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
124  **/
125 SPIBoolean
126 AccessibleEditableText_insertText (AccessibleEditableText *obj,
127                                    long int position,
128                                    const char *text,
129                                    long int length)
130 {
131   dbus_int32_t d_position = position, d_length = length;
132   dbus_bool_t retval;
133
134   cspi_return_val_if_fail (obj != NULL, FALSE);
135
136   cspi_dbus_call (obj, spi_interface_editable_text, "insertText", NULL, "isi=>b", d_position, text, d_length, &retval);
137
138   cspi_return_val_if_ev ("insertText", FALSE);
139
140   return retval;
141 }
142
143 /**
144  * AccessibleEditableText_copyText:
145  * @obj: a pointer to the #AccessibleEditableText object to modify.
146  * @startPos: an integer indicating the starting character offset
147  *       of the text to copy.
148  * @endPos: an integer indicating the offset of the first character
149  *       past the end of the text section to be copied.
150  *
151  * Copy text from an #AccessibleEditableText object into the clipboard.
152  *
153  * @see: AccessibleEditableText_pasteText 
154  *
155  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
156  **/
157 SPIBoolean
158 AccessibleEditableText_copyText (AccessibleText *obj,
159                                  long int startPos,
160                                  long int endPos)
161 {
162   dbus_int32_t d_startPos = startPos, d_endPos = endPos;
163
164   cspi_return_val_if_fail (obj != NULL, FALSE);
165
166   cspi_dbus_call (obj, spi_interface_editable_text, "copyText", NULL, "ii", startPos, endPos);
167
168   cspi_return_val_if_ev ("copyText", FALSE);
169
170   return TRUE;
171 }
172
173 /**
174  * AccessibleEditableText_cutText:
175  * @obj: a pointer to the #AccessibleEditableText object to modify.
176  * @startPos: an integer indicating the starting character offset
177  *       of the text to cut.
178  * @endPos: an integer indicating the offset of the first character
179  *       past the end of the text section to be cut.
180  *
181  * Delete text from an #AccessibleEditableText object, copying the
182  *       excised portion into the clipboard.
183  *
184  * @see: AccessibleEditableText_pasteText
185  *
186  * Returns: #TRUE if operation was successful, #FALSE otherwise.
187  **/
188 SPIBoolean
189 AccessibleEditableText_cutText (AccessibleEditableText *obj,
190                                 long int startPos,
191                                 long int endPos)
192 {
193   dbus_int32_t d_startPos = startPos, d_endPos = endPos;
194   dbus_bool_t retval;
195
196   cspi_return_val_if_fail (obj != NULL, FALSE);
197
198   cspi_dbus_call (obj, spi_interface_editable_text, "cutText", NULL, "ii=>b", d_startPos, d_endPos, &retval);
199
200   cspi_return_val_if_ev ("cutText", FALSE);
201
202   return retval;
203 }
204
205 /**
206  * AccessibleEditableText_deleteText:
207  * @obj: a pointer to the #AccessibleEditableText object to modify.
208  * @startPos: an integer indicating the starting character offset
209  *       of the text to delete.
210  * @endPos: an integer indicating the offset of the first character
211  *       past the end of the text section to be deleted.
212  *
213  * Delete text from an #AccessibleEditableText object, without copying the
214  *       excised portion into the clipboard.
215  *
216  * @see: AccessibleEditableText_cutText
217  *
218  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
219  **/
220 SPIBoolean
221 AccessibleEditableText_deleteText (AccessibleEditableText *obj,
222                                    long startPos,
223                                    long endPos)
224 {
225   dbus_int32_t d_startPos = startPos, d_endPos = endPos;
226   dbus_bool_t retval;
227
228   cspi_return_val_if_fail (obj != NULL, FALSE);
229
230   cspi_dbus_call (obj, spi_interface_editable_text, "deleteText", NULL, "ii=>b", d_startPos, d_endPos, &retval);
231
232   cspi_return_val_if_ev ("deleteText", FALSE);
233
234   return retval;
235 }
236
237 /**
238  * AccessibleEditableText_pasteText:
239  * @obj: a pointer to the #AccessibleEditableText object to modify.
240  * @position: an integer indicating the character offset at which to insert
241  *       the new text.  
242  *
243  * Insert text from the clipboard into an #AccessibleEditableText object.
244  * As with all character offsets, the specified @position may not be the
245  *       same as the resulting byte offset, since the text is in a
246  *       variable-width encoding.
247  *
248  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
249  **/
250 SPIBoolean
251 AccessibleEditableText_pasteText (AccessibleEditableText *obj,
252                                   long int position)
253 {
254   dbus_int32_t d_position = position;
255   dbus_bool_t retval;
256
257   cspi_return_val_if_fail (obj != NULL, FALSE);
258
259   cspi_dbus_call (obj, spi_interface_editable_text, "pasteText", NULL, "i=>b", d_position, &retval);
260
261   cspi_return_val_if_ev ("pasteText", FALSE);
262
263   return retval;
264 }