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