gtk/auto/
im_multicontext.rs1use crate::{IMContext, InputHints, InputPurpose};
6use glib::{prelude::*, translate::*};
7use std::fmt;
8
9glib::wrapper! {
10 #[doc(alias = "GtkIMMulticontext")]
16 pub struct IMMulticontext(Object<ffi::GtkIMMulticontext, ffi::GtkIMMulticontextClass>) @extends IMContext;
17
18 match fn {
19 type_ => || ffi::gtk_im_multicontext_get_type(),
20 }
21}
22
23impl IMMulticontext {
24 pub const NONE: Option<&'static IMMulticontext> = None;
25
26 #[doc(alias = "gtk_im_multicontext_new")]
32 pub fn new() -> IMMulticontext {
33 assert_initialized_main_thread!();
34 unsafe { IMContext::from_glib_full(ffi::gtk_im_multicontext_new()).unsafe_cast() }
35 }
36
37 pub fn builder() -> IMMulticontextBuilder {
42 IMMulticontextBuilder::new()
43 }
44}
45
46impl Default for IMMulticontext {
47 fn default() -> Self {
48 Self::new()
49 }
50}
51
52#[must_use = "The builder must be built to be used"]
57pub struct IMMulticontextBuilder {
58 builder: glib::object::ObjectBuilder<'static, IMMulticontext>,
59}
60
61impl IMMulticontextBuilder {
62 fn new() -> Self {
63 Self {
64 builder: glib::object::Object::builder(),
65 }
66 }
67
68 pub fn input_hints(self, input_hints: InputHints) -> Self {
69 Self {
70 builder: self.builder.property("input-hints", input_hints),
71 }
72 }
73
74 pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
75 Self {
76 builder: self.builder.property("input-purpose", input_purpose),
77 }
78 }
79
80 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
83 pub fn build(self) -> IMMulticontext {
84 self.builder.build()
85 }
86}
87
88mod sealed {
89 pub trait Sealed {}
90 impl<T: super::IsA<super::IMMulticontext>> Sealed for T {}
91}
92
93pub trait IMMulticontextExt: IsA<IMMulticontext> + sealed::Sealed + 'static {
99 #[doc(alias = "gtk_im_multicontext_get_context_id")]
105 #[doc(alias = "get_context_id")]
106 fn context_id(&self) -> Option<glib::GString> {
107 unsafe {
108 from_glib_none(ffi::gtk_im_multicontext_get_context_id(
109 self.as_ref().to_glib_none().0,
110 ))
111 }
112 }
113
114 #[doc(alias = "gtk_im_multicontext_set_context_id")]
121 fn set_context_id(&self, context_id: &str) {
122 unsafe {
123 ffi::gtk_im_multicontext_set_context_id(
124 self.as_ref().to_glib_none().0,
125 context_id.to_glib_none().0,
126 );
127 }
128 }
129}
130
131impl<O: IsA<IMMulticontext>> IMMulticontextExt for O {}
132
133impl fmt::Display for IMMulticontext {
134 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
135 f.write_str("IMMulticontext")
136 }
137}