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 
5 use crate::IMContext;
6 use crate::InputHints;
7 use crate::InputPurpose;
8 use glib::object::Cast;
9 use glib::object::IsA;
10 use glib::translate::*;
11 use glib::StaticType;
12 use glib::ToValue;
13 use std::fmt;
14 
15 glib::wrapper! {
16     #[doc(alias = "GtkIMMulticontext")]
17     pub struct IMMulticontext(Object<ffi::GtkIMMulticontext, ffi::GtkIMMulticontextClass>) @extends IMContext;
18 
19     match fn {
20         type_ => || ffi::gtk_im_multicontext_get_type(),
21     }
22 }
23 
24 impl IMMulticontext {
25     #[doc(alias = "gtk_im_multicontext_new")]
new() -> IMMulticontext26     pub fn new() -> IMMulticontext {
27         assert_initialized_main_thread!();
28         unsafe { IMContext::from_glib_full(ffi::gtk_im_multicontext_new()).unsafe_cast() }
29     }
30 
31     // rustdoc-stripper-ignore-next
32     /// Creates a new builder-pattern struct instance to construct [`IMMulticontext`] objects.
33     ///
34     /// This method returns an instance of [`IMMulticontextBuilder`] which can be used to create [`IMMulticontext`] objects.
builder() -> IMMulticontextBuilder35     pub fn builder() -> IMMulticontextBuilder {
36         IMMulticontextBuilder::default()
37     }
38 }
39 
40 impl Default for IMMulticontext {
default() -> Self41     fn default() -> Self {
42         Self::new()
43     }
44 }
45 
46 #[derive(Clone, Default)]
47 // rustdoc-stripper-ignore-next
48 /// A [builder-pattern] type to construct [`IMMulticontext`] objects.
49 ///
50 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
51 pub struct IMMulticontextBuilder {
52     input_hints: Option<InputHints>,
53     input_purpose: Option<InputPurpose>,
54 }
55 
56 impl IMMulticontextBuilder {
57     // rustdoc-stripper-ignore-next
58     /// Create a new [`IMMulticontextBuilder`].
new() -> Self59     pub fn new() -> Self {
60         Self::default()
61     }
62 
63     // rustdoc-stripper-ignore-next
64     /// Build the [`IMMulticontext`].
build(self) -> IMMulticontext65     pub fn build(self) -> IMMulticontext {
66         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
67         if let Some(ref input_hints) = self.input_hints {
68             properties.push(("input-hints", input_hints));
69         }
70         if let Some(ref input_purpose) = self.input_purpose {
71             properties.push(("input-purpose", input_purpose));
72         }
73         glib::Object::new::<IMMulticontext>(&properties)
74             .expect("Failed to create an instance of IMMulticontext")
75     }
76 
input_hints(mut self, input_hints: InputHints) -> Self77     pub fn input_hints(mut self, input_hints: InputHints) -> Self {
78         self.input_hints = Some(input_hints);
79         self
80     }
81 
input_purpose(mut self, input_purpose: InputPurpose) -> Self82     pub fn input_purpose(mut self, input_purpose: InputPurpose) -> Self {
83         self.input_purpose = Some(input_purpose);
84         self
85     }
86 }
87 
88 pub const NONE_IM_MULTICONTEXT: Option<&IMMulticontext> = None;
89 
90 pub trait IMMulticontextExt: 'static {
91     #[doc(alias = "gtk_im_multicontext_get_context_id")]
92     #[doc(alias = "get_context_id")]
context_id(&self) -> Option<glib::GString>93     fn context_id(&self) -> Option<glib::GString>;
94 
95     #[doc(alias = "gtk_im_multicontext_set_context_id")]
set_context_id(&self, context_id: &str)96     fn set_context_id(&self, context_id: &str);
97 }
98 
99 impl<O: IsA<IMMulticontext>> IMMulticontextExt for O {
context_id(&self) -> Option<glib::GString>100     fn context_id(&self) -> Option<glib::GString> {
101         unsafe {
102             from_glib_none(ffi::gtk_im_multicontext_get_context_id(
103                 self.as_ref().to_glib_none().0,
104             ))
105         }
106     }
107 
set_context_id(&self, context_id: &str)108     fn set_context_id(&self, context_id: &str) {
109         unsafe {
110             ffi::gtk_im_multicontext_set_context_id(
111                 self.as_ref().to_glib_none().0,
112                 context_id.to_glib_none().0,
113             );
114         }
115     }
116 }
117 
118 impl fmt::Display for IMMulticontext {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result119     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
120         f.write_str("IMMulticontext")
121     }
122 }
123