gtk/auto/im_context.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{InputHints, InputPurpose};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem, mem::transmute, ptr};
12
13glib::wrapper! {
14 /// [`IMContext`][crate::IMContext] defines the interface for GTK+ input methods. An input method
15 /// is used by GTK+ text input widgets like [`Entry`][crate::Entry] to map from key events to
16 /// Unicode character strings.
17 ///
18 /// The default input method can be set programmatically via the
19 /// [`gtk-im-module`][struct@crate::Settings#gtk-im-module] GtkSettings property. Alternatively, you may set
20 /// the GTK_IM_MODULE environment variable as documented in
21 /// [Running GTK+ Applications][gtk-running].
22 ///
23 /// The [`Entry`][crate::Entry] [`im-module`][struct@crate::Entry#im-module] and [`TextView`][crate::TextView] [`im-module`][struct@crate::TextView#im-module]
24 /// properties may also be used to set input methods for specific widget
25 /// instances. For instance, a certain entry widget might be expected to contain
26 /// certain characters which would be easier to input with a certain input
27 /// method.
28 ///
29 /// An input method may consume multiple key events in sequence and finally
30 /// output the composed result. This is called preediting, and an input method
31 /// may provide feedback about this process by displaying the intermediate
32 /// composition states as preedit text. For instance, the default GTK+ input
33 /// method implements the input of arbitrary Unicode code points by holding down
34 /// the Control and Shift keys and then typing “U” followed by the hexadecimal
35 /// digits of the code point. When releasing the Control and Shift keys,
36 /// preediting ends and the character is inserted as text. Ctrl+Shift+u20AC for
37 /// example results in the € sign.
38 ///
39 /// Additional input methods can be made available for use by GTK+ widgets as
40 /// loadable modules. An input method module is a small shared library which
41 /// implements a subclass of [`IMContext`][crate::IMContext] or [`IMContextSimple`][crate::IMContextSimple] and exports
42 /// these four functions:
43 ///
44 ///
45 ///
46 /// **⚠️ The following code is in C ⚠️**
47 ///
48 /// ```C
49 /// void im_module_init(GTypeModule *module);
50 /// ```
51 /// This function should register the `GType` of the [`IMContext`][crate::IMContext] subclass which
52 /// implements the input method by means of `g_type_module_register_type()`. Note
53 /// that `g_type_register_static()` cannot be used as the type needs to be
54 /// registered dynamically.
55 ///
56 ///
57 ///
58 /// **⚠️ The following code is in C ⚠️**
59 ///
60 /// ```C
61 /// void im_module_exit(void);
62 /// ```
63 /// Here goes any cleanup code your input method might require on module unload.
64 ///
65 ///
66 ///
67 /// **⚠️ The following code is in C ⚠️**
68 ///
69 /// ```C
70 /// void im_module_list(const GtkIMContextInfo ***contexts, int *n_contexts)
71 /// {
72 /// *contexts = info_list;
73 /// *n_contexts = G_N_ELEMENTS (info_list);
74 /// }
75 /// ```
76 /// This function returns the list of input methods provided by the module. The
77 /// example implementation above shows a common solution and simply returns a
78 /// pointer to statically defined array of `GtkIMContextInfo` items for each
79 /// provided input method.
80 ///
81 ///
82 ///
83 /// **⚠️ The following code is in C ⚠️**
84 ///
85 /// ```C
86 /// GtkIMContext * im_module_create(const gchar *context_id);
87 /// ```
88 /// This function should return a pointer to a newly created instance of the
89 /// [`IMContext`][crate::IMContext] subclass identified by `context_id`. The context ID is the same
90 /// as specified in the `GtkIMContextInfo` array returned by `im_module_list()`.
91 ///
92 /// After a new loadable input method module has been installed on the system,
93 /// the configuration file `gtk.immodules` needs to be
94 /// regenerated by [gtk-query-immodules-3.0][gtk-query-immodules-3.0],
95 /// in order for the new input method to become available to GTK+ applications.
96 ///
97 /// This is an Abstract Base Class, you cannot instantiate it.
98 ///
99 /// ## Properties
100 ///
101 ///
102 /// #### `input-hints`
103 /// Readable | Writeable
104 ///
105 ///
106 /// #### `input-purpose`
107 /// Readable | Writeable
108 ///
109 /// ## Signals
110 ///
111 ///
112 /// #### `commit`
113 /// The ::commit signal is emitted when a complete input sequence
114 /// has been entered by the user. This can be a single character
115 /// immediately after a key press or the final result of preediting.
116 ///
117 ///
118 ///
119 ///
120 /// #### `delete-surrounding`
121 /// The ::delete-surrounding signal is emitted when the input method
122 /// needs to delete all or part of the context surrounding the cursor.
123 ///
124 ///
125 ///
126 ///
127 /// #### `preedit-changed`
128 /// The ::preedit-changed signal is emitted whenever the preedit sequence
129 /// currently being entered has changed. It is also emitted at the end of
130 /// a preedit sequence, in which case
131 /// [`IMContextExt::preedit_string()`][crate::prelude::IMContextExt::preedit_string()] returns the empty string.
132 ///
133 ///
134 ///
135 ///
136 /// #### `preedit-end`
137 /// The ::preedit-end signal is emitted when a preediting sequence
138 /// has been completed or canceled.
139 ///
140 ///
141 ///
142 ///
143 /// #### `preedit-start`
144 /// The ::preedit-start signal is emitted when a new preediting sequence
145 /// starts.
146 ///
147 ///
148 ///
149 ///
150 /// #### `retrieve-surrounding`
151 /// The ::retrieve-surrounding signal is emitted when the input method
152 /// requires the context surrounding the cursor. The callback should set
153 /// the input method surrounding context by calling the
154 /// [`IMContextExt::set_surrounding()`][crate::prelude::IMContextExt::set_surrounding()] method.
155 ///
156 ///
157 ///
158 /// # Implements
159 ///
160 /// [`IMContextExt`][trait@crate::prelude::IMContextExt], [`trait@glib::ObjectExt`]
161 #[doc(alias = "GtkIMContext")]
162 pub struct IMContext(Object<ffi::GtkIMContext, ffi::GtkIMContextClass>);
163
164 match fn {
165 type_ => || ffi::gtk_im_context_get_type(),
166 }
167}
168
169impl IMContext {
170 pub const NONE: Option<&'static IMContext> = None;
171}
172
173mod sealed {
174 pub trait Sealed {}
175 impl<T: super::IsA<super::IMContext>> Sealed for T {}
176}
177
178/// Trait containing all [`struct@IMContext`] methods.
179///
180/// # Implementors
181///
182/// [`IMContextSimple`][struct@crate::IMContextSimple], [`IMContext`][struct@crate::IMContext], [`IMMulticontext`][struct@crate::IMMulticontext]
183pub trait IMContextExt: IsA<IMContext> + sealed::Sealed + 'static {
184 /// Asks the widget that the input context is attached to to delete
185 /// characters around the cursor position by emitting the
186 /// GtkIMContext::delete_surrounding signal. Note that `offset` and `n_chars`
187 /// are in characters not in bytes which differs from the usage other
188 /// places in [`IMContext`][crate::IMContext].
189 ///
190 /// In order to use this function, you should first call
191 /// [`surrounding()`][Self::surrounding()] to get the current context, and
192 /// call this function immediately afterwards to make sure that you
193 /// know what you are deleting. You should also account for the fact
194 /// that even if the signal was handled, the input context might not
195 /// have deleted all the characters that were requested to be deleted.
196 ///
197 /// This function is used by an input method that wants to make
198 /// subsitutions in the existing text in response to new input. It is
199 /// not useful for applications.
200 /// ## `offset`
201 /// offset from cursor position in chars;
202 /// a negative value means start before the cursor.
203 /// ## `n_chars`
204 /// number of characters to delete.
205 ///
206 /// # Returns
207 ///
208 /// [`true`] if the signal was handled.
209 #[doc(alias = "gtk_im_context_delete_surrounding")]
210 fn delete_surrounding(&self, offset: i32, n_chars: i32) -> bool {
211 unsafe {
212 from_glib(ffi::gtk_im_context_delete_surrounding(
213 self.as_ref().to_glib_none().0,
214 offset,
215 n_chars,
216 ))
217 }
218 }
219
220 /// Allow an input method to internally handle key press and release
221 /// events. If this function returns [`true`], then no further processing
222 /// should be done for this key event.
223 /// ## `event`
224 /// the key event
225 ///
226 /// # Returns
227 ///
228 /// [`true`] if the input method handled the key event.
229 #[doc(alias = "gtk_im_context_filter_keypress")]
230 fn filter_keypress(&self, event: &gdk::EventKey) -> bool {
231 unsafe {
232 from_glib(ffi::gtk_im_context_filter_keypress(
233 self.as_ref().to_glib_none().0,
234 mut_override(event.to_glib_none().0),
235 ))
236 }
237 }
238
239 /// Notify the input method that the widget to which this
240 /// input context corresponds has gained focus. The input method
241 /// may, for example, change the displayed feedback to reflect
242 /// this change.
243 #[doc(alias = "gtk_im_context_focus_in")]
244 fn focus_in(&self) {
245 unsafe {
246 ffi::gtk_im_context_focus_in(self.as_ref().to_glib_none().0);
247 }
248 }
249
250 /// Notify the input method that the widget to which this
251 /// input context corresponds has lost focus. The input method
252 /// may, for example, change the displayed feedback or reset the contexts
253 /// state to reflect this change.
254 #[doc(alias = "gtk_im_context_focus_out")]
255 fn focus_out(&self) {
256 unsafe {
257 ffi::gtk_im_context_focus_out(self.as_ref().to_glib_none().0);
258 }
259 }
260
261 /// Retrieve the current preedit string for the input context,
262 /// and a list of attributes to apply to the string.
263 /// This string should be displayed inserted at the insertion
264 /// point.
265 ///
266 /// # Returns
267 ///
268 ///
269 /// ## `str`
270 /// location to store the retrieved
271 /// string. The string retrieved must be freed with `g_free()`.
272 ///
273 /// ## `attrs`
274 /// location to store the retrieved
275 /// attribute list. When you are done with this list, you
276 /// must unreference it with `pango_attr_list_unref()`.
277 ///
278 /// ## `cursor_pos`
279 /// location to store position of cursor (in characters)
280 /// within the preedit string.
281 #[doc(alias = "gtk_im_context_get_preedit_string")]
282 #[doc(alias = "get_preedit_string")]
283 fn preedit_string(&self) -> (glib::GString, pango::AttrList, i32) {
284 unsafe {
285 let mut str = ptr::null_mut();
286 let mut attrs = ptr::null_mut();
287 let mut cursor_pos = mem::MaybeUninit::uninit();
288 ffi::gtk_im_context_get_preedit_string(
289 self.as_ref().to_glib_none().0,
290 &mut str,
291 &mut attrs,
292 cursor_pos.as_mut_ptr(),
293 );
294 (
295 from_glib_full(str),
296 from_glib_full(attrs),
297 cursor_pos.assume_init(),
298 )
299 }
300 }
301
302 /// Retrieves context around the insertion point. Input methods
303 /// typically want context in order to constrain input text based on
304 /// existing text; this is important for languages such as Thai where
305 /// only some sequences of characters are allowed.
306 ///
307 /// This function is implemented by emitting the
308 /// GtkIMContext::retrieve_surrounding signal on the input method; in
309 /// response to this signal, a widget should provide as much context as
310 /// is available, up to an entire paragraph, by calling
311 /// [`set_surrounding()`][Self::set_surrounding()]. Note that there is no obligation
312 /// for a widget to respond to the ::retrieve_surrounding signal, so input
313 /// methods must be prepared to function without context.
314 ///
315 /// # Returns
316 ///
317 /// [`true`] if surrounding text was provided; in this case
318 /// you must free the result stored in *text.
319 ///
320 /// ## `text`
321 /// location to store a UTF-8 encoded
322 /// string of text holding context around the insertion point.
323 /// If the function returns [`true`], then you must free the result
324 /// stored in this location with `g_free()`.
325 ///
326 /// ## `cursor_index`
327 /// location to store byte index of the insertion
328 /// cursor within `text`.
329 #[doc(alias = "gtk_im_context_get_surrounding")]
330 #[doc(alias = "get_surrounding")]
331 fn surrounding(&self) -> Option<(glib::GString, i32)> {
332 unsafe {
333 let mut text = ptr::null_mut();
334 let mut cursor_index = mem::MaybeUninit::uninit();
335 let ret = from_glib(ffi::gtk_im_context_get_surrounding(
336 self.as_ref().to_glib_none().0,
337 &mut text,
338 cursor_index.as_mut_ptr(),
339 ));
340 if ret {
341 Some((from_glib_full(text), cursor_index.assume_init()))
342 } else {
343 None
344 }
345 }
346 }
347
348 /// Notify the input method that a change such as a change in cursor
349 /// position has been made. This will typically cause the input
350 /// method to clear the preedit state.
351 #[doc(alias = "gtk_im_context_reset")]
352 fn reset(&self) {
353 unsafe {
354 ffi::gtk_im_context_reset(self.as_ref().to_glib_none().0);
355 }
356 }
357
358 /// Set the client window for the input context; this is the
359 /// [`gdk::Window`][crate::gdk::Window] in which the input appears. This window is
360 /// used in order to correctly position status windows, and may
361 /// also be used for purposes internal to the input method.
362 /// ## `window`
363 /// the client window. This may be [`None`] to indicate
364 /// that the previous client window no longer exists.
365 #[doc(alias = "gtk_im_context_set_client_window")]
366 fn set_client_window(&self, window: Option<&gdk::Window>) {
367 unsafe {
368 ffi::gtk_im_context_set_client_window(
369 self.as_ref().to_glib_none().0,
370 window.to_glib_none().0,
371 );
372 }
373 }
374
375 /// Notify the input method that a change in cursor
376 /// position has been made. The location is relative to the client
377 /// window.
378 /// ## `area`
379 /// new location
380 #[doc(alias = "gtk_im_context_set_cursor_location")]
381 fn set_cursor_location(&self, area: &gdk::Rectangle) {
382 unsafe {
383 ffi::gtk_im_context_set_cursor_location(
384 self.as_ref().to_glib_none().0,
385 area.to_glib_none().0,
386 );
387 }
388 }
389
390 /// Sets surrounding context around the insertion point and preedit
391 /// string. This function is expected to be called in response to the
392 /// GtkIMContext::retrieve_surrounding signal, and will likely have no
393 /// effect if called at other times.
394 /// ## `text`
395 /// text surrounding the insertion point, as UTF-8.
396 /// the preedit string should not be included within
397 /// `text`.
398 /// ## `len`
399 /// the length of `text`, or -1 if `text` is nul-terminated
400 /// ## `cursor_index`
401 /// the byte index of the insertion cursor within `text`.
402 #[doc(alias = "gtk_im_context_set_surrounding")]
403 fn set_surrounding(&self, text: &str, cursor_index: i32) {
404 let len = text.len() as _;
405 unsafe {
406 ffi::gtk_im_context_set_surrounding(
407 self.as_ref().to_glib_none().0,
408 text.to_glib_none().0,
409 len,
410 cursor_index,
411 );
412 }
413 }
414
415 /// Sets whether the IM context should use the preedit string
416 /// to display feedback. If `use_preedit` is FALSE (default
417 /// is TRUE), then the IM context may use some other method to display
418 /// feedback, such as displaying it in a child of the root window.
419 /// ## `use_preedit`
420 /// whether the IM context should use the preedit string.
421 #[doc(alias = "gtk_im_context_set_use_preedit")]
422 fn set_use_preedit(&self, use_preedit: bool) {
423 unsafe {
424 ffi::gtk_im_context_set_use_preedit(
425 self.as_ref().to_glib_none().0,
426 use_preedit.into_glib(),
427 );
428 }
429 }
430
431 #[doc(alias = "input-hints")]
432 fn input_hints(&self) -> InputHints {
433 ObjectExt::property(self.as_ref(), "input-hints")
434 }
435
436 #[doc(alias = "input-hints")]
437 fn set_input_hints(&self, input_hints: InputHints) {
438 ObjectExt::set_property(self.as_ref(), "input-hints", input_hints)
439 }
440
441 #[doc(alias = "input-purpose")]
442 fn input_purpose(&self) -> InputPurpose {
443 ObjectExt::property(self.as_ref(), "input-purpose")
444 }
445
446 #[doc(alias = "input-purpose")]
447 fn set_input_purpose(&self, input_purpose: InputPurpose) {
448 ObjectExt::set_property(self.as_ref(), "input-purpose", input_purpose)
449 }
450
451 /// The ::commit signal is emitted when a complete input sequence
452 /// has been entered by the user. This can be a single character
453 /// immediately after a key press or the final result of preediting.
454 /// ## `str`
455 /// the completed character(s) entered by the user
456 #[doc(alias = "commit")]
457 fn connect_commit<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
458 unsafe extern "C" fn commit_trampoline<P: IsA<IMContext>, F: Fn(&P, &str) + 'static>(
459 this: *mut ffi::GtkIMContext,
460 str: *mut libc::c_char,
461 f: glib::ffi::gpointer,
462 ) {
463 let f: &F = &*(f as *const F);
464 f(
465 IMContext::from_glib_borrow(this).unsafe_cast_ref(),
466 &glib::GString::from_glib_borrow(str),
467 )
468 }
469 unsafe {
470 let f: Box_<F> = Box_::new(f);
471 connect_raw(
472 self.as_ptr() as *mut _,
473 b"commit\0".as_ptr() as *const _,
474 Some(transmute::<_, unsafe extern "C" fn()>(
475 commit_trampoline::<Self, F> as *const (),
476 )),
477 Box_::into_raw(f),
478 )
479 }
480 }
481
482 /// The ::delete-surrounding signal is emitted when the input method
483 /// needs to delete all or part of the context surrounding the cursor.
484 /// ## `offset`
485 /// the character offset from the cursor position of the text
486 /// to be deleted. A negative value indicates a position before
487 /// the cursor.
488 /// ## `n_chars`
489 /// the number of characters to be deleted
490 ///
491 /// # Returns
492 ///
493 /// [`true`] if the signal was handled.
494 #[doc(alias = "delete-surrounding")]
495 fn connect_delete_surrounding<F: Fn(&Self, i32, i32) -> bool + 'static>(
496 &self,
497 f: F,
498 ) -> SignalHandlerId {
499 unsafe extern "C" fn delete_surrounding_trampoline<
500 P: IsA<IMContext>,
501 F: Fn(&P, i32, i32) -> bool + 'static,
502 >(
503 this: *mut ffi::GtkIMContext,
504 offset: libc::c_int,
505 n_chars: libc::c_int,
506 f: glib::ffi::gpointer,
507 ) -> glib::ffi::gboolean {
508 let f: &F = &*(f as *const F);
509 f(
510 IMContext::from_glib_borrow(this).unsafe_cast_ref(),
511 offset,
512 n_chars,
513 )
514 .into_glib()
515 }
516 unsafe {
517 let f: Box_<F> = Box_::new(f);
518 connect_raw(
519 self.as_ptr() as *mut _,
520 b"delete-surrounding\0".as_ptr() as *const _,
521 Some(transmute::<_, unsafe extern "C" fn()>(
522 delete_surrounding_trampoline::<Self, F> as *const (),
523 )),
524 Box_::into_raw(f),
525 )
526 }
527 }
528
529 /// The ::preedit-changed signal is emitted whenever the preedit sequence
530 /// currently being entered has changed. It is also emitted at the end of
531 /// a preedit sequence, in which case
532 /// [`preedit_string()`][Self::preedit_string()] returns the empty string.
533 #[doc(alias = "preedit-changed")]
534 fn connect_preedit_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
535 unsafe extern "C" fn preedit_changed_trampoline<P: IsA<IMContext>, F: Fn(&P) + 'static>(
536 this: *mut ffi::GtkIMContext,
537 f: glib::ffi::gpointer,
538 ) {
539 let f: &F = &*(f as *const F);
540 f(IMContext::from_glib_borrow(this).unsafe_cast_ref())
541 }
542 unsafe {
543 let f: Box_<F> = Box_::new(f);
544 connect_raw(
545 self.as_ptr() as *mut _,
546 b"preedit-changed\0".as_ptr() as *const _,
547 Some(transmute::<_, unsafe extern "C" fn()>(
548 preedit_changed_trampoline::<Self, F> as *const (),
549 )),
550 Box_::into_raw(f),
551 )
552 }
553 }
554
555 /// The ::preedit-end signal is emitted when a preediting sequence
556 /// has been completed or canceled.
557 #[doc(alias = "preedit-end")]
558 fn connect_preedit_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
559 unsafe extern "C" fn preedit_end_trampoline<P: IsA<IMContext>, F: Fn(&P) + 'static>(
560 this: *mut ffi::GtkIMContext,
561 f: glib::ffi::gpointer,
562 ) {
563 let f: &F = &*(f as *const F);
564 f(IMContext::from_glib_borrow(this).unsafe_cast_ref())
565 }
566 unsafe {
567 let f: Box_<F> = Box_::new(f);
568 connect_raw(
569 self.as_ptr() as *mut _,
570 b"preedit-end\0".as_ptr() as *const _,
571 Some(transmute::<_, unsafe extern "C" fn()>(
572 preedit_end_trampoline::<Self, F> as *const (),
573 )),
574 Box_::into_raw(f),
575 )
576 }
577 }
578
579 /// The ::preedit-start signal is emitted when a new preediting sequence
580 /// starts.
581 #[doc(alias = "preedit-start")]
582 fn connect_preedit_start<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
583 unsafe extern "C" fn preedit_start_trampoline<P: IsA<IMContext>, F: Fn(&P) + 'static>(
584 this: *mut ffi::GtkIMContext,
585 f: glib::ffi::gpointer,
586 ) {
587 let f: &F = &*(f as *const F);
588 f(IMContext::from_glib_borrow(this).unsafe_cast_ref())
589 }
590 unsafe {
591 let f: Box_<F> = Box_::new(f);
592 connect_raw(
593 self.as_ptr() as *mut _,
594 b"preedit-start\0".as_ptr() as *const _,
595 Some(transmute::<_, unsafe extern "C" fn()>(
596 preedit_start_trampoline::<Self, F> as *const (),
597 )),
598 Box_::into_raw(f),
599 )
600 }
601 }
602
603 /// The ::retrieve-surrounding signal is emitted when the input method
604 /// requires the context surrounding the cursor. The callback should set
605 /// the input method surrounding context by calling the
606 /// [`set_surrounding()`][Self::set_surrounding()] method.
607 ///
608 /// # Returns
609 ///
610 /// [`true`] if the signal was handled.
611 #[doc(alias = "retrieve-surrounding")]
612 fn connect_retrieve_surrounding<F: Fn(&Self) -> bool + 'static>(
613 &self,
614 f: F,
615 ) -> SignalHandlerId {
616 unsafe extern "C" fn retrieve_surrounding_trampoline<
617 P: IsA<IMContext>,
618 F: Fn(&P) -> bool + 'static,
619 >(
620 this: *mut ffi::GtkIMContext,
621 f: glib::ffi::gpointer,
622 ) -> glib::ffi::gboolean {
623 let f: &F = &*(f as *const F);
624 f(IMContext::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
625 }
626 unsafe {
627 let f: Box_<F> = Box_::new(f);
628 connect_raw(
629 self.as_ptr() as *mut _,
630 b"retrieve-surrounding\0".as_ptr() as *const _,
631 Some(transmute::<_, unsafe extern "C" fn()>(
632 retrieve_surrounding_trampoline::<Self, F> as *const (),
633 )),
634 Box_::into_raw(f),
635 )
636 }
637 }
638
639 #[doc(alias = "input-hints")]
640 fn connect_input_hints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
641 unsafe extern "C" fn notify_input_hints_trampoline<
642 P: IsA<IMContext>,
643 F: Fn(&P) + 'static,
644 >(
645 this: *mut ffi::GtkIMContext,
646 _param_spec: glib::ffi::gpointer,
647 f: glib::ffi::gpointer,
648 ) {
649 let f: &F = &*(f as *const F);
650 f(IMContext::from_glib_borrow(this).unsafe_cast_ref())
651 }
652 unsafe {
653 let f: Box_<F> = Box_::new(f);
654 connect_raw(
655 self.as_ptr() as *mut _,
656 b"notify::input-hints\0".as_ptr() as *const _,
657 Some(transmute::<_, unsafe extern "C" fn()>(
658 notify_input_hints_trampoline::<Self, F> as *const (),
659 )),
660 Box_::into_raw(f),
661 )
662 }
663 }
664
665 #[doc(alias = "input-purpose")]
666 fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
667 unsafe extern "C" fn notify_input_purpose_trampoline<
668 P: IsA<IMContext>,
669 F: Fn(&P) + 'static,
670 >(
671 this: *mut ffi::GtkIMContext,
672 _param_spec: glib::ffi::gpointer,
673 f: glib::ffi::gpointer,
674 ) {
675 let f: &F = &*(f as *const F);
676 f(IMContext::from_glib_borrow(this).unsafe_cast_ref())
677 }
678 unsafe {
679 let f: Box_<F> = Box_::new(f);
680 connect_raw(
681 self.as_ptr() as *mut _,
682 b"notify::input-purpose\0".as_ptr() as *const _,
683 Some(transmute::<_, unsafe extern "C" fn()>(
684 notify_input_purpose_trampoline::<Self, F> as *const (),
685 )),
686 Box_::into_raw(f),
687 )
688 }
689 }
690}
691
692impl<O: IsA<IMContext>> IMContextExt for O {}
693
694impl fmt::Display for IMContext {
695 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
696 f.write_str("IMContext")
697 }
698}