IMContext
open class IMContext : GLibObject.Object, IMContextProtocol
GtkIMContext
defines the interface for GTK+ input methods. An input method
is used by GTK+ text input widgets like GtkEntry
to map from key events to
Unicode character strings.
The default input method can be set programmatically via the
GtkSettings:gtk-im-module
GtkSettings property. Alternatively, you may set
the GTK_IM_MODULE environment variable as documented in
Running GTK+ Applications.
The GtkEntry
GtkEntry:im-module
and GtkTextView
GtkTextView:im-module
properties may also be used to set input methods for specific widget
instances. For instance, a certain entry widget might be expected to contain
certain characters which would be easier to input with a certain input
method.
An input method may consume multiple key events in sequence and finally output the composed result. This is called preediting, and an input method may provide feedback about this process by displaying the intermediate composition states as preedit text. For instance, the default GTK+ input method implements the input of arbitrary Unicode code points by holding down the Control and Shift keys and then typing “U” followed by the hexadecimal digits of the code point. When releasing the Control and Shift keys, preediting ends and the character is inserted as text. Ctrl+Shift+u20AC for example results in the € sign.
Additional input methods can be made available for use by GTK+ widgets as
loadable modules. An input method module is a small shared library which
implements a subclass of GtkIMContext
or GtkIMContextSimple
and exports
these four functions:
(C Language Example):
void im_module_init(GTypeModule *module);
This function should register the GType
of the GtkIMContext
subclass which
implements the input method by means of g_type_module_register_type()
. Note
that g_type_register_static()
cannot be used as the type needs to be
registered dynamically.
(C Language Example):
void im_module_exit(void);
Here goes any cleanup code your input method might require on module unload.
(C Language Example):
void im_module_list(const GtkIMContextInfo ***contexts, int *n_contexts)
{
*contexts = info_list;
*n_contexts = G_N_ELEMENTS (info_list);
}
This function returns the list of input methods provided by the module. The
example implementation above shows a common solution and simply returns a
pointer to statically defined array of GtkIMContextInfo
items for each
provided input method.
(C Language Example):
GtkIMContext * im_module_create(const gchar *context_id);
This function should return a pointer to a newly created instance of the
GtkIMContext
subclass identified by context_id
. The context ID is the same
as specified in the GtkIMContextInfo
array returned by im_module_list()
.
After a new loadable input method module has been installed on the system,
the configuration file gtk.immodules
needs to be
regenerated by gtk-query-immodules-3.0,
in order for the new input method to become available to GTK+ applications.
The IMContext
type acts as a reference-counted owner of an underlying GtkIMContext
instance.
It provides the methods that can operate on this data type through IMContextProtocol
conformance.
Use IMContext
as a strong reference or owner of a GtkIMContext
instance.
-
Designated initialiser from the underlying `C` data type.
This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
IMContext
instance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkIMContext>)
Parameters
op
pointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theIMContext
instance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkIMContext>)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a non-mutating
gpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theIMContext
instance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)
Parameters
op
gpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theIMContext
instance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theIMContext
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkIMContext>?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theIMContext
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkIMContext>?)
Parameters
op
pointer to the underlying object
-
Designated initialiser from the underlying
C
data type. Will retainGtkIMContext
. i.e., ownership is transferred to theIMContext
instance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkIMContext>)
Parameters
op
pointer to the underlying object
-
Reference intialiser for a related type that implements
IMContextProtocol
Will retainGtkIMContext
.Declaration
Swift
@inlinable public init<T>(iMContext other: T) where T : IMContextProtocol
Parameters
other
an instance of a related type that implements
IMContextProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
IMContextProtocol
.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
IMContextProtocol
.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
IMContextProtocol
.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)
Parameters
p
raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
IMContextProtocol
.Declaration
Swift
@inlinable override public init(retainingRaw raw: UnsafeRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
IMContextProtocol
.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)
Parameters
p
mutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
IMContextProtocol
.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)
Parameters
raw
mutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
IMContextProtocol
.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
IMContextProtocol
.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object