sourceview/auto/
search_context.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 gio;
7#[cfg(any(feature = "v3_10", feature = "dox"))]
8use gio_sys;
9#[cfg(any(feature = "v3_10", feature = "dox"))]
10use glib;
11#[cfg(any(feature = "v3_10", feature = "dox"))]
12use glib::object::Cast;
13#[cfg(any(feature = "v3_10", feature = "dox"))]
14use glib::object::IsA;
15#[cfg(any(feature = "v3_10", feature = "dox"))]
16use glib::signal::connect_raw;
17#[cfg(any(feature = "v3_10", feature = "dox"))]
18use glib::signal::SignalHandlerId;
19use glib::translate::*;
20#[cfg(any(feature = "v3_10", feature = "dox"))]
21use glib::StaticType;
22#[cfg(any(feature = "v3_10", feature = "dox"))]
23use glib::ToValue;
24#[cfg(any(feature = "v3_10", feature = "dox"))]
25use glib_sys;
26#[cfg(any(feature = "v3_10", feature = "dox"))]
27use gobject_sys;
28#[cfg(any(feature = "v3_10", feature = "dox"))]
29use gtk;
30use gtk_source_sys;
31#[cfg(any(feature = "v3_10", feature = "dox"))]
32use std::boxed::Box as Box_;
33use std::fmt;
34#[cfg(any(feature = "v3_22", feature = "dox"))]
35use std::mem;
36#[cfg(any(feature = "v3_10", feature = "dox"))]
37use std::mem::transmute;
38#[cfg(any(feature = "v3_10", feature = "dox"))]
39use std::pin::Pin;
40#[cfg(any(feature = "v3_10", feature = "dox"))]
41use std::ptr;
42#[cfg(any(feature = "v3_10", feature = "dox"))]
43use Buffer;
44#[cfg(any(feature = "v3_10", feature = "dox"))]
45use SearchSettings;
46#[cfg(any(feature = "v3_16", feature = "dox"))]
47use Style;
48
49glib_wrapper! {
50    pub struct SearchContext(Object<gtk_source_sys::GtkSourceSearchContext, gtk_source_sys::GtkSourceSearchContextClass, SearchContextClass>);
51
52    match fn {
53        get_type => || gtk_source_sys::gtk_source_search_context_get_type(),
54    }
55}
56
57impl SearchContext {
58    #[cfg(any(feature = "v3_10", feature = "dox"))]
59    pub fn new<P: IsA<Buffer>, Q: IsA<SearchSettings>>(
60        buffer: &P,
61        settings: Option<&Q>,
62    ) -> SearchContext {
63        skip_assert_initialized!();
64        unsafe {
65            from_glib_full(gtk_source_sys::gtk_source_search_context_new(
66                buffer.as_ref().to_glib_none().0,
67                settings.map(|p| p.as_ref()).to_glib_none().0,
68            ))
69        }
70    }
71}
72
73#[derive(Clone, Default)]
74pub struct SearchContextBuilder {
75    #[cfg(any(feature = "v3_10", feature = "dox"))]
76    buffer: Option<Buffer>,
77    #[cfg(any(feature = "v3_10", feature = "dox"))]
78    highlight: Option<bool>,
79    #[cfg(any(feature = "v3_16", feature = "dox"))]
80    match_style: Option<Style>,
81    #[cfg(any(feature = "v3_10", feature = "dox"))]
82    settings: Option<SearchSettings>,
83}
84
85impl SearchContextBuilder {
86    pub fn new() -> Self {
87        Self::default()
88    }
89
90    pub fn build(self) -> SearchContext {
91        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
92        #[cfg(any(feature = "v3_10", feature = "dox"))]
93        {
94            if let Some(ref buffer) = self.buffer {
95                properties.push(("buffer", buffer));
96            }
97        }
98        #[cfg(any(feature = "v3_10", feature = "dox"))]
99        {
100            if let Some(ref highlight) = self.highlight {
101                properties.push(("highlight", highlight));
102            }
103        }
104        #[cfg(any(feature = "v3_16", feature = "dox"))]
105        {
106            if let Some(ref match_style) = self.match_style {
107                properties.push(("match-style", match_style));
108            }
109        }
110        #[cfg(any(feature = "v3_10", feature = "dox"))]
111        {
112            if let Some(ref settings) = self.settings {
113                properties.push(("settings", settings));
114            }
115        }
116        glib::Object::new(SearchContext::static_type(), &properties)
117            .expect("object new")
118            .downcast()
119            .expect("downcast")
120    }
121
122    #[cfg(any(feature = "v3_10", feature = "dox"))]
123    pub fn buffer<P: IsA<Buffer>>(mut self, buffer: &P) -> Self {
124        self.buffer = Some(buffer.clone().upcast());
125        self
126    }
127
128    #[cfg(any(feature = "v3_10", feature = "dox"))]
129    pub fn highlight(mut self, highlight: bool) -> Self {
130        self.highlight = Some(highlight);
131        self
132    }
133
134    #[cfg(any(feature = "v3_16", feature = "dox"))]
135    pub fn match_style(mut self, match_style: &Style) -> Self {
136        self.match_style = Some(match_style.clone());
137        self
138    }
139
140    #[cfg(any(feature = "v3_10", feature = "dox"))]
141    pub fn settings<P: IsA<SearchSettings>>(mut self, settings: &P) -> Self {
142        self.settings = Some(settings.clone().upcast());
143        self
144    }
145}
146
147pub const NONE_SEARCH_CONTEXT: Option<&SearchContext> = None;
148
149pub trait SearchContextExt: 'static {
150    #[cfg_attr(feature = "v3_22", deprecated)]
151    #[cfg(any(feature = "v3_10", feature = "dox"))]
152    fn backward(&self, iter: &gtk::TextIter) -> Option<(gtk::TextIter, gtk::TextIter)>;
153
154    #[cfg(any(feature = "v3_22", feature = "dox"))]
155    fn backward2(&self, iter: &gtk::TextIter) -> Option<(gtk::TextIter, gtk::TextIter, bool)>;
156
157    #[cfg(any(feature = "v3_10", feature = "dox"))]
158    fn backward_async<
159        P: IsA<gio::Cancellable>,
160        Q: FnOnce(Result<(gtk::TextIter, gtk::TextIter), glib::Error>) + Send + 'static,
161    >(
162        &self,
163        iter: &gtk::TextIter,
164        cancellable: Option<&P>,
165        callback: Q,
166    );
167
168    #[cfg(any(feature = "v3_10", feature = "dox"))]
169    fn backward_async_future(
170        &self,
171        iter: &gtk::TextIter,
172    ) -> Pin<
173        Box_<
174            dyn std::future::Future<Output = Result<(gtk::TextIter, gtk::TextIter), glib::Error>>
175                + 'static,
176        >,
177    >;
178
179    //#[cfg(any(feature = "v3_22", feature = "dox"))]
180    //fn backward_finish2(&self, result: /*Ignored*/&gio::AsyncResult) -> Result<(gtk::TextIter, gtk::TextIter, bool), glib::Error>;
181
182    #[cfg_attr(feature = "v3_22", deprecated)]
183    #[cfg(any(feature = "v3_10", feature = "dox"))]
184    fn forward(&self, iter: &gtk::TextIter) -> Option<(gtk::TextIter, gtk::TextIter)>;
185
186    #[cfg(any(feature = "v3_22", feature = "dox"))]
187    fn forward2(&self, iter: &gtk::TextIter) -> Option<(gtk::TextIter, gtk::TextIter, bool)>;
188
189    #[cfg(any(feature = "v3_10", feature = "dox"))]
190    fn forward_async<
191        P: IsA<gio::Cancellable>,
192        Q: FnOnce(Result<(gtk::TextIter, gtk::TextIter), glib::Error>) + Send + 'static,
193    >(
194        &self,
195        iter: &gtk::TextIter,
196        cancellable: Option<&P>,
197        callback: Q,
198    );
199
200    #[cfg(any(feature = "v3_10", feature = "dox"))]
201    fn forward_async_future(
202        &self,
203        iter: &gtk::TextIter,
204    ) -> Pin<
205        Box_<
206            dyn std::future::Future<Output = Result<(gtk::TextIter, gtk::TextIter), glib::Error>>
207                + 'static,
208        >,
209    >;
210
211    //#[cfg(any(feature = "v3_22", feature = "dox"))]
212    //fn forward_finish2(&self, result: /*Ignored*/&gio::AsyncResult) -> Result<(gtk::TextIter, gtk::TextIter, bool), glib::Error>;
213
214    #[cfg(any(feature = "v3_10", feature = "dox"))]
215    fn get_buffer(&self) -> Option<Buffer>;
216
217    #[cfg(any(feature = "v3_10", feature = "dox"))]
218    fn get_highlight(&self) -> bool;
219
220    #[cfg(any(feature = "v3_16", feature = "dox"))]
221    fn get_match_style(&self) -> Option<Style>;
222
223    #[cfg(any(feature = "v3_10", feature = "dox"))]
224    fn get_occurrence_position(
225        &self,
226        match_start: &gtk::TextIter,
227        match_end: &gtk::TextIter,
228    ) -> i32;
229
230    #[cfg(any(feature = "v3_10", feature = "dox"))]
231    fn get_occurrences_count(&self) -> i32;
232
233    #[cfg(any(feature = "v3_10", feature = "dox"))]
234    fn get_regex_error(&self) -> Option<glib::Error>;
235
236    #[cfg(any(feature = "v3_10", feature = "dox"))]
237    fn get_settings(&self) -> Option<SearchSettings>;
238
239    #[cfg_attr(feature = "v3_22", deprecated)]
240    #[cfg(any(feature = "v3_10", feature = "dox"))]
241    fn replace(
242        &self,
243        match_start: &gtk::TextIter,
244        match_end: &gtk::TextIter,
245        replace: &str,
246    ) -> Result<(), glib::Error>;
247
248    #[cfg(any(feature = "v3_22", feature = "dox"))]
249    fn replace2(
250        &self,
251        match_start: &mut gtk::TextIter,
252        match_end: &mut gtk::TextIter,
253        replace: &str,
254    ) -> Result<(), glib::Error>;
255
256    #[cfg(any(feature = "v3_10", feature = "dox"))]
257    fn replace_all(&self, replace: &str) -> Result<u32, glib::Error>;
258
259    #[cfg(any(feature = "v3_10", feature = "dox"))]
260    fn set_highlight(&self, highlight: bool);
261
262    #[cfg(any(feature = "v3_16", feature = "dox"))]
263    fn set_match_style(&self, match_style: Option<&Style>);
264
265    #[cfg_attr(feature = "v3_24", deprecated)]
266    #[cfg(any(feature = "v3_10", feature = "dox"))]
267    fn set_settings<P: IsA<SearchSettings>>(&self, settings: Option<&P>);
268
269    #[cfg(any(feature = "v3_10", feature = "dox"))]
270    fn connect_property_highlight_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
271
272    #[cfg(any(feature = "v3_16", feature = "dox"))]
273    fn connect_property_match_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
274
275    #[cfg(any(feature = "v3_10", feature = "dox"))]
276    fn connect_property_occurrences_count_notify<F: Fn(&Self) + 'static>(
277        &self,
278        f: F,
279    ) -> SignalHandlerId;
280
281    #[cfg(any(feature = "v3_10", feature = "dox"))]
282    fn connect_property_regex_error_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
283
284    #[cfg(any(feature = "v3_10", feature = "dox"))]
285    fn connect_property_settings_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
286}
287
288impl<O: IsA<SearchContext>> SearchContextExt for O {
289    #[cfg(any(feature = "v3_10", feature = "dox"))]
290    fn backward(&self, iter: &gtk::TextIter) -> Option<(gtk::TextIter, gtk::TextIter)> {
291        unsafe {
292            let mut match_start = gtk::TextIter::uninitialized();
293            let mut match_end = gtk::TextIter::uninitialized();
294            let ret = from_glib(gtk_source_sys::gtk_source_search_context_backward(
295                self.as_ref().to_glib_none().0,
296                iter.to_glib_none().0,
297                match_start.to_glib_none_mut().0,
298                match_end.to_glib_none_mut().0,
299            ));
300            if ret {
301                Some((match_start, match_end))
302            } else {
303                None
304            }
305        }
306    }
307
308    #[cfg(any(feature = "v3_22", feature = "dox"))]
309    fn backward2(&self, iter: &gtk::TextIter) -> Option<(gtk::TextIter, gtk::TextIter, bool)> {
310        unsafe {
311            let mut match_start = gtk::TextIter::uninitialized();
312            let mut match_end = gtk::TextIter::uninitialized();
313            let mut has_wrapped_around = mem::MaybeUninit::uninit();
314            let ret = from_glib(gtk_source_sys::gtk_source_search_context_backward2(
315                self.as_ref().to_glib_none().0,
316                iter.to_glib_none().0,
317                match_start.to_glib_none_mut().0,
318                match_end.to_glib_none_mut().0,
319                has_wrapped_around.as_mut_ptr(),
320            ));
321            let has_wrapped_around = has_wrapped_around.assume_init();
322            if ret {
323                Some((match_start, match_end, from_glib(has_wrapped_around)))
324            } else {
325                None
326            }
327        }
328    }
329
330    #[cfg(any(feature = "v3_10", feature = "dox"))]
331    fn backward_async<
332        P: IsA<gio::Cancellable>,
333        Q: FnOnce(Result<(gtk::TextIter, gtk::TextIter), glib::Error>) + Send + 'static,
334    >(
335        &self,
336        iter: &gtk::TextIter,
337        cancellable: Option<&P>,
338        callback: Q,
339    ) {
340        let user_data: Box_<Q> = Box_::new(callback);
341        unsafe extern "C" fn backward_async_trampoline<
342            Q: FnOnce(Result<(gtk::TextIter, gtk::TextIter), glib::Error>) + Send + 'static,
343        >(
344            _source_object: *mut gobject_sys::GObject,
345            res: *mut gio_sys::GAsyncResult,
346            user_data: glib_sys::gpointer,
347        ) {
348            let mut error = ptr::null_mut();
349            let mut match_start = gtk::TextIter::uninitialized();
350            let mut match_end = gtk::TextIter::uninitialized();
351            let _ = gtk_source_sys::gtk_source_search_context_backward_finish(
352                _source_object as *mut _,
353                res,
354                match_start.to_glib_none_mut().0,
355                match_end.to_glib_none_mut().0,
356                &mut error,
357            );
358            let result = if error.is_null() {
359                Ok((match_start, match_end))
360            } else {
361                Err(from_glib_full(error))
362            };
363            let callback: Box_<Q> = Box_::from_raw(user_data as *mut _);
364            callback(result);
365        }
366        let callback = backward_async_trampoline::<Q>;
367        unsafe {
368            gtk_source_sys::gtk_source_search_context_backward_async(
369                self.as_ref().to_glib_none().0,
370                iter.to_glib_none().0,
371                cancellable.map(|p| p.as_ref()).to_glib_none().0,
372                Some(callback),
373                Box_::into_raw(user_data) as *mut _,
374            );
375        }
376    }
377
378    #[cfg(any(feature = "v3_10", feature = "dox"))]
379    fn backward_async_future(
380        &self,
381        iter: &gtk::TextIter,
382    ) -> Pin<
383        Box_<
384            dyn std::future::Future<Output = Result<(gtk::TextIter, gtk::TextIter), glib::Error>>
385                + 'static,
386        >,
387    > {
388        let iter = iter.clone();
389        Box_::pin(gio::GioFuture::new(self, move |obj, send| {
390            let cancellable = gio::Cancellable::new();
391            obj.backward_async(&iter, Some(&cancellable), move |res| {
392                send.resolve(res);
393            });
394
395            cancellable
396        }))
397    }
398
399    //#[cfg(any(feature = "v3_22", feature = "dox"))]
400    //fn backward_finish2(&self, result: /*Ignored*/&gio::AsyncResult) -> Result<(gtk::TextIter, gtk::TextIter, bool), glib::Error> {
401    //    unsafe { TODO: call gtk_source_sys:gtk_source_search_context_backward_finish2() }
402    //}
403
404    #[cfg(any(feature = "v3_10", feature = "dox"))]
405    fn forward(&self, iter: &gtk::TextIter) -> Option<(gtk::TextIter, gtk::TextIter)> {
406        unsafe {
407            let mut match_start = gtk::TextIter::uninitialized();
408            let mut match_end = gtk::TextIter::uninitialized();
409            let ret = from_glib(gtk_source_sys::gtk_source_search_context_forward(
410                self.as_ref().to_glib_none().0,
411                iter.to_glib_none().0,
412                match_start.to_glib_none_mut().0,
413                match_end.to_glib_none_mut().0,
414            ));
415            if ret {
416                Some((match_start, match_end))
417            } else {
418                None
419            }
420        }
421    }
422
423    #[cfg(any(feature = "v3_22", feature = "dox"))]
424    fn forward2(&self, iter: &gtk::TextIter) -> Option<(gtk::TextIter, gtk::TextIter, bool)> {
425        unsafe {
426            let mut match_start = gtk::TextIter::uninitialized();
427            let mut match_end = gtk::TextIter::uninitialized();
428            let mut has_wrapped_around = mem::MaybeUninit::uninit();
429            let ret = from_glib(gtk_source_sys::gtk_source_search_context_forward2(
430                self.as_ref().to_glib_none().0,
431                iter.to_glib_none().0,
432                match_start.to_glib_none_mut().0,
433                match_end.to_glib_none_mut().0,
434                has_wrapped_around.as_mut_ptr(),
435            ));
436            let has_wrapped_around = has_wrapped_around.assume_init();
437            if ret {
438                Some((match_start, match_end, from_glib(has_wrapped_around)))
439            } else {
440                None
441            }
442        }
443    }
444
445    #[cfg(any(feature = "v3_10", feature = "dox"))]
446    fn forward_async<
447        P: IsA<gio::Cancellable>,
448        Q: FnOnce(Result<(gtk::TextIter, gtk::TextIter), glib::Error>) + Send + 'static,
449    >(
450        &self,
451        iter: &gtk::TextIter,
452        cancellable: Option<&P>,
453        callback: Q,
454    ) {
455        let user_data: Box_<Q> = Box_::new(callback);
456        unsafe extern "C" fn forward_async_trampoline<
457            Q: FnOnce(Result<(gtk::TextIter, gtk::TextIter), glib::Error>) + Send + 'static,
458        >(
459            _source_object: *mut gobject_sys::GObject,
460            res: *mut gio_sys::GAsyncResult,
461            user_data: glib_sys::gpointer,
462        ) {
463            let mut error = ptr::null_mut();
464            let mut match_start = gtk::TextIter::uninitialized();
465            let mut match_end = gtk::TextIter::uninitialized();
466            let _ = gtk_source_sys::gtk_source_search_context_forward_finish(
467                _source_object as *mut _,
468                res,
469                match_start.to_glib_none_mut().0,
470                match_end.to_glib_none_mut().0,
471                &mut error,
472            );
473            let result = if error.is_null() {
474                Ok((match_start, match_end))
475            } else {
476                Err(from_glib_full(error))
477            };
478            let callback: Box_<Q> = Box_::from_raw(user_data as *mut _);
479            callback(result);
480        }
481        let callback = forward_async_trampoline::<Q>;
482        unsafe {
483            gtk_source_sys::gtk_source_search_context_forward_async(
484                self.as_ref().to_glib_none().0,
485                iter.to_glib_none().0,
486                cancellable.map(|p| p.as_ref()).to_glib_none().0,
487                Some(callback),
488                Box_::into_raw(user_data) as *mut _,
489            );
490        }
491    }
492
493    #[cfg(any(feature = "v3_10", feature = "dox"))]
494    fn forward_async_future(
495        &self,
496        iter: &gtk::TextIter,
497    ) -> Pin<
498        Box_<
499            dyn std::future::Future<Output = Result<(gtk::TextIter, gtk::TextIter), glib::Error>>
500                + 'static,
501        >,
502    > {
503        let iter = iter.clone();
504        Box_::pin(gio::GioFuture::new(self, move |obj, send| {
505            let cancellable = gio::Cancellable::new();
506            obj.forward_async(&iter, Some(&cancellable), move |res| {
507                send.resolve(res);
508            });
509
510            cancellable
511        }))
512    }
513
514    //#[cfg(any(feature = "v3_22", feature = "dox"))]
515    //fn forward_finish2(&self, result: /*Ignored*/&gio::AsyncResult) -> Result<(gtk::TextIter, gtk::TextIter, bool), glib::Error> {
516    //    unsafe { TODO: call gtk_source_sys:gtk_source_search_context_forward_finish2() }
517    //}
518
519    #[cfg(any(feature = "v3_10", feature = "dox"))]
520    fn get_buffer(&self) -> Option<Buffer> {
521        unsafe {
522            from_glib_none(gtk_source_sys::gtk_source_search_context_get_buffer(
523                self.as_ref().to_glib_none().0,
524            ))
525        }
526    }
527
528    #[cfg(any(feature = "v3_10", feature = "dox"))]
529    fn get_highlight(&self) -> bool {
530        unsafe {
531            from_glib(gtk_source_sys::gtk_source_search_context_get_highlight(
532                self.as_ref().to_glib_none().0,
533            ))
534        }
535    }
536
537    #[cfg(any(feature = "v3_16", feature = "dox"))]
538    fn get_match_style(&self) -> Option<Style> {
539        unsafe {
540            from_glib_none(gtk_source_sys::gtk_source_search_context_get_match_style(
541                self.as_ref().to_glib_none().0,
542            ))
543        }
544    }
545
546    #[cfg(any(feature = "v3_10", feature = "dox"))]
547    fn get_occurrence_position(
548        &self,
549        match_start: &gtk::TextIter,
550        match_end: &gtk::TextIter,
551    ) -> i32 {
552        unsafe {
553            gtk_source_sys::gtk_source_search_context_get_occurrence_position(
554                self.as_ref().to_glib_none().0,
555                match_start.to_glib_none().0,
556                match_end.to_glib_none().0,
557            )
558        }
559    }
560
561    #[cfg(any(feature = "v3_10", feature = "dox"))]
562    fn get_occurrences_count(&self) -> i32 {
563        unsafe {
564            gtk_source_sys::gtk_source_search_context_get_occurrences_count(
565                self.as_ref().to_glib_none().0,
566            )
567        }
568    }
569
570    #[cfg(any(feature = "v3_10", feature = "dox"))]
571    fn get_regex_error(&self) -> Option<glib::Error> {
572        unsafe {
573            from_glib_full(gtk_source_sys::gtk_source_search_context_get_regex_error(
574                self.as_ref().to_glib_none().0,
575            ))
576        }
577    }
578
579    #[cfg(any(feature = "v3_10", feature = "dox"))]
580    fn get_settings(&self) -> Option<SearchSettings> {
581        unsafe {
582            from_glib_none(gtk_source_sys::gtk_source_search_context_get_settings(
583                self.as_ref().to_glib_none().0,
584            ))
585        }
586    }
587
588    #[cfg(any(feature = "v3_10", feature = "dox"))]
589    fn replace(
590        &self,
591        match_start: &gtk::TextIter,
592        match_end: &gtk::TextIter,
593        replace: &str,
594    ) -> Result<(), glib::Error> {
595        let replace_length = replace.len() as i32;
596        unsafe {
597            let mut error = ptr::null_mut();
598            let _ = gtk_source_sys::gtk_source_search_context_replace(
599                self.as_ref().to_glib_none().0,
600                match_start.to_glib_none().0,
601                match_end.to_glib_none().0,
602                replace.to_glib_none().0,
603                replace_length,
604                &mut error,
605            );
606            if error.is_null() {
607                Ok(())
608            } else {
609                Err(from_glib_full(error))
610            }
611        }
612    }
613
614    #[cfg(any(feature = "v3_22", feature = "dox"))]
615    fn replace2(
616        &self,
617        match_start: &mut gtk::TextIter,
618        match_end: &mut gtk::TextIter,
619        replace: &str,
620    ) -> Result<(), glib::Error> {
621        let replace_length = replace.len() as i32;
622        unsafe {
623            let mut error = ptr::null_mut();
624            let _ = gtk_source_sys::gtk_source_search_context_replace2(
625                self.as_ref().to_glib_none().0,
626                match_start.to_glib_none_mut().0,
627                match_end.to_glib_none_mut().0,
628                replace.to_glib_none().0,
629                replace_length,
630                &mut error,
631            );
632            if error.is_null() {
633                Ok(())
634            } else {
635                Err(from_glib_full(error))
636            }
637        }
638    }
639
640    #[cfg(any(feature = "v3_10", feature = "dox"))]
641    fn replace_all(&self, replace: &str) -> Result<u32, glib::Error> {
642        let replace_length = replace.len() as i32;
643        unsafe {
644            let mut error = ptr::null_mut();
645            let ret = gtk_source_sys::gtk_source_search_context_replace_all(
646                self.as_ref().to_glib_none().0,
647                replace.to_glib_none().0,
648                replace_length,
649                &mut error,
650            );
651            if error.is_null() {
652                Ok(ret)
653            } else {
654                Err(from_glib_full(error))
655            }
656        }
657    }
658
659    #[cfg(any(feature = "v3_10", feature = "dox"))]
660    fn set_highlight(&self, highlight: bool) {
661        unsafe {
662            gtk_source_sys::gtk_source_search_context_set_highlight(
663                self.as_ref().to_glib_none().0,
664                highlight.to_glib(),
665            );
666        }
667    }
668
669    #[cfg(any(feature = "v3_16", feature = "dox"))]
670    fn set_match_style(&self, match_style: Option<&Style>) {
671        unsafe {
672            gtk_source_sys::gtk_source_search_context_set_match_style(
673                self.as_ref().to_glib_none().0,
674                match_style.to_glib_none().0,
675            );
676        }
677    }
678
679    #[cfg(any(feature = "v3_10", feature = "dox"))]
680    fn set_settings<P: IsA<SearchSettings>>(&self, settings: Option<&P>) {
681        unsafe {
682            gtk_source_sys::gtk_source_search_context_set_settings(
683                self.as_ref().to_glib_none().0,
684                settings.map(|p| p.as_ref()).to_glib_none().0,
685            );
686        }
687    }
688
689    #[cfg(any(feature = "v3_10", feature = "dox"))]
690    fn connect_property_highlight_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
691        unsafe extern "C" fn notify_highlight_trampoline<P, F: Fn(&P) + 'static>(
692            this: *mut gtk_source_sys::GtkSourceSearchContext,
693            _param_spec: glib_sys::gpointer,
694            f: glib_sys::gpointer,
695        ) where
696            P: IsA<SearchContext>,
697        {
698            let f: &F = &*(f as *const F);
699            f(&SearchContext::from_glib_borrow(this).unsafe_cast_ref())
700        }
701        unsafe {
702            let f: Box_<F> = Box_::new(f);
703            connect_raw(
704                self.as_ptr() as *mut _,
705                b"notify::highlight\0".as_ptr() as *const _,
706                Some(transmute::<_, unsafe extern "C" fn()>(
707                    notify_highlight_trampoline::<Self, F> as *const (),
708                )),
709                Box_::into_raw(f),
710            )
711        }
712    }
713
714    #[cfg(any(feature = "v3_16", feature = "dox"))]
715    fn connect_property_match_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
716        unsafe extern "C" fn notify_match_style_trampoline<P, F: Fn(&P) + 'static>(
717            this: *mut gtk_source_sys::GtkSourceSearchContext,
718            _param_spec: glib_sys::gpointer,
719            f: glib_sys::gpointer,
720        ) where
721            P: IsA<SearchContext>,
722        {
723            let f: &F = &*(f as *const F);
724            f(&SearchContext::from_glib_borrow(this).unsafe_cast_ref())
725        }
726        unsafe {
727            let f: Box_<F> = Box_::new(f);
728            connect_raw(
729                self.as_ptr() as *mut _,
730                b"notify::match-style\0".as_ptr() as *const _,
731                Some(transmute::<_, unsafe extern "C" fn()>(
732                    notify_match_style_trampoline::<Self, F> as *const (),
733                )),
734                Box_::into_raw(f),
735            )
736        }
737    }
738
739    #[cfg(any(feature = "v3_10", feature = "dox"))]
740    fn connect_property_occurrences_count_notify<F: Fn(&Self) + 'static>(
741        &self,
742        f: F,
743    ) -> SignalHandlerId {
744        unsafe extern "C" fn notify_occurrences_count_trampoline<P, F: Fn(&P) + 'static>(
745            this: *mut gtk_source_sys::GtkSourceSearchContext,
746            _param_spec: glib_sys::gpointer,
747            f: glib_sys::gpointer,
748        ) where
749            P: IsA<SearchContext>,
750        {
751            let f: &F = &*(f as *const F);
752            f(&SearchContext::from_glib_borrow(this).unsafe_cast_ref())
753        }
754        unsafe {
755            let f: Box_<F> = Box_::new(f);
756            connect_raw(
757                self.as_ptr() as *mut _,
758                b"notify::occurrences-count\0".as_ptr() as *const _,
759                Some(transmute::<_, unsafe extern "C" fn()>(
760                    notify_occurrences_count_trampoline::<Self, F> as *const (),
761                )),
762                Box_::into_raw(f),
763            )
764        }
765    }
766
767    #[cfg(any(feature = "v3_10", feature = "dox"))]
768    fn connect_property_regex_error_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
769        unsafe extern "C" fn notify_regex_error_trampoline<P, F: Fn(&P) + 'static>(
770            this: *mut gtk_source_sys::GtkSourceSearchContext,
771            _param_spec: glib_sys::gpointer,
772            f: glib_sys::gpointer,
773        ) where
774            P: IsA<SearchContext>,
775        {
776            let f: &F = &*(f as *const F);
777            f(&SearchContext::from_glib_borrow(this).unsafe_cast_ref())
778        }
779        unsafe {
780            let f: Box_<F> = Box_::new(f);
781            connect_raw(
782                self.as_ptr() as *mut _,
783                b"notify::regex-error\0".as_ptr() as *const _,
784                Some(transmute::<_, unsafe extern "C" fn()>(
785                    notify_regex_error_trampoline::<Self, F> as *const (),
786                )),
787                Box_::into_raw(f),
788            )
789        }
790    }
791
792    #[cfg(any(feature = "v3_10", feature = "dox"))]
793    fn connect_property_settings_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
794        unsafe extern "C" fn notify_settings_trampoline<P, F: Fn(&P) + 'static>(
795            this: *mut gtk_source_sys::GtkSourceSearchContext,
796            _param_spec: glib_sys::gpointer,
797            f: glib_sys::gpointer,
798        ) where
799            P: IsA<SearchContext>,
800        {
801            let f: &F = &*(f as *const F);
802            f(&SearchContext::from_glib_borrow(this).unsafe_cast_ref())
803        }
804        unsafe {
805            let f: Box_<F> = Box_::new(f);
806            connect_raw(
807                self.as_ptr() as *mut _,
808                b"notify::settings\0".as_ptr() as *const _,
809                Some(transmute::<_, unsafe extern "C" fn()>(
810                    notify_settings_trampoline::<Self, F> as *const (),
811                )),
812                Box_::into_raw(f),
813            )
814        }
815    }
816}
817
818impl fmt::Display for SearchContext {
819    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
820        write!(f, "SearchContext")
821    }
822}