Fix most compiler warnings and various miscellaneous problems
[platform/upstream/at-spi2-core.git] / atspi / atspi-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 "atspi-private.h"
25
26 #if 0
27 /* TODO: implement */
28 /**
29  * atspi_editable_text_set_attributes:
30  * @obj: a pointer to the #AtspiEditableText object to modify.
31  * @attributes: a character string indicating the attributes to apply to the range,
32  *        delimited by ':'.
33  * @startOffset: a #long indicating the start of the desired text range.
34  * @endOffset: a #long indicating the first character past the desired range.
35  *
36  * Set the attributes applied to a range of text from an #AtspiEditableText
37  *          object, and the bounds of the range.
38  *
39  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
40  **/
41 gboolean
42 atspi_editable_text_set_attributes (AtspiEditableText *obj,
43                                     const char *attributes,
44                                     gint start_pos,
45                                     gint end_pos,
46                                     GError **error
47 {
48   dbus_int32_t d_start_pos = start_pos, d_end_pos = end_pos;
49   dbus_bool_t retval;
50
51   cspi_return_val_if_fail (obj != NULL, FALSE);
52
53   _atspi_dbus_call (obj, atspi_interface_editable_text, "SetAttributes", error, "sii=>b", attributes, d_start_pos, d_end_pos, &retval);
54
55   return retval;
56 }
57 #endif
58
59 /**
60  * atspi_editable_text_set_text_contents:
61  * @obj: a pointer to the #AtspiEditableText object to modify.
62  * @new_contents: a character string, encoded in UTF-8, which is to
63  *      become the new text contents of the #AtspiEditableText object.
64  *
65  * Replace the entire text contents of an #AtspiEditableText object.
66  *
67  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
68  **/
69 gboolean
70 atspi_editable_text_set_text_contents (AtspiEditableText *obj,
71                                        const gchar *new_contents,
72                                        GError **error)
73 {
74   dbus_bool_t retval = FALSE;
75
76   g_return_val_if_fail (obj != NULL, FALSE);
77
78   _atspi_dbus_call (obj, atspi_interface_editable_text, "SetTextContents", error, "s=>b", new_contents, &retval);
79
80   return retval;
81 }
82
83 /**
84  * atspi_editable_text_insert_text:
85  * @obj: a pointer to the #AtspiEditableText object to modify.
86  * @position: an integer indicating the character offset at which to insert
87  *       the new text.  
88  * @text: a gchar* pointer to the text to insert, in UTF-8 encoding.
89  * @length: (frankly I'm not sure this parameter should be here)
90  *
91  * Insert text into an #AtspiEditableText object.
92  * As with all character offsets, the specified @position may not be the
93  *       same as the resulting byte offset, since the text is in a
94  *       variable-width encoding.
95  *
96  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
97  **/
98 gboolean
99 atspi_editable_text_insert_text (AtspiEditableText *obj,
100                                  gint position,
101                                  const gchar *text,
102                                  gint length,
103                                  GError **error)
104 {
105   dbus_int32_t d_position = position, d_length = length;
106   dbus_bool_t retval = FALSE;
107
108   g_return_val_if_fail (obj != NULL, FALSE);
109
110   _atspi_dbus_call (obj, atspi_interface_editable_text, "InsertText", error, "isi=>b", d_position, text, d_length, &retval);
111
112   return retval;
113 }
114
115 /**
116  * atspi_editable_text_copy_text:
117  * @obj: a pointer to the #AtspiEditableText object to modify.
118  * @start_pos: an integer indicating the starting character offset
119  *       of the text to copy.
120  * @end_pos: an integer indicating the offset of the first character
121  *       past the end of the text section to be copied.
122  *
123  * Copy text from an #AtspiEditableText object into the clipboard.
124  *
125  * see: atspi_editable_text_paste_text 
126  *
127  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
128  **/
129 gboolean
130 atspi_editable_text_copy_text (AtspiEditableText *obj,
131                                gint start_pos,
132                                gint end_pos,
133                                GError **error)
134 {
135   dbus_int32_t d_start_pos = start_pos, d_end_pos = end_pos;
136
137   g_return_val_if_fail (obj != NULL, FALSE);
138
139   _atspi_dbus_call (obj, atspi_interface_editable_text, "CopyText", error, "ii", d_start_pos, d_end_pos);
140
141   return TRUE;
142 }
143
144 /**
145  * atspi_editable_text_cut_text:
146  * @obj: a pointer to the #AtspiEditableText object to modify.
147  * @start_pos: an integer indicating the starting character offset
148  *       of the text to cut.
149  * @end_pos: an integer indicating the offset of the first character
150  *       past the end of the text section to be cut.
151  *
152  * Delete text from an #AtspiEditableText object, copying the
153  *       excised portion into the clipboard.
154  *
155  * see: atspi_editable_text_paste_text
156  *
157  * Returns: #TRUE if operation was successful, #FALSE otherwise.
158  **/
159 gboolean
160 atspi_editable_text_cut_text (AtspiEditableText *obj,
161                               gint start_pos,
162                               gint end_pos,
163                               GError **error)
164 {
165   dbus_int32_t d_start_pos = start_pos, d_end_pos = end_pos;
166   dbus_bool_t retval = FALSE;
167
168   g_return_val_if_fail (obj != NULL, FALSE);
169
170   _atspi_dbus_call (obj, atspi_interface_editable_text, "CutText", error, "ii=>b", d_start_pos, d_end_pos, &retval);
171
172   return retval;
173 }
174
175 /**
176  * atspi_editable_text_delete_text:
177  * @obj: a pointer to the #AtspiEditableText object to modify.
178  * @start_pos: an integer indicating the starting character offset
179  *       of the text to delete.
180  * @end_pos: an integer indicating the offset of the first character
181  *       past the end of the text section to be deleted.
182  *
183  * Delete text from an #AtspiEditableText object, without copying the
184  *       excised portion into the clipboard.
185  *
186  * see: atspi_editable_text_cut_text
187  *
188  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
189  **/
190 gboolean
191 atspi_editable_text_delete_text (AtspiEditableText *obj,
192                                  gint start_pos,
193                                  gint end_pos,
194                                  GError **error)
195 {
196   dbus_int32_t d_start_pos = start_pos, d_end_pos = end_pos;
197   dbus_bool_t retval = FALSE;
198
199   g_return_val_if_fail (obj != NULL, FALSE);
200
201   _atspi_dbus_call (obj, atspi_interface_editable_text, "DeleteText", error, "ii=>b", d_start_pos, d_end_pos, &retval);
202
203   return retval;
204 }
205
206 /**
207  * atspi_editable_text_paste_text:
208  * @obj: a pointer to the #AtspiEditableText object to modify.
209  * @position: an integer indicating the character offset at which to insert
210  *       the new text.  
211  *
212  * Insert text from the clipboard into an #AtspiEditableText object.
213  * As with all character offsets, the specified @position may not be the
214  *       same as the resulting byte offset, since the text is in a
215  *       variable-width encoding.
216  *
217  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
218  **/
219 gboolean
220 atspi_editable_text_paste_text (AtspiEditableText *obj,
221                                 gint position,
222                                 GError **error)
223 {
224   dbus_int32_t d_position = position;
225   dbus_bool_t retval = FALSE;
226
227   g_return_val_if_fail (obj != NULL, FALSE);
228
229   _atspi_dbus_call (obj, atspi_interface_editable_text, "PasteText", error, "i=>b", d_position, &retval);
230
231   return retval;
232 }
233
234 static void
235 atspi_editable_text_base_init (AtspiEditableText *klass)
236 {
237 }
238
239 GType
240 atspi_editable_text_get_type (void)
241 {
242   static GType type = 0;
243
244   if (!type) {
245     static const GTypeInfo tinfo =
246     {
247       sizeof (AtspiEditableText),
248       (GBaseInitFunc) atspi_editable_text_base_init,
249       (GBaseFinalizeFunc) NULL,
250     };
251
252     type = g_type_register_static (G_TYPE_INTERFACE, "AtspiEditableText", &tinfo, 0);
253
254   }
255   return type;
256 }