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::{ffi, IMContext, InputHints, InputPurpose};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// [`IMContextSimple`][crate::IMContextSimple] is an input method supporting table-based input methods.
10 ///
11 /// ## Compose sequences
12 ///
13 /// [`IMContextSimple`][crate::IMContextSimple] reads compose sequences from the first of the
14 /// following files that is found: ~/.config/gtk-4.0/Compose, ~/.XCompose,
15 /// /usr/share/X11/locale/$locale/Compose (for locales that have a nontrivial
16 /// Compose file). A subset of the file syntax described in the Compose(5)
17 /// manual page is supported. Additionally, `include "`L`"` loads GTK’s built-in
18 /// table of compose sequences rather than the locale-specific one from X11.
19 ///
20 /// If none of these files is found, [`IMContextSimple`][crate::IMContextSimple] uses a built-in table
21 /// of compose sequences that is derived from the X11 Compose files.
22 ///
23 /// Note that compose sequences typically start with the Compose_key, which is
24 /// often not available as a dedicated key on keyboards. Keyboard layouts may
25 /// map this keysym to other keys, such as the right Control key.
26 ///
27 /// ## Unicode characters
28 ///
29 /// [`IMContextSimple`][crate::IMContextSimple] also supports numeric entry of Unicode characters
30 /// by typing <kbd>Ctrl</kbd>-<kbd>Shift</kbd>-<kbd>u</kbd>, followed by a
31 /// hexadecimal Unicode codepoint.
32 ///
33 /// For example,
34 ///
35 /// Ctrl-Shift-u 1 2 3 Enter
36 ///
37 /// yields U+0123 LATIN SMALL LETTER G WITH CEDILLA, i.e. ģ.
38 ///
39 /// ## Dead keys
40 ///
41 /// [`IMContextSimple`][crate::IMContextSimple] supports dead keys. For example, typing
42 ///
43 /// dead_acute a
44 ///
45 /// yields U+00E! LATIN SMALL LETTER_A WITH ACUTE, i.e. á. Note that this
46 /// depends on the keyboard layout including dead keys.
47 ///
48 /// # Implements
49 ///
50 /// [`IMContextExt`][trait@crate::prelude::IMContextExt], [`trait@glib::ObjectExt`]
51 #[doc(alias = "GtkIMContextSimple")]
52 pub struct IMContextSimple(Object<ffi::GtkIMContextSimple, ffi::GtkIMContextSimpleClass>) @extends IMContext;
53
54 match fn {
55 type_ => || ffi::gtk_im_context_simple_get_type(),
56 }
57}
58
59impl IMContextSimple {
60 pub const NONE: Option<&'static IMContextSimple> = None;
61
62 /// Creates a new [`IMContextSimple`][crate::IMContextSimple].
63 ///
64 /// # Returns
65 ///
66 /// a new [`IMContextSimple`][crate::IMContextSimple]
67 #[doc(alias = "gtk_im_context_simple_new")]
68 pub fn new() -> IMContextSimple {
69 assert_initialized_main_thread!();
70 unsafe { IMContext::from_glib_full(ffi::gtk_im_context_simple_new()).unsafe_cast() }
71 }
72
73 // rustdoc-stripper-ignore-next
74 /// Creates a new builder-pattern struct instance to construct [`IMContextSimple`] objects.
75 ///
76 /// This method returns an instance of [`IMContextSimpleBuilder`](crate::builders::IMContextSimpleBuilder) which can be used to create [`IMContextSimple`] objects.
77 pub fn builder() -> IMContextSimpleBuilder {
78 IMContextSimpleBuilder::new()
79 }
80}
81
82impl Default for IMContextSimple {
83 fn default() -> Self {
84 Self::new()
85 }
86}
87
88// rustdoc-stripper-ignore-next
89/// A [builder-pattern] type to construct [`IMContextSimple`] objects.
90///
91/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
92#[must_use = "The builder must be built to be used"]
93pub struct IMContextSimpleBuilder {
94 builder: glib::object::ObjectBuilder<'static, IMContextSimple>,
95}
96
97impl IMContextSimpleBuilder {
98 fn new() -> Self {
99 Self {
100 builder: glib::object::Object::builder(),
101 }
102 }
103
104 /// Additional hints that allow input methods to fine-tune
105 /// their behaviour.
106 pub fn input_hints(self, input_hints: InputHints) -> Self {
107 Self {
108 builder: self.builder.property("input-hints", input_hints),
109 }
110 }
111
112 /// The purpose of the text field that the `GtkIMContext is connected to.
113 ///
114 /// This property can be used by on-screen keyboards and other input
115 /// methods to adjust their behaviour.
116 pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
117 Self {
118 builder: self.builder.property("input-purpose", input_purpose),
119 }
120 }
121
122 // rustdoc-stripper-ignore-next
123 /// Build the [`IMContextSimple`].
124 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
125 pub fn build(self) -> IMContextSimple {
126 assert_initialized_main_thread!();
127 self.builder.build()
128 }
129}