gtk/auto/
im_context_simple.rs

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
5use glib::object::Cast;
6use glib::translate::*;
7use glib::StaticType;
8use glib::ToValue;
9use gtk_sys;
10use std::fmt;
11use IMContext;
12use InputHints;
13use InputPurpose;
14
15glib_wrapper! {
16    pub struct IMContextSimple(Object<gtk_sys::GtkIMContextSimple, gtk_sys::GtkIMContextSimpleClass, IMContextSimpleClass>) @extends IMContext;
17
18    match fn {
19        get_type => || gtk_sys::gtk_im_context_simple_get_type(),
20    }
21}
22
23impl IMContextSimple {
24    pub fn new() -> IMContextSimple {
25        assert_initialized_main_thread!();
26        unsafe { IMContext::from_glib_full(gtk_sys::gtk_im_context_simple_new()).unsafe_cast() }
27    }
28}
29
30impl Default for IMContextSimple {
31    fn default() -> Self {
32        Self::new()
33    }
34}
35
36pub struct IMContextSimpleBuilder {
37    input_hints: Option<InputHints>,
38    input_purpose: Option<InputPurpose>,
39}
40
41impl IMContextSimpleBuilder {
42    pub fn new() -> Self {
43        Self {
44            input_hints: None,
45            input_purpose: None,
46        }
47    }
48
49    pub fn build(self) -> IMContextSimple {
50        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
51        if let Some(ref input_hints) = self.input_hints {
52            properties.push(("input-hints", input_hints));
53        }
54        if let Some(ref input_purpose) = self.input_purpose {
55            properties.push(("input-purpose", input_purpose));
56        }
57        glib::Object::new(IMContextSimple::static_type(), &properties)
58            .expect("object new")
59            .downcast()
60            .expect("downcast")
61    }
62
63    pub fn input_hints(mut self, input_hints: InputHints) -> Self {
64        self.input_hints = Some(input_hints);
65        self
66    }
67
68    pub fn input_purpose(mut self, input_purpose: InputPurpose) -> Self {
69        self.input_purpose = Some(input_purpose);
70        self
71    }
72}
73
74pub const NONE_IM_CONTEXT_SIMPLE: Option<&IMContextSimple> = None;
75
76impl fmt::Display for IMContextSimple {
77    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
78        write!(f, "IMContextSimple")
79    }
80}