gtk4/auto/im_multicontext.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 /// [`IMMulticontext`][crate::IMMulticontext] is an input method context supporting multiple,
10 /// switchable input methods.
11 ///
12 /// Text widgets such as [`Text`][crate::Text] or [`TextView`][crate::TextView] use a `GtkIMMultiContext`
13 /// to implement their `im-module` property for switching between different
14 /// input methods.
15 ///
16 /// # Implements
17 ///
18 /// [`IMMulticontextExt`][trait@crate::prelude::IMMulticontextExt], [`IMContextExt`][trait@crate::prelude::IMContextExt], [`trait@glib::ObjectExt`]
19 #[doc(alias = "GtkIMMulticontext")]
20 pub struct IMMulticontext(Object<ffi::GtkIMMulticontext, ffi::GtkIMMulticontextClass>) @extends IMContext;
21
22 match fn {
23 type_ => || ffi::gtk_im_multicontext_get_type(),
24 }
25}
26
27impl IMMulticontext {
28 pub const NONE: Option<&'static IMMulticontext> = None;
29
30 /// Creates a new [`IMMulticontext`][crate::IMMulticontext].
31 ///
32 /// # Returns
33 ///
34 /// a new [`IMMulticontext`][crate::IMMulticontext].
35 #[doc(alias = "gtk_im_multicontext_new")]
36 pub fn new() -> IMMulticontext {
37 assert_initialized_main_thread!();
38 unsafe { IMContext::from_glib_full(ffi::gtk_im_multicontext_new()).unsafe_cast() }
39 }
40
41 // rustdoc-stripper-ignore-next
42 /// Creates a new builder-pattern struct instance to construct [`IMMulticontext`] objects.
43 ///
44 /// This method returns an instance of [`IMMulticontextBuilder`](crate::builders::IMMulticontextBuilder) which can be used to create [`IMMulticontext`] objects.
45 pub fn builder() -> IMMulticontextBuilder {
46 IMMulticontextBuilder::new()
47 }
48}
49
50impl Default for IMMulticontext {
51 fn default() -> Self {
52 Self::new()
53 }
54}
55
56// rustdoc-stripper-ignore-next
57/// A [builder-pattern] type to construct [`IMMulticontext`] objects.
58///
59/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
60#[must_use = "The builder must be built to be used"]
61pub struct IMMulticontextBuilder {
62 builder: glib::object::ObjectBuilder<'static, IMMulticontext>,
63}
64
65impl IMMulticontextBuilder {
66 fn new() -> Self {
67 Self {
68 builder: glib::object::Object::builder(),
69 }
70 }
71
72 /// Additional hints that allow input methods to fine-tune
73 /// their behaviour.
74 pub fn input_hints(self, input_hints: InputHints) -> Self {
75 Self {
76 builder: self.builder.property("input-hints", input_hints),
77 }
78 }
79
80 /// The purpose of the text field that the `GtkIMContext is connected to.
81 ///
82 /// This property can be used by on-screen keyboards and other input
83 /// methods to adjust their behaviour.
84 pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
85 Self {
86 builder: self.builder.property("input-purpose", input_purpose),
87 }
88 }
89
90 // rustdoc-stripper-ignore-next
91 /// Build the [`IMMulticontext`].
92 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
93 pub fn build(self) -> IMMulticontext {
94 assert_initialized_main_thread!();
95 self.builder.build()
96 }
97}
98
99mod sealed {
100 pub trait Sealed {}
101 impl<T: super::IsA<super::IMMulticontext>> Sealed for T {}
102}
103
104/// Trait containing all [`struct@IMMulticontext`] methods.
105///
106/// # Implementors
107///
108/// [`IMMulticontext`][struct@crate::IMMulticontext]
109pub trait IMMulticontextExt: IsA<IMMulticontext> + sealed::Sealed + 'static {
110 /// Gets the id of the currently active delegate of the @self.
111 ///
112 /// # Returns
113 ///
114 /// the id of the currently active delegate
115 #[doc(alias = "gtk_im_multicontext_get_context_id")]
116 #[doc(alias = "get_context_id")]
117 fn context_id(&self) -> glib::GString {
118 unsafe {
119 from_glib_none(ffi::gtk_im_multicontext_get_context_id(
120 self.as_ref().to_glib_none().0,
121 ))
122 }
123 }
124
125 /// Sets the context id for @self.
126 ///
127 /// This causes the currently active delegate of @self to be
128 /// replaced by the delegate corresponding to the new context id.
129 ///
130 /// Setting this to a non-[`None`] value overrides the system-wide
131 /// IM module setting. See the [`gtk-im-module`][struct@crate::Settings#gtk-im-module]
132 /// property.
133 /// ## `context_id`
134 /// the id to use
135 #[doc(alias = "gtk_im_multicontext_set_context_id")]
136 fn set_context_id(&self, context_id: Option<&str>) {
137 unsafe {
138 ffi::gtk_im_multicontext_set_context_id(
139 self.as_ref().to_glib_none().0,
140 context_id.to_glib_none().0,
141 );
142 }
143 }
144}
145
146impl<O: IsA<IMMulticontext>> IMMulticontextExt for O {}