gtk/auto/
im_multicontext.rs1use crate::{IMContext, InputHints, InputPurpose, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 #[doc(alias = "GtkIMMulticontext")]
15 pub struct IMMulticontext(Object<ffi::GtkIMMulticontext, ffi::GtkIMMulticontextClass>) @extends IMContext;
16
17 match fn {
18 type_ => || ffi::gtk_im_multicontext_get_type(),
19 }
20}
21
22impl IMMulticontext {
23 pub const NONE: Option<&'static IMMulticontext> = None;
24
25 #[doc(alias = "gtk_im_multicontext_new")]
31 pub fn new() -> IMMulticontext {
32 assert_initialized_main_thread!();
33 unsafe { IMContext::from_glib_full(ffi::gtk_im_multicontext_new()).unsafe_cast() }
34 }
35
36 pub fn builder() -> IMMulticontextBuilder {
41 IMMulticontextBuilder::new()
42 }
43}
44
45impl Default for IMMulticontext {
46 fn default() -> Self {
47 Self::new()
48 }
49}
50
51#[must_use = "The builder must be built to be used"]
56pub struct IMMulticontextBuilder {
57 builder: glib::object::ObjectBuilder<'static, IMMulticontext>,
58}
59
60impl IMMulticontextBuilder {
61 fn new() -> Self {
62 Self {
63 builder: glib::object::Object::builder(),
64 }
65 }
66
67 pub fn input_hints(self, input_hints: InputHints) -> Self {
68 Self {
69 builder: self.builder.property("input-hints", input_hints),
70 }
71 }
72
73 pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
74 Self {
75 builder: self.builder.property("input-purpose", input_purpose),
76 }
77 }
78
79 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
82 pub fn build(self) -> IMMulticontext {
83 assert_initialized_main_thread!();
84 self.builder.build()
85 }
86}
87
88pub trait IMMulticontextExt: IsA<IMMulticontext> + 'static {
94 #[doc(alias = "gtk_im_multicontext_get_context_id")]
100 #[doc(alias = "get_context_id")]
101 fn context_id(&self) -> Option<glib::GString> {
102 unsafe {
103 from_glib_none(ffi::gtk_im_multicontext_get_context_id(
104 self.as_ref().to_glib_none().0,
105 ))
106 }
107 }
108
109 #[doc(alias = "gtk_im_multicontext_set_context_id")]
116 fn set_context_id(&self, context_id: &str) {
117 unsafe {
118 ffi::gtk_im_multicontext_set_context_id(
119 self.as_ref().to_glib_none().0,
120 context_id.to_glib_none().0,
121 );
122 }
123 }
124}
125
126impl<O: IsA<IMMulticontext>> IMMulticontextExt for O {}