1
<!-- ##### SECTION Title ##### -->
4
<!-- ##### SECTION Short_Description ##### -->
5
Interface for text-editing widgets
7
<!-- ##### SECTION Long_Description ##### -->
9
The #GtkEditable interface is an interface which should be implemented by
10
text editing widgets, such as #GtkEntry and #GtkText. It contains functions
11
for generically manipulating an editable widget, a large number of action
12
signals used for key bindings, and several signals that an application can
13
connect to to modify the behavior of a widget.
17
As an example of the latter usage, by connecting
18
the following handler to "insert_text", an application
19
can convert all entry into a widget into uppercase.
22
<title>Forcing entry to uppercase.</title>
24
#include <ctype.h>
27
insert_text_handler (GtkEditable *editable,
34
gchar *result = g_utf8_strup (text, length);
36
g_signal_handlers_block_by_func (editable,
37
(gpointer) insert_text_handler, data);
38
gtk_editable_insert_text (editable, result, length, position);
39
g_signal_handlers_unblock_by_func (editable,
40
(gpointer) insert_text_handler, data);
42
g_signal_stop_emission_by_name (editable, "insert_text");
50
<!-- ##### SECTION See_Also ##### -->
55
<!-- ##### SECTION Stability_Level ##### -->
58
<!-- ##### STRUCT GtkEditable ##### -->
60
The #GtkEditable structure contains the following fields.
61
(These fields should be considered read-only. They should
62
never be set by an application.)
64
<informaltable pgwide="1" frame="none" role="struct">
65
<tgroup cols="2"><colspec colwidth="2*"/><colspec colwidth="8*"/>
69
<entry>#guint selection_start;</entry>
70
<entry>the starting position of the selected characters
71
in the widget.</entry>
75
<entry>#guint selection_end;</entry>
76
<entry>the end position of the selected characters
77
in the widget.</entry>
81
<entry>#guint editable;</entry>
82
<entry>a flag indicating whether or not the widget is
83
editable by the user.</entry>
86
</tbody></tgroup></informaltable>
90
<!-- ##### SIGNAL GtkEditable::changed ##### -->
92
Indicates that the user has changed the contents
96
@editable: the object which received the signal.
98
<!-- ##### SIGNAL GtkEditable::delete-text ##### -->
100
This signal is emitted when text is deleted from
101
the widget by the user. The default handler for
102
this signal will normally be responsible for inserting
103
the text, so by connecting to this signal and then
104
stopping the signal with gtk_signal_emit_stop(), it
105
is possible to modify the inserted text, or prevent
106
it from being inserted entirely. The @start_pos
107
and @end_pos parameters are interpreted as for
108
gtk_editable_delete_text()
111
@editable: the object which received the signal.
112
@start_pos: the starting position.
113
@end_pos: the end position.
115
<!-- ##### SIGNAL GtkEditable::insert-text ##### -->
117
This signal is emitted when text is inserted into
118
the widget by the user. The default handler for
119
this signal will normally be responsible for inserting
120
the text, so by connecting to this signal and then
121
stopping the signal with gtk_signal_emit_stop(), it
122
is possible to modify the inserted text, or prevent
123
it from being inserted entirely.
126
@editable: the object which received the signal.
127
@new_text: the new text to insert.
128
@new_text_length: the length of the new text, in bytes,
129
or -1 if new_text is nul-terminated
130
@position: the position, in characters, at which to insert
131
the new text. this is an in-out parameter.
132
After the signal emission is finished, it should
133
point after the newly inserted text.
135
<!-- ##### FUNCTION gtk_editable_select_region ##### -->
137
Selects a region of text. The characters that
138
are selected are those characters at positions from
139
@start_pos up to, but not including @end_pos. If
140
@end_pos is negative, then the the characters selected
141
will be those characters from @start_pos to the end
145
@editable: a #GtkEditable widget.
146
@start: the starting position.
147
@end: the end position.
150
<!-- ##### FUNCTION gtk_editable_get_selection_bounds ##### -->
152
Gets the current selection bounds, if there is a selection.
155
@editable: a #GtkEditable widget.
156
@start: location to store the starting position, or %NULL.
157
@end: location to store the end position, or %NULL.
158
@Returns: %TRUE if there is a selection.
161
<!-- ##### FUNCTION gtk_editable_insert_text ##### -->
163
Inserts text at a given position.
166
@editable: a #GtkEditable widget.
167
@new_text: the text to insert.
168
@new_text_length: the length of the text to insert, in bytes
169
@position: an inout parameter. The caller initializes it to
170
the position at which to insert the text. After the
171
call it points at the position after the newly
175
<!-- ##### FUNCTION gtk_editable_delete_text ##### -->
177
Deletes a sequence of characters. The characters that
178
are deleted are those characters at positions from
179
@start_pos up to, but not including @end_pos. If
180
@end_pos is negative, then the the characters deleted
181
will be those characters from @start_pos to the end
185
@editable: a #GtkEditable widget.
186
@start_pos: the starting position.
187
@end_pos: the end position.
190
<!-- ##### FUNCTION gtk_editable_get_chars ##### -->
192
Retrieves a sequence of characters. The characters that
193
are retrieved are those characters at positions from
194
@start_pos up to, but not including @end_pos. If
195
@end_pos is negative, then the the characters retrieved
196
will be those characters from @start_pos to the end
200
@editable: a #GtkEditable widget.
201
@start_pos: the starting position.
202
@end_pos: the end position.
203
@Returns: the characters in the indicated region.
204
The result must be freed with g_free() when
205
the application is finished with it.
208
<!-- ##### FUNCTION gtk_editable_cut_clipboard ##### -->
210
Causes the characters in the current selection to
211
be copied to the clipboard and then deleted from
215
@editable: a #GtkEditable widget.
218
<!-- ##### FUNCTION gtk_editable_copy_clipboard ##### -->
220
Causes the characters in the current selection to
221
be copied to the clipboard.
224
@editable: a #GtkEditable widget.
227
<!-- ##### FUNCTION gtk_editable_paste_clipboard ##### -->
229
Causes the contents of the clipboard to be pasted into
230
the given widget at the current cursor position.
233
@editable: a #GtkEditable widget.
236
<!-- ##### FUNCTION gtk_editable_delete_selection ##### -->
238
Deletes the current contents of the widgets selection and
239
disclaims the selection.
242
@editable: a #GtkEditable widget.
245
<!-- ##### FUNCTION gtk_editable_set_position ##### -->
247
Sets the cursor position.
250
@editable: a #GtkEditable widget.
251
@position: the position of the cursor. The cursor is displayed
252
before the character with the given (base 0) index
253
in the widget. The value must be less than or
254
equal to the number of characters in the widget.
255
A value of -1 indicates that the position should
256
be set after the last character in the entry.
257
Note that this position is in characters, not in
261
<!-- ##### FUNCTION gtk_editable_get_position ##### -->
263
Retrieves the current cursor position.
266
@editable: a #GtkEditable widget.
267
@Returns: the position of the cursor. The cursor is displayed
268
before the character with the given (base 0) index
269
in the widget. The value will be less than or
270
equal to the number of characters in the widget.
271
Note that this position is in characters, not in
275
<!-- ##### FUNCTION gtk_editable_set_editable ##### -->
277
Determines if the user can edit the text in the editable
281
@editable: a #GtkEditable widget.
282
@is_editable: %TRUE if the user is allowed to edit the text
286
<!-- ##### FUNCTION gtk_editable_get_editable ##### -->