sourceview/auto/
search_settings.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
5#[cfg(any(feature = "v3_10", feature = "dox"))]
6use glib::object::Cast;
7#[cfg(any(feature = "v3_10", feature = "dox"))]
8use glib::object::IsA;
9#[cfg(any(feature = "v3_10", feature = "dox"))]
10use glib::signal::connect_raw;
11#[cfg(any(feature = "v3_10", feature = "dox"))]
12use glib::signal::SignalHandlerId;
13use glib::translate::*;
14#[cfg(any(feature = "v3_10", feature = "dox"))]
15use glib::GString;
16#[cfg(any(feature = "v3_10", feature = "dox"))]
17use glib::StaticType;
18#[cfg(any(feature = "v3_10", feature = "dox"))]
19use glib::ToValue;
20#[cfg(any(feature = "v3_10", feature = "dox"))]
21use glib_sys;
22use gtk_source_sys;
23#[cfg(any(feature = "v3_10", feature = "dox"))]
24use std::boxed::Box as Box_;
25use std::fmt;
26#[cfg(any(feature = "v3_10", feature = "dox"))]
27use std::mem::transmute;
28
29glib_wrapper! {
30    pub struct SearchSettings(Object<gtk_source_sys::GtkSourceSearchSettings, gtk_source_sys::GtkSourceSearchSettingsClass, SearchSettingsClass>);
31
32    match fn {
33        get_type => || gtk_source_sys::gtk_source_search_settings_get_type(),
34    }
35}
36
37impl SearchSettings {
38    #[cfg(any(feature = "v3_10", feature = "dox"))]
39    pub fn new() -> SearchSettings {
40        assert_initialized_main_thread!();
41        unsafe { from_glib_full(gtk_source_sys::gtk_source_search_settings_new()) }
42    }
43}
44
45#[cfg(any(feature = "v3_10", feature = "dox"))]
46impl Default for SearchSettings {
47    fn default() -> Self {
48        Self::new()
49    }
50}
51
52#[derive(Clone, Default)]
53pub struct SearchSettingsBuilder {
54    #[cfg(any(feature = "v3_10", feature = "dox"))]
55    at_word_boundaries: Option<bool>,
56    #[cfg(any(feature = "v3_10", feature = "dox"))]
57    case_sensitive: Option<bool>,
58    #[cfg(any(feature = "v3_10", feature = "dox"))]
59    regex_enabled: Option<bool>,
60    #[cfg(any(feature = "v3_10", feature = "dox"))]
61    search_text: Option<String>,
62    #[cfg(any(feature = "v3_10", feature = "dox"))]
63    wrap_around: Option<bool>,
64}
65
66impl SearchSettingsBuilder {
67    pub fn new() -> Self {
68        Self::default()
69    }
70
71    pub fn build(self) -> SearchSettings {
72        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
73        #[cfg(any(feature = "v3_10", feature = "dox"))]
74        {
75            if let Some(ref at_word_boundaries) = self.at_word_boundaries {
76                properties.push(("at-word-boundaries", at_word_boundaries));
77            }
78        }
79        #[cfg(any(feature = "v3_10", feature = "dox"))]
80        {
81            if let Some(ref case_sensitive) = self.case_sensitive {
82                properties.push(("case-sensitive", case_sensitive));
83            }
84        }
85        #[cfg(any(feature = "v3_10", feature = "dox"))]
86        {
87            if let Some(ref regex_enabled) = self.regex_enabled {
88                properties.push(("regex-enabled", regex_enabled));
89            }
90        }
91        #[cfg(any(feature = "v3_10", feature = "dox"))]
92        {
93            if let Some(ref search_text) = self.search_text {
94                properties.push(("search-text", search_text));
95            }
96        }
97        #[cfg(any(feature = "v3_10", feature = "dox"))]
98        {
99            if let Some(ref wrap_around) = self.wrap_around {
100                properties.push(("wrap-around", wrap_around));
101            }
102        }
103        glib::Object::new(SearchSettings::static_type(), &properties)
104            .expect("object new")
105            .downcast()
106            .expect("downcast")
107    }
108
109    #[cfg(any(feature = "v3_10", feature = "dox"))]
110    pub fn at_word_boundaries(mut self, at_word_boundaries: bool) -> Self {
111        self.at_word_boundaries = Some(at_word_boundaries);
112        self
113    }
114
115    #[cfg(any(feature = "v3_10", feature = "dox"))]
116    pub fn case_sensitive(mut self, case_sensitive: bool) -> Self {
117        self.case_sensitive = Some(case_sensitive);
118        self
119    }
120
121    #[cfg(any(feature = "v3_10", feature = "dox"))]
122    pub fn regex_enabled(mut self, regex_enabled: bool) -> Self {
123        self.regex_enabled = Some(regex_enabled);
124        self
125    }
126
127    #[cfg(any(feature = "v3_10", feature = "dox"))]
128    pub fn search_text(mut self, search_text: &str) -> Self {
129        self.search_text = Some(search_text.to_string());
130        self
131    }
132
133    #[cfg(any(feature = "v3_10", feature = "dox"))]
134    pub fn wrap_around(mut self, wrap_around: bool) -> Self {
135        self.wrap_around = Some(wrap_around);
136        self
137    }
138}
139
140pub const NONE_SEARCH_SETTINGS: Option<&SearchSettings> = None;
141
142pub trait SearchSettingsExt: 'static {
143    #[cfg(any(feature = "v3_10", feature = "dox"))]
144    fn get_at_word_boundaries(&self) -> bool;
145
146    #[cfg(any(feature = "v3_10", feature = "dox"))]
147    fn get_case_sensitive(&self) -> bool;
148
149    #[cfg(any(feature = "v3_10", feature = "dox"))]
150    fn get_regex_enabled(&self) -> bool;
151
152    #[cfg(any(feature = "v3_10", feature = "dox"))]
153    fn get_search_text(&self) -> Option<GString>;
154
155    #[cfg(any(feature = "v3_10", feature = "dox"))]
156    fn get_wrap_around(&self) -> bool;
157
158    #[cfg(any(feature = "v3_10", feature = "dox"))]
159    fn set_at_word_boundaries(&self, at_word_boundaries: bool);
160
161    #[cfg(any(feature = "v3_10", feature = "dox"))]
162    fn set_case_sensitive(&self, case_sensitive: bool);
163
164    #[cfg(any(feature = "v3_10", feature = "dox"))]
165    fn set_regex_enabled(&self, regex_enabled: bool);
166
167    #[cfg(any(feature = "v3_10", feature = "dox"))]
168    fn set_search_text(&self, search_text: Option<&str>);
169
170    #[cfg(any(feature = "v3_10", feature = "dox"))]
171    fn set_wrap_around(&self, wrap_around: bool);
172
173    #[cfg(any(feature = "v3_10", feature = "dox"))]
174    fn connect_property_at_word_boundaries_notify<F: Fn(&Self) + 'static>(
175        &self,
176        f: F,
177    ) -> SignalHandlerId;
178
179    #[cfg(any(feature = "v3_10", feature = "dox"))]
180    fn connect_property_case_sensitive_notify<F: Fn(&Self) + 'static>(
181        &self,
182        f: F,
183    ) -> SignalHandlerId;
184
185    #[cfg(any(feature = "v3_10", feature = "dox"))]
186    fn connect_property_regex_enabled_notify<F: Fn(&Self) + 'static>(
187        &self,
188        f: F,
189    ) -> SignalHandlerId;
190
191    #[cfg(any(feature = "v3_10", feature = "dox"))]
192    fn connect_property_search_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
193
194    #[cfg(any(feature = "v3_10", feature = "dox"))]
195    fn connect_property_wrap_around_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
196}
197
198impl<O: IsA<SearchSettings>> SearchSettingsExt for O {
199    #[cfg(any(feature = "v3_10", feature = "dox"))]
200    fn get_at_word_boundaries(&self) -> bool {
201        unsafe {
202            from_glib(
203                gtk_source_sys::gtk_source_search_settings_get_at_word_boundaries(
204                    self.as_ref().to_glib_none().0,
205                ),
206            )
207        }
208    }
209
210    #[cfg(any(feature = "v3_10", feature = "dox"))]
211    fn get_case_sensitive(&self) -> bool {
212        unsafe {
213            from_glib(
214                gtk_source_sys::gtk_source_search_settings_get_case_sensitive(
215                    self.as_ref().to_glib_none().0,
216                ),
217            )
218        }
219    }
220
221    #[cfg(any(feature = "v3_10", feature = "dox"))]
222    fn get_regex_enabled(&self) -> bool {
223        unsafe {
224            from_glib(
225                gtk_source_sys::gtk_source_search_settings_get_regex_enabled(
226                    self.as_ref().to_glib_none().0,
227                ),
228            )
229        }
230    }
231
232    #[cfg(any(feature = "v3_10", feature = "dox"))]
233    fn get_search_text(&self) -> Option<GString> {
234        unsafe {
235            from_glib_none(gtk_source_sys::gtk_source_search_settings_get_search_text(
236                self.as_ref().to_glib_none().0,
237            ))
238        }
239    }
240
241    #[cfg(any(feature = "v3_10", feature = "dox"))]
242    fn get_wrap_around(&self) -> bool {
243        unsafe {
244            from_glib(gtk_source_sys::gtk_source_search_settings_get_wrap_around(
245                self.as_ref().to_glib_none().0,
246            ))
247        }
248    }
249
250    #[cfg(any(feature = "v3_10", feature = "dox"))]
251    fn set_at_word_boundaries(&self, at_word_boundaries: bool) {
252        unsafe {
253            gtk_source_sys::gtk_source_search_settings_set_at_word_boundaries(
254                self.as_ref().to_glib_none().0,
255                at_word_boundaries.to_glib(),
256            );
257        }
258    }
259
260    #[cfg(any(feature = "v3_10", feature = "dox"))]
261    fn set_case_sensitive(&self, case_sensitive: bool) {
262        unsafe {
263            gtk_source_sys::gtk_source_search_settings_set_case_sensitive(
264                self.as_ref().to_glib_none().0,
265                case_sensitive.to_glib(),
266            );
267        }
268    }
269
270    #[cfg(any(feature = "v3_10", feature = "dox"))]
271    fn set_regex_enabled(&self, regex_enabled: bool) {
272        unsafe {
273            gtk_source_sys::gtk_source_search_settings_set_regex_enabled(
274                self.as_ref().to_glib_none().0,
275                regex_enabled.to_glib(),
276            );
277        }
278    }
279
280    #[cfg(any(feature = "v3_10", feature = "dox"))]
281    fn set_search_text(&self, search_text: Option<&str>) {
282        unsafe {
283            gtk_source_sys::gtk_source_search_settings_set_search_text(
284                self.as_ref().to_glib_none().0,
285                search_text.to_glib_none().0,
286            );
287        }
288    }
289
290    #[cfg(any(feature = "v3_10", feature = "dox"))]
291    fn set_wrap_around(&self, wrap_around: bool) {
292        unsafe {
293            gtk_source_sys::gtk_source_search_settings_set_wrap_around(
294                self.as_ref().to_glib_none().0,
295                wrap_around.to_glib(),
296            );
297        }
298    }
299
300    #[cfg(any(feature = "v3_10", feature = "dox"))]
301    fn connect_property_at_word_boundaries_notify<F: Fn(&Self) + 'static>(
302        &self,
303        f: F,
304    ) -> SignalHandlerId {
305        unsafe extern "C" fn notify_at_word_boundaries_trampoline<P, F: Fn(&P) + 'static>(
306            this: *mut gtk_source_sys::GtkSourceSearchSettings,
307            _param_spec: glib_sys::gpointer,
308            f: glib_sys::gpointer,
309        ) where
310            P: IsA<SearchSettings>,
311        {
312            let f: &F = &*(f as *const F);
313            f(&SearchSettings::from_glib_borrow(this).unsafe_cast_ref())
314        }
315        unsafe {
316            let f: Box_<F> = Box_::new(f);
317            connect_raw(
318                self.as_ptr() as *mut _,
319                b"notify::at-word-boundaries\0".as_ptr() as *const _,
320                Some(transmute::<_, unsafe extern "C" fn()>(
321                    notify_at_word_boundaries_trampoline::<Self, F> as *const (),
322                )),
323                Box_::into_raw(f),
324            )
325        }
326    }
327
328    #[cfg(any(feature = "v3_10", feature = "dox"))]
329    fn connect_property_case_sensitive_notify<F: Fn(&Self) + 'static>(
330        &self,
331        f: F,
332    ) -> SignalHandlerId {
333        unsafe extern "C" fn notify_case_sensitive_trampoline<P, F: Fn(&P) + 'static>(
334            this: *mut gtk_source_sys::GtkSourceSearchSettings,
335            _param_spec: glib_sys::gpointer,
336            f: glib_sys::gpointer,
337        ) where
338            P: IsA<SearchSettings>,
339        {
340            let f: &F = &*(f as *const F);
341            f(&SearchSettings::from_glib_borrow(this).unsafe_cast_ref())
342        }
343        unsafe {
344            let f: Box_<F> = Box_::new(f);
345            connect_raw(
346                self.as_ptr() as *mut _,
347                b"notify::case-sensitive\0".as_ptr() as *const _,
348                Some(transmute::<_, unsafe extern "C" fn()>(
349                    notify_case_sensitive_trampoline::<Self, F> as *const (),
350                )),
351                Box_::into_raw(f),
352            )
353        }
354    }
355
356    #[cfg(any(feature = "v3_10", feature = "dox"))]
357    fn connect_property_regex_enabled_notify<F: Fn(&Self) + 'static>(
358        &self,
359        f: F,
360    ) -> SignalHandlerId {
361        unsafe extern "C" fn notify_regex_enabled_trampoline<P, F: Fn(&P) + 'static>(
362            this: *mut gtk_source_sys::GtkSourceSearchSettings,
363            _param_spec: glib_sys::gpointer,
364            f: glib_sys::gpointer,
365        ) where
366            P: IsA<SearchSettings>,
367        {
368            let f: &F = &*(f as *const F);
369            f(&SearchSettings::from_glib_borrow(this).unsafe_cast_ref())
370        }
371        unsafe {
372            let f: Box_<F> = Box_::new(f);
373            connect_raw(
374                self.as_ptr() as *mut _,
375                b"notify::regex-enabled\0".as_ptr() as *const _,
376                Some(transmute::<_, unsafe extern "C" fn()>(
377                    notify_regex_enabled_trampoline::<Self, F> as *const (),
378                )),
379                Box_::into_raw(f),
380            )
381        }
382    }
383
384    #[cfg(any(feature = "v3_10", feature = "dox"))]
385    fn connect_property_search_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
386        unsafe extern "C" fn notify_search_text_trampoline<P, F: Fn(&P) + 'static>(
387            this: *mut gtk_source_sys::GtkSourceSearchSettings,
388            _param_spec: glib_sys::gpointer,
389            f: glib_sys::gpointer,
390        ) where
391            P: IsA<SearchSettings>,
392        {
393            let f: &F = &*(f as *const F);
394            f(&SearchSettings::from_glib_borrow(this).unsafe_cast_ref())
395        }
396        unsafe {
397            let f: Box_<F> = Box_::new(f);
398            connect_raw(
399                self.as_ptr() as *mut _,
400                b"notify::search-text\0".as_ptr() as *const _,
401                Some(transmute::<_, unsafe extern "C" fn()>(
402                    notify_search_text_trampoline::<Self, F> as *const (),
403                )),
404                Box_::into_raw(f),
405            )
406        }
407    }
408
409    #[cfg(any(feature = "v3_10", feature = "dox"))]
410    fn connect_property_wrap_around_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
411        unsafe extern "C" fn notify_wrap_around_trampoline<P, F: Fn(&P) + 'static>(
412            this: *mut gtk_source_sys::GtkSourceSearchSettings,
413            _param_spec: glib_sys::gpointer,
414            f: glib_sys::gpointer,
415        ) where
416            P: IsA<SearchSettings>,
417        {
418            let f: &F = &*(f as *const F);
419            f(&SearchSettings::from_glib_borrow(this).unsafe_cast_ref())
420        }
421        unsafe {
422            let f: Box_<F> = Box_::new(f);
423            connect_raw(
424                self.as_ptr() as *mut _,
425                b"notify::wrap-around\0".as_ptr() as *const _,
426                Some(transmute::<_, unsafe extern "C" fn()>(
427                    notify_wrap_around_trampoline::<Self, F> as *const (),
428                )),
429                Box_::into_raw(f),
430            )
431        }
432    }
433}
434
435impl fmt::Display for SearchSettings {
436    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
437        write!(f, "SearchSettings")
438    }
439}