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 glib::object::Cast; 6 use glib::object::IsA; 7 use glib::translate::*; 8 use glib::GString; 9 use glib::StaticType; 10 use glib::ToValue; 11 use gtk_sys; 12 use std::fmt; 13 use IMContext; 14 use InputHints; 15 use InputPurpose; 16 17 glib_wrapper! { 18 pub struct IMMulticontext(Object<gtk_sys::GtkIMMulticontext, gtk_sys::GtkIMMulticontextClass, IMMulticontextClass>) @extends IMContext; 19 20 match fn { 21 get_type => || gtk_sys::gtk_im_multicontext_get_type(), 22 } 23 } 24 25 impl IMMulticontext { new() -> IMMulticontext26 pub fn new() -> IMMulticontext { 27 assert_initialized_main_thread!(); 28 unsafe { IMContext::from_glib_full(gtk_sys::gtk_im_multicontext_new()).unsafe_cast() } 29 } 30 } 31 32 impl Default for IMMulticontext { default() -> Self33 fn default() -> Self { 34 Self::new() 35 } 36 } 37 38 #[derive(Clone, Default)] 39 pub struct IMMulticontextBuilder { 40 input_hints: Option<InputHints>, 41 input_purpose: Option<InputPurpose>, 42 } 43 44 impl IMMulticontextBuilder { new() -> Self45 pub fn new() -> Self { 46 Self::default() 47 } 48 build(self) -> IMMulticontext49 pub fn build(self) -> IMMulticontext { 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(IMMulticontext::static_type(), &properties) 58 .expect("object new") 59 .downcast() 60 .expect("downcast") 61 } 62 input_hints(mut self, input_hints: InputHints) -> Self63 pub fn input_hints(mut self, input_hints: InputHints) -> Self { 64 self.input_hints = Some(input_hints); 65 self 66 } 67 input_purpose(mut self, input_purpose: InputPurpose) -> Self68 pub fn input_purpose(mut self, input_purpose: InputPurpose) -> Self { 69 self.input_purpose = Some(input_purpose); 70 self 71 } 72 } 73 74 pub const NONE_IM_MULTICONTEXT: Option<&IMMulticontext> = None; 75 76 pub trait IMMulticontextExt: 'static { get_context_id(&self) -> Option<GString>77 fn get_context_id(&self) -> Option<GString>; 78 set_context_id(&self, context_id: &str)79 fn set_context_id(&self, context_id: &str); 80 } 81 82 impl<O: IsA<IMMulticontext>> IMMulticontextExt for O { get_context_id(&self) -> Option<GString>83 fn get_context_id(&self) -> Option<GString> { 84 unsafe { 85 from_glib_none(gtk_sys::gtk_im_multicontext_get_context_id( 86 self.as_ref().to_glib_none().0, 87 )) 88 } 89 } 90 set_context_id(&self, context_id: &str)91 fn set_context_id(&self, context_id: &str) { 92 unsafe { 93 gtk_sys::gtk_im_multicontext_set_context_id( 94 self.as_ref().to_glib_none().0, 95 context_id.to_glib_none().0, 96 ); 97 } 98 } 99 } 100 101 impl fmt::Display for IMMulticontext { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result102 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 103 write!(f, "IMMulticontext") 104 } 105 } 106