gi-gtk-3.0.24: Gtk bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.IMContext

Contents

Description

IMContext defines the interface for GTK+ input methods. An input method is used by GTK+ text input widgets like Entry to map from key events to Unicode character strings.

The default input method can be set programmatically via the Settings:gtk-im-module GtkSettings property. Alternatively, you may set the GTK_IM_MODULE environment variable as documented in [Running GTK+ Applications][gtk-running].

The Entry Entry:im-module and TextView TextView: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 IMContext or IMContextSimple and exports these four functions:

C code

void im_module_init(GTypeModule *module);

This function should register the GType of the IMContext subclass which implements the input method by means of typeModuleRegisterType. Note that typeRegisterStatic cannot be used as the type needs to be registered dynamically.

C code

void im_module_exit(void);

Here goes any cleanup code your input method might require on module unload.

C code

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 IMContextInfo items for each provided input method.

C code

GtkIMContext * im_module_create(const gchar *context_id);

This function should return a pointer to a newly created instance of the IMContext subclass identified by contextId. The context ID is the same as specified in the IMContextInfo 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][gtk-query-immodules-3.0], in order for the new input method to become available to GTK+ applications.

Synopsis

Exported types

newtype IMContext Source #

Memory-managed wrapper type.

Instances
GObject IMContext Source # 
Instance details

Defined in GI.Gtk.Objects.IMContext

IsObject IMContext Source # 
Instance details

Defined in GI.Gtk.Objects.IMContext

IsIMContext IMContext Source # 
Instance details

Defined in GI.Gtk.Objects.IMContext

class GObject o => IsIMContext o Source #

Type class for types which can be safely cast to IMContext, for instance with toIMContext.

toIMContext :: (MonadIO m, IsIMContext o) => o -> m IMContext Source #

Cast to IMContext, for types for which this is known to be safe. For general casts, use castTo.

noIMContext :: Maybe IMContext Source #

A convenience alias for Nothing :: Maybe IMContext.

Methods

deleteSurrounding

iMContextDeleteSurrounding Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a) 
=> a

context: a IMContext

-> Int32

offset: offset from cursor position in chars; a negative value means start before the cursor.

-> Int32

nChars: number of characters to delete.

-> m Bool

Returns: True if the signal was handled.

Asks the widget that the input context is attached to to delete characters around the cursor position by emitting the GtkIMContext::delete_surrounding signal. Note that offset and nChars are in characters not in bytes which differs from the usage other places in IMContext.

In order to use this function, you should first call iMContextGetSurrounding to get the current context, and call this function immediately afterwards to make sure that you know what you are deleting. You should also account for the fact that even if the signal was handled, the input context might not have deleted all the characters that were requested to be deleted.

This function is used by an input method that wants to make subsitutions in the existing text in response to new input. It is not useful for applications.

filterKeypress

iMContextFilterKeypress Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a) 
=> a

context: a IMContext

-> EventKey

event: the key event

-> m Bool

Returns: True if the input method handled the key event.

Allow an input method to internally handle key press and release events. If this function returns True, then no further processing should be done for this key event.

focusIn

iMContextFocusIn Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a) 
=> a

context: a IMContext

-> m () 

Notify the input method that the widget to which this input context corresponds has gained focus. The input method may, for example, change the displayed feedback to reflect this change.

focusOut

iMContextFocusOut Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a) 
=> a

context: a IMContext

-> m () 

Notify the input method that the widget to which this input context corresponds has lost focus. The input method may, for example, change the displayed feedback or reset the contexts state to reflect this change.

getPreeditString

iMContextGetPreeditString Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a) 
=> a

context: a IMContext

-> m (Text, AttrList, Int32) 

Retrieve the current preedit string for the input context, and a list of attributes to apply to the string. This string should be displayed inserted at the insertion point.

getSurrounding

iMContextGetSurrounding Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a) 
=> a

context: a IMContext

-> m (Bool, Text, Int32)

Returns: True if surrounding text was provided; in this case you must free the result stored in *text.

Retrieves context around the insertion point. Input methods typically want context in order to constrain input text based on existing text; this is important for languages such as Thai where only some sequences of characters are allowed.

