Skip to main content

gtk/auto/
im_multicontext.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 crate::{IMContext, InputHints, InputPurpose, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    ///
10    ///
11    /// # Implements
12    ///
13    /// [`IMMulticontextExt`][trait@crate::prelude::IMMulticontextExt], [`IMContextExt`][trait@crate::prelude::IMContextExt], [`trait@glib::ObjectExt`]
14    #[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    /// Creates a new [`IMMulticontext`][crate::IMMulticontext].
26    ///
27    /// # Returns
28    ///
29    /// a new [`IMMulticontext`][crate::IMMulticontext].
30    #[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    // rustdoc-stripper-ignore-next
37    /// Creates a new builder-pattern struct instance to construct [`IMMulticontext`] objects.
38    ///
39    /// This method returns an instance of [`IMMulticontextBuilder`](crate::builders::IMMulticontextBuilder) which can be used to create [`IMMulticontext`] objects.
40    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// rustdoc-stripper-ignore-next
52/// A [builder-pattern] type to construct [`IMMulticontext`] objects.
53///
54/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
55#[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    // rustdoc-stripper-ignore-next
80    /// Build the [`IMMulticontext`].
81    #[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
88/// Trait containing all [`struct@IMMulticontext`] methods.
89///
90/// # Implementors
91///
92/// [`IMMulticontext`][struct@crate::IMMulticontext]
93pub trait IMMulticontextExt: IsA<IMMulticontext> + 'static {
94    /// Gets the id of the currently active slave of the `self`.
95    ///
96    /// # Returns
97    ///
98    /// the id of the currently active slave
99    #[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    /// Sets the context id for `self`.
110    ///
111    /// This causes the currently active slave of `self` to be
112    /// replaced by the slave corresponding to the new context id.
113    /// ## `context_id`
114    /// the id to use
115    #[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 {}