Skip to main content

gtk/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    /// GtkIMContextSimple is a simple input method context supporting table-based
10    /// input methods. It has a built-in table of compose sequences that is derived
11    /// from the X11 Compose files.
12    ///
13    /// GtkIMContextSimple reads additional compose sequences from the first of the
14    /// following files that is found: ~/.config/gtk-3.0/Compose, ~/.XCompose,
15    /// /usr/share/X11/locale/$locale/Compose (for locales that have a nontrivial
16    /// Compose file). The syntax of these files is described in the Compose(5)
17    /// manual page.
18    ///
19    /// ## Unicode characters
20    ///
21    /// GtkIMContextSimple also supports numeric entry of Unicode characters
22    /// by typing Ctrl-Shift-u, followed by a hexadecimal Unicode codepoint.
23    /// For example, Ctrl-Shift-u 1 2 3 Enter yields U+0123 LATIN SMALL LETTER
24    /// G WITH CEDILLA, i.e. ģ.
25    ///
26    /// # Implements
27    ///
28    /// [`IMContextExt`][trait@crate::prelude::IMContextExt], [`trait@glib::ObjectExt`], [`IMContextSimpleExtManual`][trait@crate::prelude::IMContextSimpleExtManual]
29    #[doc(alias = "GtkIMContextSimple")]
30    pub struct IMContextSimple(Object<ffi::GtkIMContextSimple, ffi::GtkIMContextSimpleClass>) @extends IMContext;
31
32    match fn {
33        type_ => || ffi::gtk_im_context_simple_get_type(),
34    }
35}
36
37impl IMContextSimple {
38    pub const NONE: Option<&'static IMContextSimple> = None;
39
40    /// Creates a new [`IMContextSimple`][crate::IMContextSimple].
41    ///
42    /// # Returns
43    ///
44    /// a new [`IMContextSimple`][crate::IMContextSimple].
45    #[doc(alias = "gtk_im_context_simple_new")]
46    pub fn new() -> IMContextSimple {
47        assert_initialized_main_thread!();
48        unsafe { IMContext::from_glib_full(ffi::gtk_im_context_simple_new()).unsafe_cast() }
49    }
50
51    // rustdoc-stripper-ignore-next
52    /// Creates a new builder-pattern struct instance to construct [`IMContextSimple`] objects.
53    ///
54    /// This method returns an instance of [`IMContextSimpleBuilder`](crate::builders::IMContextSimpleBuilder) which can be used to create [`IMContextSimple`] objects.
55    pub fn builder() -> IMContextSimpleBuilder {
56        IMContextSimpleBuilder::new()
57    }
58}
59
60impl Default for IMContextSimple {
61    fn default() -> Self {
62        Self::new()
63    }
64}
65
66// rustdoc-stripper-ignore-next
67/// A [builder-pattern] type to construct [`IMContextSimple`] objects.
68///
69/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
70#[must_use = "The builder must be built to be used"]
71pub struct IMContextSimpleBuilder {
72    builder: glib::object::ObjectBuilder<'static, IMContextSimple>,
73}
74
75impl IMContextSimpleBuilder {
76    fn new() -> Self {
77        Self {
78            builder: glib::object::Object::builder(),
79        }
80    }
81
82    pub fn input_hints(self, input_hints: InputHints) -> Self {
83        Self {
84            builder: self.builder.property("input-hints", input_hints),
85        }
86    }
87
88    pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
89        Self {
90            builder: self.builder.property("input-purpose", input_purpose),
91        }
92    }
93
94    // rustdoc-stripper-ignore-next
95    /// Build the [`IMContextSimple`].
96    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
97    pub fn build(self) -> IMContextSimple {
98        assert_initialized_main_thread!();
99        self.builder.build()
100    }
101}