Typical examples of editable widgets are gtk.entry.Entry and
gtk.spin_button.SpinButton. 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 modify the behavior
of a widget.
As an example of the latter usage, by connecting the following handler to
signal@Gtk.Editable::insert-text, an application can convert all entry
into a widget into uppercase.
The most likely scenario for implementing gtk.editable.Editable on your own widget
is that you will embed a gtk.text.Text inside a complex widget, and want to
delegate the editable functionality to that text widget. gtk.editable.Editable
provides some utility functions to make this easy.
In your interface_init function for the gtk.editable.Editable interface, provide
an implementation for the get_delegate vfunc that returns your text widget:
You don't need to provide any other vfuncs. The default implementations
work by forwarding to the delegate that the GtkEditableInterface.get_delegate()
vfunc returns.
It is important to note that if you create a gtk.editable.Editable that uses
a delegate, the low level signal@Gtk.Editable::insert-text and
signal@Gtk.Editable::delete-text signals will be propagated from the
"wrapper" editable to the delegate, but they will not be propagated from
the delegate to the "wrapper" editable, as they would cause an infinite
recursion. If you wish to connect to the signal@Gtk.Editable::insert-text
and signal@Gtk.Editable::delete-text signals, you will need to connect
to them on the delegate obtained via gtk.editable.Editable.getDelegate.
gtk.editable.Editable is an interface for text editing widgets.
Typical examples of editable widgets are gtk.entry.Entry and gtk.spin_button.SpinButton. 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 modify the behavior of a widget.
As an example of the latter usage, by connecting the following handler to signal@Gtk.Editable::insert-text, an application can convert all entry into a widget into uppercase.
Forcing entry to uppercase.
Implementing GtkEditable
The most likely scenario for implementing gtk.editable.Editable on your own widget is that you will embed a gtk.text.Text inside a complex widget, and want to delegate the editable functionality to that text widget. gtk.editable.Editable provides some utility functions to make this easy.
In your class_init function, call gtk.editable.Editable.installProperties, passing the first available property ID:
In your interface_init function for the gtk.editable.Editable interface, provide an implementation for the get_delegate vfunc that returns your text widget:
You don't need to provide any other vfuncs. The default implementations work by forwarding to the delegate that the GtkEditableInterface.get_delegate() vfunc returns.
In your instance_init function, create your text widget, and then call gtk.editable.Editable.initDelegate:
In your dispose function, call gtk.editable.Editable.finishDelegate before destroying your text widget:
Finally, use gtk.editable.Editable.delegateSetProperty in your set_property function (and similar for get_property), to set the editable properties:
It is important to note that if you create a gtk.editable.Editable that uses a delegate, the low level signal@Gtk.Editable::insert-text and signal@Gtk.Editable::delete-text signals will be propagated from the "wrapper" editable to the delegate, but they will not be propagated from the delegate to the "wrapper" editable, as they would cause an infinite recursion. If you wish to connect to the signal@Gtk.Editable::insert-text and signal@Gtk.Editable::delete-text signals, you will need to connect to them on the delegate obtained via gtk.editable.Editable.getDelegate.