sourceview5/auto/
completion_words.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, CompletionProvider};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkSourceCompletionWords")]
16    pub struct CompletionWords(Object<ffi::GtkSourceCompletionWords, ffi::GtkSourceCompletionWordsClass>) @implements CompletionProvider;
17
18    match fn {
19        type_ => || ffi::gtk_source_completion_words_get_type(),
20    }
21}
22
23impl CompletionWords {
24    pub const NONE: Option<&'static CompletionWords> = None;
25
26    #[doc(alias = "gtk_source_completion_words_new")]
27    pub fn new(title: Option<&str>) -> CompletionWords {
28        assert_initialized_main_thread!();
29        unsafe { from_glib_full(ffi::gtk_source_completion_words_new(title.to_glib_none().0)) }
30    }
31
32    // rustdoc-stripper-ignore-next
33    /// Creates a new builder-pattern struct instance to construct [`CompletionWords`] objects.
34    ///
35    /// This method returns an instance of [`CompletionWordsBuilder`](crate::builders::CompletionWordsBuilder) which can be used to create [`CompletionWords`] objects.
36    pub fn builder() -> CompletionWordsBuilder {
37        CompletionWordsBuilder::new()
38    }
39}
40
41impl Default for CompletionWords {
42    fn default() -> Self {
43        glib::object::Object::new::<Self>()
44    }
45}
46
47// rustdoc-stripper-ignore-next
48/// A [builder-pattern] type to construct [`CompletionWords`] objects.
49///
50/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
51#[must_use = "The builder must be built to be used"]
52pub struct CompletionWordsBuilder {
53    builder: glib::object::ObjectBuilder<'static, CompletionWords>,
54}
55
56impl CompletionWordsBuilder {
57    fn new() -> Self {
58        Self {
59            builder: glib::object::Object::builder(),
60        }
61    }
62
63    pub fn minimum_word_size(self, minimum_word_size: u32) -> Self {
64        Self {
65            builder: self
66                .builder
67                .property("minimum-word-size", minimum_word_size),
68        }
69    }
70
71    pub fn priority(self, priority: i32) -> Self {
72        Self {
73            builder: self.builder.property("priority", priority),
74        }
75    }
76
77    pub fn proposals_batch_size(self, proposals_batch_size: u32) -> Self {
78        Self {
79            builder: self
80                .builder
81                .property("proposals-batch-size", proposals_batch_size),
82        }
83    }
84
85    pub fn scan_batch_size(self, scan_batch_size: u32) -> Self {
86        Self {
87            builder: self.builder.property("scan-batch-size", scan_batch_size),
88        }
89    }
90
91    pub fn title(self, title: impl Into<glib::GString>) -> Self {
92        Self {
93            builder: self.builder.property("title", title.into()),
94        }
95    }
96
97    // rustdoc-stripper-ignore-next
98    /// Build the [`CompletionWords`].
99    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
100    pub fn build(self) -> CompletionWords {
101        self.builder.build()
102    }
103}
104
105mod sealed {
106    pub trait Sealed {}
107    impl<T: super::IsA<super::CompletionWords>> Sealed for T {}
108}
109
110pub trait CompletionWordsExt: IsA<CompletionWords> + sealed::Sealed + 'static {
111    #[doc(alias = "gtk_source_completion_words_register")]
112    fn register(&self, buffer: &impl IsA<gtk::TextBuffer>) {
113        unsafe {
114            ffi::gtk_source_completion_words_register(
115                self.as_ref().to_glib_none().0,
116                buffer.as_ref().to_glib_none().0,
117            );
118        }
119    }
120
121    #[doc(alias = "gtk_source_completion_words_unregister")]
122    fn unregister(&self, buffer: &impl IsA<gtk::TextBuffer>) {
123        unsafe {
124            ffi::gtk_source_completion_words_unregister(
125                self.as_ref().to_glib_none().0,
126                buffer.as_ref().to_glib_none().0,
127            );
128        }
129    }
130
131    #[doc(alias = "minimum-word-size")]
132    fn minimum_word_size(&self) -> u32 {
133        ObjectExt::property(self.as_ref(), "minimum-word-size")
134    }
135
136    #[doc(alias = "minimum-word-size")]
137    fn set_minimum_word_size(&self, minimum_word_size: u32) {
138        ObjectExt::set_property(self.as_ref(), "minimum-word-size", minimum_word_size)
139    }
140
141    fn priority(&self) -> i32 {
142        ObjectExt::property(self.as_ref(), "priority")
143    }
144
145    fn set_priority(&self, priority: i32) {
146        ObjectExt::set_property(self.as_ref(), "priority", priority)
147    }
148
149    #[doc(alias = "proposals-batch-size")]
150    fn proposals_batch_size(&self) -> u32 {
151        ObjectExt::property(self.as_ref(), "proposals-batch-size")
152    }
153
154    #[doc(alias = "proposals-batch-size")]
155    fn set_proposals_batch_size(&self, proposals_batch_size: u32) {
156        ObjectExt::set_property(self.as_ref(), "proposals-batch-size", proposals_batch_size)
157    }
158
159    #[doc(alias = "scan-batch-size")]
160    fn scan_batch_size(&self) -> u32 {
161        ObjectExt::property(self.as_ref(), "scan-batch-size")
162    }
163
164    #[doc(alias = "scan-batch-size")]
165    fn set_scan_batch_size(&self, scan_batch_size: u32) {
166        ObjectExt::set_property(self.as_ref(), "scan-batch-size", scan_batch_size)
167    }
168
169    fn set_title(&self, title: Option<&str>) {
170        ObjectExt::set_property(self.as_ref(), "title", title)
171    }
172
173    #[doc(alias = "minimum-word-size")]
174    fn connect_minimum_word_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
175        unsafe extern "C" fn notify_minimum_word_size_trampoline<
176            P: IsA<CompletionWords>,
177            F: Fn(&P) + 'static,
178        >(
179            this: *mut ffi::GtkSourceCompletionWords,
180            _param_spec: glib::ffi::gpointer,
181            f: glib::ffi::gpointer,
182        ) {
183            let f: &F = &*(f as *const F);
184            f(CompletionWords::from_glib_borrow(this).unsafe_cast_ref())
185        }
186        unsafe {
187            let f: Box_<F> = Box_::new(f);
188            connect_raw(
189                self.as_ptr() as *mut _,
190                b"notify::minimum-word-size\0".as_ptr() as *const _,
191                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
192                    notify_minimum_word_size_trampoline::<Self, F> as *const (),
193                )),
194                Box_::into_raw(f),
195            )
196        }
197    }
198
199    #[doc(alias = "priority")]
200    fn connect_priority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
201        unsafe extern "C" fn notify_priority_trampoline<
202            P: IsA<CompletionWords>,
203            F: Fn(&P) + 'static,
204        >(
205            this: *mut ffi::GtkSourceCompletionWords,
206            _param_spec: glib::ffi::gpointer,
207            f: glib::ffi::gpointer,
208        ) {
209            let f: &F = &*(f as *const F);
210            f(CompletionWords::from_glib_borrow(this).unsafe_cast_ref())
211        }
212        unsafe {
213            let f: Box_<F> = Box_::new(f);
214            connect_raw(
215                self.as_ptr() as *mut _,
216                b"notify::priority\0".as_ptr() as *const _,
217                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
218                    notify_priority_trampoline::<Self, F> as *const (),
219                )),
220                Box_::into_raw(f),
221            )
222        }
223    }
224
225    #[doc(alias = "proposals-batch-size")]
226    fn connect_proposals_batch_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
227        unsafe extern "C" fn notify_proposals_batch_size_trampoline<
228            P: IsA<CompletionWords>,
229            F: Fn(&P) + 'static,
230        >(
231            this: *mut ffi::GtkSourceCompletionWords,
232            _param_spec: glib::ffi::gpointer,
233            f: glib::ffi::gpointer,
234        ) {
235            let f: &F = &*(f as *const F);
236            f(CompletionWords::from_glib_borrow(this).unsafe_cast_ref())
237        }
238        unsafe {
239            let f: Box_<F> = Box_::new(f);
240            connect_raw(
241                self.as_ptr() as *mut _,
242                b"notify::proposals-batch-size\0".as_ptr() as *const _,
243                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
244                    notify_proposals_batch_size_trampoline::<Self, F> as *const (),
245                )),
246                Box_::into_raw(f),
247            )
248        }
249    }
250
251    #[doc(alias = "scan-batch-size")]
252    fn connect_scan_batch_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
253        unsafe extern "C" fn notify_scan_batch_size_trampoline<
254            P: IsA<CompletionWords>,
255            F: Fn(&P) + 'static,
256        >(
257            this: *mut ffi::GtkSourceCompletionWords,
258            _param_spec: glib::ffi::gpointer,
259            f: glib::ffi::gpointer,
260        ) {
261            let f: &F = &*(f as *const F);
262            f(CompletionWords::from_glib_borrow(this).unsafe_cast_ref())
263        }
264        unsafe {
265            let f: Box_<F> = Box_::new(f);
266            connect_raw(
267                self.as_ptr() as *mut _,
268                b"notify::scan-batch-size\0".as_ptr() as *const _,
269                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
270                    notify_scan_batch_size_trampoline::<Self, F> as *const (),
271                )),
272                Box_::into_raw(f),
273            )
274        }
275    }
276
277    #[doc(alias = "title")]
278    fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
279        unsafe extern "C" fn notify_title_trampoline<
280            P: IsA<CompletionWords>,
281            F: Fn(&P) + 'static,
282        >(
283            this: *mut ffi::GtkSourceCompletionWords,
284            _param_spec: glib::ffi::gpointer,
285            f: glib::ffi::gpointer,
286        ) {
287            let f: &F = &*(f as *const F);
288            f(CompletionWords::from_glib_borrow(this).unsafe_cast_ref())
289        }
290        unsafe {
291            let f: Box_<F> = Box_::new(f);
292            connect_raw(
293                self.as_ptr() as *mut _,
294                b"notify::title\0".as_ptr() as *const _,
295                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
296                    notify_title_trampoline::<Self, F> as *const (),
297                )),
298                Box_::into_raw(f),
299            )
300        }
301    }
302}
303
304impl<O: IsA<CompletionWords>> CompletionWordsExt for O {}