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::translate::*;
10 use glib::StaticType;
11 use glib::ToValue;
12 use std::fmt;
13 
14 glib::wrapper! {
15     #[doc(alias = "GtkIMContextSimple")]
16     pub struct IMContextSimple(Object<ffi::GtkIMContextSimple, ffi::GtkIMContextSimpleClass>) @extends IMContext;
17 
18     match fn {
19         type_ => || ffi::gtk_im_context_simple_get_type(),
20     }
21 }
22 
23 impl IMContextSimple {
24     #[doc(alias = "gtk_im_context_simple_new")]
new() -> IMContextSimple25     pub fn new() -> IMContextSimple {
26         assert_initialized_main_thread!();
27         unsafe { IMContext::from_glib_full(ffi::gtk_im_context_simple_new()).unsafe_cast() }
28     }
29 
30     // rustdoc-stripper-ignore-next
31     /// Creates a new builder-pattern struct instance to construct [`IMContextSimple`] objects.
32     ///
33     /// This method returns an instance of [`IMContextSimpleBuilder`] which can be used to create [`IMContextSimple`] objects.
builder() -> IMContextSimpleBuilder34     pub fn builder() -> IMContextSimpleBuilder {
35         IMContextSimpleBuilder::default()
36     }
37 }
38 
39 impl Default for IMContextSimple {
default() -> Self40     fn default() -> Self {
41         Self::new()
42     }
43 }
44 
45 #[derive(Clone, Default)]
46 // rustdoc-stripper-ignore-next
47 /// A [builder-pattern] type to construct [`IMContextSimple`] objects.
48 ///
49 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
50 pub struct IMContextSimpleBuilder {
51     input_hints: Option<InputHints>,
52     input_purpose: Option<InputPurpose>,
53 }
54 
55 impl IMContextSimpleBuilder {
56     // rustdoc-stripper-ignore-next
57     /// Create a new [`IMContextSimpleBuilder`].
new() -> Self58     pub fn new() -> Self {
59         Self::default()
60     }
61 
62     // rustdoc-stripper-ignore-next
63     /// Build the [`IMContextSimple`].
build(self) -> IMContextSimple64     pub fn build(self) -> IMContextSimple {
65         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
66         if let Some(ref input_hints) = self.input_hints {
67             properties.push(("input-hints", input_hints));
68         }
69         if let Some(ref input_purpose) = self.input_purpose {
70             properties.push(("input-purpose", input_purpose));
71         }
72         glib::Object::new::<IMContextSimple>(&properties)
73             .expect("Failed to create an instance of IMContextSimple")
74     }
75 
input_hints(mut self, input_hints: InputHints) -> Self76     pub fn input_hints(mut self, input_hints: InputHints) -> Self {
77         self.input_hints = Some(input_hints);
78         self
79     }
80 
input_purpose(mut self, input_purpose: InputPurpose) -> Self81     pub fn input_purpose(mut self, input_purpose: InputPurpose) -> Self {
82         self.input_purpose = Some(input_purpose);
83         self
84     }
85 }
86 
87 pub const NONE_IM_CONTEXT_SIMPLE: Option<&IMContextSimple> = None;
88 
89 impl fmt::Display for IMContextSimple {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result90     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
91         f.write_str("IMContextSimple")
92     }
93 }
94