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};
6use glib::{prelude::*, translate::*};
7use std::fmt;
8
9glib::wrapper! {
10    ///
11    ///
12    /// # Implements
13    ///
14    /// [`IMMulticontextExt`][trait@crate::prelude::IMMulticontextExt], [`IMContextExt`][trait@crate::prelude::IMContextExt], [`trait@glib::ObjectExt`]
15    #[doc(alias = "GtkIMMulticontext")]
16    pub struct IMMulticontext(Object<ffi::GtkIMMulticontext, ffi::GtkIMMulticontextClass>) @extends IMContext;
17
18    match fn {
19        type_ => || ffi::gtk_im_multicontext_get_type(),
20    }
21}
22
23impl IMMulticontext {
24    pub const NONE: Option<&'static IMMulticontext> = None;
25
26    /// Creates a new [`IMMulticontext`][crate::IMMulticontext].
27    ///
28    /// # Returns
29    ///
30    /// a new [`IMMulticontext`][crate::IMMulticontext].
31    #[doc(alias = "gtk_im_multicontext_new")]
32    pub fn new() -> IMMulticontext {
33        assert_initialized_main_thread!();
34        unsafe { IMContext::from_glib_full(ffi::gtk_im_multicontext_new()).unsafe_cast() }
35    }
36
37    // rustdoc-stripper-ignore-next
38    /// Creates a new builder-pattern struct instance to construct [`IMMulticontext`] objects.
39    ///
40    /// This method returns an instance of [`IMMulticontextBuilder`](crate::builders::IMMulticontextBuilder) which can be used to create [`IMMulticontext`] objects.
41    pub fn builder() -> IMMulticontextBuilder {
42        IMMulticontextBuilder::new()
43    }
44}
45
46impl Default for IMMulticontext {
47    fn default() -> Self {
48        Self::new()
49    }
50}
51
52// rustdoc-stripper-ignore-next
53/// A [builder-pattern] type to construct [`IMMulticontext`] objects.
54///
55/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
56#[must_use = "The builder must be built to be used"]
57pub struct IMMulticontextBuilder {
58    builder: glib::object::ObjectBuilder<'static, IMMulticontext>,
59}
60
61impl IMMulticontextBuilder {
62    fn new() -> Self {
63        Self {
64            builder: glib::object::Object::builder(),
65        }
66    }
67
68    pub fn input_hints(self, input_hints: InputHints) -> Self {
69        Self {
70            builder: self.builder.property("input-hints", input_hints),
71        }
72    }
73
74    pub fn input_purpose(self, input_purpose: InputPurpose) -> Self {
75        Self {
76            builder: self.builder.property("input-purpose", input_purpose),
77        }
78    }
79
80    // rustdoc-stripper-ignore-next
81    /// Build the [`IMMulticontext`].
82    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
83    pub fn build(self) -> IMMulticontext {
84        self.builder.build()
85    }
86}
87
88mod sealed {
89    pub trait Sealed {}
90    impl<T: super::IsA<super::IMMulticontext>> Sealed for T {}
91}
92
93/// Trait containing all [`struct@IMMulticontext`] methods.
94///
95/// # Implementors
96///
97/// [`IMMulticontext`][struct@crate::IMMulticontext]
98pub trait IMMulticontextExt: IsA<IMMulticontext> + sealed::Sealed + 'static {
99    /// Gets the id of the currently active slave of the `self`.
100    ///
101    /// # Returns
102    ///
103    /// the id of the currently active slave
104    #[doc(alias = "gtk_im_multicontext_get_context_id")]
105    #[doc(alias = "get_context_id")]
106    fn context_id(&self) -> Option<glib::GString> {
107        unsafe {
108            from_glib_none(ffi::gtk_im_multicontext_get_context_id(
109                self.as_ref().to_glib_none().0,
110            ))
111        }
112    }
113
114    /// Sets the context id for `self`.
115    ///
116    /// This causes the currently active slave of `self` to be
117    /// replaced by the slave corresponding to the new context id.
118    /// ## `context_id`
119    /// the id to use
120    #[doc(alias = "gtk_im_multicontext_set_context_id")]
121    fn set_context_id(&self, context_id: &str) {
122        unsafe {
123            ffi::gtk_im_multicontext_set_context_id(
124                self.as_ref().to_glib_none().0,
125                context_id.to_glib_none().0,
126            );
127        }
128    }
129}
130
131impl<O: IsA<IMMulticontext>> IMMulticontextExt for O {}
132
133impl fmt::Display for IMMulticontext {
134    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
135        f.write_str("IMMulticontext")
136    }
137}