Skip to main content

gtk4/auto/
im_context_simple.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::{IMContext, InputHints, InputPurpose, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// . Note that this
10    ///  depends on the keyboard layout including dead keys.
11    ///
12    /// # Implements
13    ///
14    /// [`IMContextExt`][trait@crate::prelude::IMContextExt], [`trait@glib::ObjectExt`]
15    #[doc(alias = "GtkIMContextSimple")]
16    pub struct IMContextSimple(Object<ffi::GtkIMContextSimple, ffi::GtkIMContextSimpleClass>) @extends IMContext;
17
18    match fn {
19        type_ => || ffi::gtk_im_context_simple_get_type(),
20    }
21}
22
23impl IMContextSimple {
24    pub const NONE: Option<&'static IMContextSimple> = None;
25
26    /// Creates a new [`IMContextSimple`][crate::IMContextSimple].
27    ///
28    /// # Returns
29    ///
30    /// a new [`IMContextSimple`][crate::IMContextSimple]
31    #[doc(alias = "gtk_im_context_simple_new")]
32    pub fn new() -> IMContextSimple {
33        assert_initialized_main_thread!();
34        unsafe { IMContext::from_glib_full(ffi::gtk_im_context_simple_new()).unsafe_cast() }
35    }
36
37    // rustdoc-stripper-ignore-next
38    /// Creates a new builder-pattern struct instance to construct [`IMContextSimple`] objects.
39    ///
40    /// This method returns an instance of [`IMContextSimpleBuilder`](crate::builders::IMContextSimpleBuilder) which can be used to create [`IMContextSimple`] objects.
41    pub fn builder() -> IMContextSimpleBuilder {
42        IMContextSimpleBuilder::new()
43    }
44}
45
46impl Default for IMContextSimple {
47    fn default() -> Self {
48        Self::new()
49    }
50}
51
52// rustdoc-stripper-ignore-next
53/// A [builder-pattern] type to construct [`IMContextSimple`] objects.
54///
55/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
56#[must_use = "The builder must be built to be used"]
57pub struct IMContextSimpleBuilder {
58    builder: glib::object::ObjectBuilder<'static, IMContextSimple>,
59}
60
61impl IMContextSimpleBuilder {
62    fn new() -> Self {
63        Self {
64            builder: glib::object::Object::builder(),
65        }
66    }
67
68    /// Additional hints that allow input methods to fine-tune
69    /// their behaviour.
70    pub fn input_hints(self, input_hints: InputHints) -> Self {
71        Self {
72            builder: self.builder.property("input-hints", input_hints),
73        }
74    }
75
76    /// The purpose of the text field that the `GtkIMContext is connected to.
77    ///
78    /// This property can be used by on-screen keyboards and other input
79    /// methods to adjust their behaviour.
80    pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
81        Self {
82            builder: self.builder.property("input-purpose", input_purpose),
83        }
84    }
85
86    // rustdoc-stripper-ignore-next
87    /// Build the [`IMContextSimple`].
88    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
89    pub fn build(self) -> IMContextSimple {
90        assert_initialized_main_thread!();
91        self.builder.build()
92    }
93}