This function is implemented by emitting the GtkIMContext::retrieve_surrounding signal on the input method; in response to this signal, a widget should provide as much context as is available, up to an entire paragraph, by calling iMContextSetSurrounding. Note that there is no obligation for a widget to respond to the ::retrieve_surrounding signal, so input methods must be prepared to function without context.

reset

iMContextReset Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a) 
=> a

context: a IMContext

-> m () 

Notify the input method that a change such as a change in cursor position has been made. This will typically cause the input method to clear the preedit state.

setClientWindow

iMContextSetClientWindow Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a, IsWindow b) 
=> a

context: a IMContext

-> Maybe b

window: the client window. This may be Nothing to indicate that the previous client window no longer exists.

-> m () 

Set the client window for the input context; this is the Window in which the input appears. This window is used in order to correctly position status windows, and may also be used for purposes internal to the input method.

setCursorLocation

iMContextSetCursorLocation Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a) 
=> a

context: a IMContext

-> Rectangle

area: new location

-> m () 

Notify the input method that a change in cursor position has been made. The location is relative to the client window.

setSurrounding

iMContextSetSurrounding Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a) 
=> a

context: a IMContext

-> Text

text: text surrounding the insertion point, as UTF-8. the preedit string should not be included within text.

-> Int32

len: the length of text, or -1 if text is nul-terminated

-> Int32

cursorIndex: the byte index of the insertion cursor within text.

-> m () 

Sets surrounding context around the insertion point and preedit string. This function is expected to be called in response to the GtkIMContext::retrieve_surrounding signal, and will likely have no effect if called at other times.

setUsePreedit

iMContextSetUsePreedit Source #

Arguments

:: (HasCallStack, MonadIO m, IsIMContext a) 
=> a

context: a IMContext

-> Bool

usePreedit: whether the IM context should use the preedit string.

-> m () 

Sets whether the IM context should use the preedit string to display feedback. If usePreedit is FALSE (default is TRUE), then the IM context may use some other method to display feedback, such as displaying it in a child of the root window.

Properties

inputHints

No description available in the introspection data.

constructIMContextInputHints :: IsIMContext o => [InputHints] -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “input-hints” property. This is rarely needed directly, but it is used by new.

getIMContextInputHints :: (MonadIO m, IsIMContext o) => o -> m [InputHints] Source #

Get the value of the “input-hints” property. When overloading is enabled, this is equivalent to

get iMContext #inputHints

setIMContextInputHints :: (MonadIO m, IsIMContext o) => o -> [InputHints] -> m () Source #

Set the value of the “input-hints” property. When overloading is enabled, this is equivalent to

