Package: gtk

Interface gtk-editable

Superclasses

g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

Direct Slots

None

Details

The gtk-editable interface is an interface which should be implemented by text editing widgets, such as gtk-entry and gtk-spin-button. It contains functions for generically manipulating an editable widget, a large number of action signals used for key bindings, and several signals that an application can connect to to modify the behavior of a widget.

Example

As an example of the latter usage, by connecting the following handler to "insert-text", an application can convert all entry into a widget into uppercase.

Forcing entry to uppercase.
 #include <ctype.h>

void insert_text_handler (GtkEditable *editable, const gchar *text, gint length, gint *position, gpointer data) { gchar *result = g_utf8_strup (text, length);

g_signal_handlers_block_by_func (editable, (gpointer) insert_text_handler, data); gtk_editable_insert_text (editable, result, length, position); g_signal_handlers_unblock_by_func (editable, (gpointer) insert_text_handler, data);

g_signal_stop_emission_by_name (editable, "insert_text");

g_free (result); }

Signal Details

The "changed" signal
 lambda (editable)    : Run Last      
The "changed" signal is emitted at the end of a single user visible operation on the contents of the gtk-editable.

E.g., a paste operation that replaces the contents of the selection will cause only one signal emission, even though it is implemented by first deleting the selection, then inserting the new content, and may cause multiple "notify::text" signals to be emitted.
editable
The gtk-editable widget which received the signal.
The "delete-text" signal
 lambda (editable start end)    :run-last      
The signal is emitted when text is deleted from the widget by the user. The default handler for this signal will normally be responsible for deleting the text, so by connecting to this signal and then stopping the signal with the g-signal-stop-emission function, it is possible to modify the range of deleted text, or prevent it from being deleted entirely. The start and end parameters are interpreted as for the gtk-editable-delete-text function.
editable
The gtk-editable widget which received the signal.
start
An integer with the starting position.
end
An integer with the end position.
The "insert-text" signal
 lambda (editable text length position)    :run-last      
The signal is emitted when text is inserted into the widget by the user. The default handler for this signal will normally be responsible for inserting the text, so by connecting to this signal and then stopping the signal with the g-signal-stop-emission function, it is possible to modify the inserted text, or prevent it from being inserted entirely.
editable
The gtk-editable widget which received the signal.
text
A string with the new text to insert.
length
An integer with the length of the new text, in bytes, or -1 if text is nul-terminated.
position
A pointer to the position, in characters, at which to insert the new text. This is an in-out parameter. After the signal emission is finished, it should point after the newly inserted text.
 

Inherited Slot Access Functions

See also

2020-6-1