gtk4/auto/
im_multicontext.rs1use crate::{ffi, IMContext, InputHints, InputPurpose};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 #[doc(alias = "GtkIMMulticontext")]
10 pub struct IMMulticontext(Object<ffi::GtkIMMulticontext, ffi::GtkIMMulticontextClass>) @extends IMContext;
11
12 match fn {
13 type_ => || ffi::gtk_im_multicontext_get_type(),
14 }
15}
16
17impl IMMulticontext {
18 pub const NONE: Option<&'static IMMulticontext> = None;
19
20 #[doc(alias = "gtk_im_multicontext_new")]
21 pub fn new() -> IMMulticontext {
22 assert_initialized_main_thread!();
23 unsafe { IMContext::from_glib_full(ffi::gtk_im_multicontext_new()).unsafe_cast() }
24 }
25
26 pub fn builder() -> IMMulticontextBuilder {
31 IMMulticontextBuilder::new()
32 }
33}
34
35impl Default for IMMulticontext {
36 fn default() -> Self {
37 Self::new()
38 }
39}
40
41#[must_use = "The builder must be built to be used"]
46pub struct IMMulticontextBuilder {
47 builder: glib::object::ObjectBuilder<'static, IMMulticontext>,
48}
49
50impl IMMulticontextBuilder {
51 fn new() -> Self {
52 Self {
53 builder: glib::object::Object::builder(),
54 }
55 }
56
57 pub fn input_hints(self, input_hints: InputHints) -> Self {
58 Self {
59 builder: self.builder.property("input-hints", input_hints),
60 }
61 }
62
63 pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
64 Self {
65 builder: self.builder.property("input-purpose", input_purpose),
66 }
67 }
68
69 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
72 pub fn build(self) -> IMMulticontext {
73 assert_initialized_main_thread!();
74 self.builder.build()
75 }
76}
77
78pub trait IMMulticontextExt: IsA<IMMulticontext> + 'static {
79 #[doc(alias = "gtk_im_multicontext_get_context_id")]
80 #[doc(alias = "get_context_id")]
81 fn context_id(&self) -> glib::GString {
82 unsafe {
83 from_glib_none(ffi::gtk_im_multicontext_get_context_id(
84 self.as_ref().to_glib_none().0,
85 ))
86 }
87 }
88
89 #[doc(alias = "gtk_im_multicontext_set_context_id")]
90 fn set_context_id(&self, context_id: Option<&str>) {
91 unsafe {
92 ffi::gtk_im_multicontext_set_context_id(
93 self.as_ref().to_glib_none().0,
94 context_id.to_glib_none().0,
95 );
96 }
97 }
98}
99
100impl<O: IsA<IMMulticontext>> IMMulticontextExt for O {}