set iMContext [ #inputHints := value ]

inputPurpose

No description available in the introspection data.

constructIMContextInputPurpose :: IsIMContext o => InputPurpose -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “input-purpose” property. This is rarely needed directly, but it is used by new.

getIMContextInputPurpose :: (MonadIO m, IsIMContext o) => o -> m InputPurpose Source #

Get the value of the “input-purpose” property. When overloading is enabled, this is equivalent to

get iMContext #inputPurpose

setIMContextInputPurpose :: (MonadIO m, IsIMContext o) => o -> InputPurpose -> m () Source #

Set the value of the “input-purpose” property. When overloading is enabled, this is equivalent to

set iMContext [ #inputPurpose := value ]

Signals

commit

type C_IMContextCommitCallback = Ptr () -> CString -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type IMContextCommitCallback Source #

Arguments

 = Text

str: the completed character(s) entered by the user

-> IO () 

The ::commit signal is emitted when a complete input sequence has been entered by the user. This can be a single character immediately after a key press or the final result of preediting.

afterIMContextCommit :: (IsIMContext a, MonadIO m) => a -> IMContextCommitCallback -> m SignalHandlerId Source #

Connect a signal handler for the “commit” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after iMContext #commit callback

onIMContextCommit :: (IsIMContext a, MonadIO m) => a -> IMContextCommitCallback -> m SignalHandlerId Source #

Connect a signal handler for the “commit” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on iMContext #commit callback

deleteSurrounding

type C_IMContextDeleteSurroundingCallback = Ptr () -> Int32 -> Int32 -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

type IMContextDeleteSurroundingCallback Source #

Arguments

 = Int32

offset: the character offset from the cursor position of the text to be deleted. A negative value indicates a position before the cursor.

-> Int32

nChars: the number of characters to be deleted

-> IO Bool

Returns: True if the signal was handled.

The ::delete-surrounding signal is emitted when the input method needs to delete all or part of the context surrounding the cursor.

afterIMContextDeleteSurrounding :: (IsIMContext a, MonadIO m) => a -> IMContextDeleteSurroundingCallback -> m SignalHandlerId Source #

Connect a signal handler for the “delete-surrounding” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after iMContext #deleteSurrounding callback

onIMContextDeleteSurrounding :: (IsIMContext a, MonadIO m) => a -> IMContextDeleteSurroundingCallback -> m SignalHandlerId Source #

Connect a signal handler for the “delete-surrounding” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on iMContext #deleteSurrounding callback

preeditChanged

type C_IMContextPreeditChangedCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type IMContextPreeditChangedCallback = IO () Source #

The ::preedit-changed signal is emitted whenever the preedit sequence currently being entered has changed. It is also emitted at the end of a preedit sequence, in which case iMContextGetPreeditString returns the empty string.

afterIMContextPreeditChanged :: (IsIMContext a, MonadIO m) => a -> IMContextPreeditChangedCallback -> m SignalHandlerId Source #

Connect a signal handler for the “preedit-changed” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after iMContext #preeditChanged callback

onIMContextPreeditChanged :: (IsIMContext a, MonadIO m) => a -> IMContextPreeditChangedCallback -> m SignalHandlerId Source #

Connect a signal handler for the “preedit-changed” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on iMContext #preeditChanged callback

preeditEnd

type C_IMContextPreeditEndCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type IMContextPreeditEndCallback = IO () Source #

The ::preedit-end signal is emitted when a preediting sequence has been completed or canceled.

afterIMContextPreeditEnd :: (IsIMContext a, MonadIO m) => a -> IMContextPreeditEndCallback -> m SignalHandlerId Source #

Connect a signal handler for the “preedit-end” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after iMContext #preeditEnd callback

onIMContextPreeditEnd :: (IsIMContext a, MonadIO m) => a -> IMContextPreeditEndCallback -> m SignalHandlerId Source #

Connect a signal handler for the “preedit-end” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on iMContext #preeditEnd callback

preeditStart

type C_IMContextPreeditStartCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type IMContextPreeditStartCallback = IO () Source #

The ::preedit-start signal is emitted when a new preediting sequence starts.

afterIMContextPreeditStart :: (IsIMContext a, MonadIO m) => a -> IMContextPreeditStartCallback -> m SignalHandlerId Source #

Connect a signal handler for the “preedit-start” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after iMContext #preeditStart callback

onIMContextPreeditStart :: (IsIMContext a, MonadIO m) => a -> IMContextPreeditStartCallback -> m SignalHandlerId Source #

Connect a signal handler for the “preedit-start” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on iMContext #preeditStart callback

retrieveSurrounding

type C_IMContextRetrieveSurroundingCallback = Ptr () -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

type IMContextRetrieveSurroundingCallback Source #

Arguments

 = IO Bool

Returns: True if the signal was handled.

The ::retrieve-surrounding signal is emitted when the input method requires the context surrounding the cursor. The callback should set the input method surrounding context by calling the iMContextSetSurrounding method.

afterIMContextRetrieveSurrounding :: (IsIMContext a, MonadIO m) => a -> IMContextRetrieveSurroundingCallback -> m SignalHandlerId Source #

Connect a signal handler for the “retrieve-surrounding” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after iMContext #retrieveSurrounding callback

onIMContextRetrieveSurrounding :: (IsIMContext a, MonadIO m) => a -> IMContextRetrieveSurroundingCallback -> m SignalHandlerId Source #

Connect a signal handler for the “retrieve-surrounding” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on iMContext #retrieveSurrounding callback