gtk4/auto/
search_bar.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::{
6    Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, Editable, LayoutManager,
7    Overflow, Widget, ffi,
8};
9use glib::{
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// Reveals a search entry when search is started.
18    ///
19    /// <picture>
20    ///   <source srcset="search-bar-dark.png" media="(prefers-color-scheme: dark)">
21    ///   <img alt="An example GtkSearchBar" src="search-bar.png">
22    /// </picture>
23    ///
24    /// It can also contain additional widgets, such as drop-down menus,
25    /// or buttons.  The search bar would appear when a search is started
26    /// through typing on the keyboard, or the application’s search mode
27    /// is toggled on.
28    ///
29    /// For keyboard presses to start a search, the search bar must be told
30    /// of a widget to capture key events from through
31    /// [`set_key_capture_widget()`][Self::set_key_capture_widget()]. This widget will
32    /// typically be the top-level window, or a parent container of the
33    /// search bar. Common shortcuts such as Ctrl+F should be handled as an
34    /// application action, or through the menu items.
35    ///
36    /// You will also need to tell the search bar about which entry you
37    /// are using as your search entry using [`connect_entry()`][Self::connect_entry()].
38    ///
39    /// ## Creating a search bar
40    ///
41    /// The following example shows you how to create a more complex search
42    /// entry.
43    ///
44    /// [A simple example](https://gitlab.gnome.org/GNOME/gtk/tree/main/examples/search-bar.c)
45    ///
46    /// # Shortcuts and Gestures
47    ///
48    /// [`SearchBar`][crate::SearchBar] supports the following keyboard shortcuts:
49    ///
50    /// - <kbd>Escape</kbd> hides the search bar.
51    ///
52    /// # CSS nodes
53    ///
54    /// ```text
55    /// searchbar
56    /// ╰── revealer
57    ///     ╰── box
58    ///          ├── [child]
59    ///          ╰── [button.close]
60    /// ```
61    ///
62    /// [`SearchBar`][crate::SearchBar] has a main CSS node with name searchbar. It has a child
63    /// node with name revealer that contains a node with name box. The box node
64    /// contains both the CSS node of the child widget as well as an optional button
65    /// node which gets the .close style class applied.
66    ///
67    /// # Accessibility
68    ///
69    /// [`SearchBar`][crate::SearchBar] uses the [enum@Gtk.AccessibleRole.search] role.
70    ///
71    /// ## Properties
72    ///
73    ///
74    /// #### `child`
75    ///  The child widget.
76    ///
77    /// Readable | Writeable | Construct
78    ///
79    ///
80    /// #### `key-capture-widget`
81    ///  The key capture widget.
82    ///
83    /// Readable | Writeable | Construct
84    ///
85    ///
86    /// #### `search-mode-enabled`
87    ///  Whether the search mode is on and the search bar shown.
88    ///
89    /// Readable | Writeable
90    ///
91    ///
92    /// #### `show-close-button`
93    ///  Whether to show the close button in the search bar.
94    ///
95    /// Readable | Writeable | Construct
96    /// <details><summary><h4>Widget</h4></summary>
97    ///
98    ///
99    /// #### `can-focus`
100    ///  Whether the widget or any of its descendents can accept
101    /// the input focus.
102    ///
103    /// This property is meant to be set by widget implementations,
104    /// typically in their instance init function.
105    ///
106    /// Readable | Writeable
107    ///
108    ///
109    /// #### `can-target`
110    ///  Whether the widget can receive pointer events.
111    ///
112    /// Readable | Writeable
113    ///
114    ///
115    /// #### `css-classes`
116    ///  A list of css classes applied to this widget.
117    ///
118    /// Readable | Writeable
119    ///
120    ///
121    /// #### `css-name`
122    ///  The name of this widget in the CSS tree.
123    ///
124    /// This property is meant to be set by widget implementations,
125    /// typically in their instance init function.
126    ///
127    /// Readable | Writeable | Construct Only
128    ///
129    ///
130    /// #### `cursor`
131    ///  The cursor used by @widget.
132    ///
133    /// Readable | Writeable
134    ///
135    ///
136    /// #### `focus-on-click`
137    ///  Whether the widget should grab focus when it is clicked with the mouse.
138    ///
139    /// This property is only relevant for widgets that can take focus.
140    ///
141    /// Readable | Writeable
142    ///
143    ///
144    /// #### `focusable`
145    ///  Whether this widget itself will accept the input focus.
146    ///
147    /// Readable | Writeable
148    ///
149    ///
150    /// #### `halign`
151    ///  How to distribute horizontal space if widget gets extra space.
152    ///
153    /// Readable | Writeable
154    ///
155    ///
156    /// #### `has-default`
157    ///  Whether the widget is the default widget.
158    ///
159    /// Readable
160    ///
161    ///
162    /// #### `has-focus`
163    ///  Whether the widget has the input focus.
164    ///
165    /// Readable
166    ///
167    ///
168    /// #### `has-tooltip`
169    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
170    /// signal on @widget.
171    ///
172    /// A true value indicates that @widget can have a tooltip, in this case
173    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
174    /// determine whether it will provide a tooltip or not.
175    ///
176    /// Readable | Writeable
177    ///
178    ///
179    /// #### `height-request`
180    ///  Overrides for height request of the widget.
181    ///
182    /// If this is -1, the natural request will be used.
183    ///
184    /// Readable | Writeable
185    ///
186    ///
187    /// #### `hexpand`
188    ///  Whether to expand horizontally.
189    ///
190    /// Readable | Writeable
191    ///
192    ///
193    /// #### `hexpand-set`
194    ///  Whether to use the `hexpand` property.
195    ///
196    /// Readable | Writeable
197    ///
198    ///
199    /// #### `layout-manager`
200    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
201    /// the preferred size of the widget, and allocate its children.
202    ///
203    /// This property is meant to be set by widget implementations,
204    /// typically in their instance init function.
205    ///
206    /// Readable | Writeable
207    ///
208    ///
209    /// #### `limit-events`
210    ///  Makes this widget act like a modal dialog, with respect to
211    /// event delivery.
212    ///
213    /// Global event controllers will not handle events with targets
214    /// inside the widget, unless they are set up to ignore propagation
215    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
216    ///
217    /// Readable | Writeable
218    ///
219    ///
220    /// #### `margin-bottom`
221    ///  Margin on bottom side of widget.
222    ///
223    /// This property adds margin outside of the widget's normal size
224    /// request, the margin will be added in addition to the size from
225    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
226    ///
227    /// Readable | Writeable
228    ///
229    ///
230    /// #### `margin-end`
231    ///  Margin on end of widget, horizontally.
232    ///
233    /// This property supports left-to-right and right-to-left text
234    /// directions.
235    ///
236    /// This property adds margin outside of the widget's normal size
237    /// request, the margin will be added in addition to the size from
238    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
239    ///
240    /// Readable | Writeable
241    ///
242    ///
243    /// #### `margin-start`
244    ///  Margin on start of widget, horizontally.
245    ///
246    /// This property supports left-to-right and right-to-left text
247    /// directions.
248    ///
249    /// This property adds margin outside of the widget's normal size
250    /// request, the margin will be added in addition to the size from
251    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
252    ///
253    /// Readable | Writeable
254    ///
255    ///
256    /// #### `margin-top`
257    ///  Margin on top side of widget.
258    ///
259    /// This property adds margin outside of the widget's normal size
260    /// request, the margin will be added in addition to the size from
261    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
262    ///
263    /// Readable | Writeable
264    ///
265    ///
266    /// #### `name`
267    ///  The name of the widget.
268    ///
269    /// Readable | Writeable
270    ///
271    ///
272    /// #### `opacity`
273    ///  The requested opacity of the widget.
274    ///
275    /// Readable | Writeable
276    ///
277    ///
278    /// #### `overflow`
279    ///  How content outside the widget's content area is treated.
280    ///
281    /// This property is meant to be set by widget implementations,
282    /// typically in their instance init function.
283    ///
284    /// Readable | Writeable
285    ///
286    ///
287    /// #### `parent`
288    ///  The parent widget of this widget.
289    ///
290    /// Readable
291    ///
292    ///
293    /// #### `receives-default`
294    ///  Whether the widget will receive the default action when it is focused.
295    ///
296    /// Readable | Writeable
297    ///
298    ///
299    /// #### `root`
300    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
301    ///
302    /// This will be `NULL` if the widget is not contained in a root widget.
303    ///
304    /// Readable
305    ///
306    ///
307    /// #### `scale-factor`
308    ///  The scale factor of the widget.
309    ///
310    /// Readable
311    ///
312    ///
313    /// #### `sensitive`
314    ///  Whether the widget responds to input.
315    ///
316    /// Readable | Writeable
317    ///
318    ///
319    /// #### `tooltip-markup`
320    ///  Sets the text of tooltip to be the given string, which is marked up
321    /// with Pango markup.
322    ///
323    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
324    ///
325    /// This is a convenience property which will take care of getting the
326    /// tooltip shown if the given string is not `NULL`:
327    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
328    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
329    /// the default signal handler.
330    ///
331    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
332    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
333    ///
334    /// Readable | Writeable
335    ///
336    ///
337    /// #### `tooltip-text`
338    ///  Sets the text of tooltip to be the given string.
339    ///
340    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
341    ///
342    /// This is a convenience property which will take care of getting the
343    /// tooltip shown if the given string is not `NULL`:
344    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
345    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
346    /// the default signal handler.
347    ///
348    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
349    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
350    ///
351    /// Readable | Writeable
352    ///
353    ///
354    /// #### `valign`
355    ///  How to distribute vertical space if widget gets extra space.
356    ///
357    /// Readable | Writeable
358    ///
359    ///
360    /// #### `vexpand`
361    ///  Whether to expand vertically.
362    ///
363    /// Readable | Writeable
364    ///
365    ///
366    /// #### `vexpand-set`
367    ///  Whether to use the `vexpand` property.
368    ///
369    /// Readable | Writeable
370    ///
371    ///
372    /// #### `visible`
373    ///  Whether the widget is visible.
374    ///
375    /// Readable | Writeable
376    ///
377    ///
378    /// #### `width-request`
379    ///  Overrides for width request of the widget.
380    ///
381    /// If this is -1, the natural request will be used.
382    ///
383    /// Readable | Writeable
384    /// </details>
385    /// <details><summary><h4>Accessible</h4></summary>
386    ///
387    ///
388    /// #### `accessible-role`
389    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
390    ///
391    /// The accessible role cannot be changed once set.
392    ///
393    /// Readable | Writeable
394    /// </details>
395    ///
396    /// # Implements
397    ///
398    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
399    #[doc(alias = "GtkSearchBar")]
400    pub struct SearchBar(Object<ffi::GtkSearchBar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
401
402    match fn {
403        type_ => || ffi::gtk_search_bar_get_type(),
404    }
405}
406
407impl SearchBar {
408    /// Creates a [`SearchBar`][crate::SearchBar].
409    ///
410    /// You will need to tell it about which widget is going to be your text
411    /// entry using [`connect_entry()`][Self::connect_entry()].
412    ///
413    /// # Returns
414    ///
415    /// a new [`SearchBar`][crate::SearchBar]
416    #[doc(alias = "gtk_search_bar_new")]
417    pub fn new() -> SearchBar {
418        assert_initialized_main_thread!();
419        unsafe { Widget::from_glib_none(ffi::gtk_search_bar_new()).unsafe_cast() }
420    }
421
422    // rustdoc-stripper-ignore-next
423    /// Creates a new builder-pattern struct instance to construct [`SearchBar`] objects.
424    ///
425    /// This method returns an instance of [`SearchBarBuilder`](crate::builders::SearchBarBuilder) which can be used to create [`SearchBar`] objects.
426    pub fn builder() -> SearchBarBuilder {
427        SearchBarBuilder::new()
428    }
429
430    /// Connects the [`Editable`][crate::Editable] widget passed as the one to be used in
431    /// this search bar.
432    ///
433    /// The entry should be a descendant of the search bar. Calling this
434    /// function manually is only required if the entry isn’t the direct
435    /// child of the search bar (as in our main example).
436    /// ## `entry`
437    /// a [`Editable`][crate::Editable]
438    #[doc(alias = "gtk_search_bar_connect_entry")]
439    pub fn connect_entry(&self, entry: &impl IsA<Editable>) {
440        unsafe {
441            ffi::gtk_search_bar_connect_entry(
442                self.to_glib_none().0,
443                entry.as_ref().to_glib_none().0,
444            );
445        }
446    }
447
448    /// Gets the child widget of @self.
449    ///
450    /// # Returns
451    ///
452    /// the child widget of @self
453    #[doc(alias = "gtk_search_bar_get_child")]
454    #[doc(alias = "get_child")]
455    pub fn child(&self) -> Option<Widget> {
456        unsafe { from_glib_none(ffi::gtk_search_bar_get_child(self.to_glib_none().0)) }
457    }
458
459    /// Gets the widget that @self is capturing key events from.
460    ///
461    /// # Returns
462    ///
463    /// The key capture widget.
464    #[doc(alias = "gtk_search_bar_get_key_capture_widget")]
465    #[doc(alias = "get_key_capture_widget")]
466    #[doc(alias = "key-capture-widget")]
467    pub fn key_capture_widget(&self) -> Option<Widget> {
468        unsafe {
469            from_glib_none(ffi::gtk_search_bar_get_key_capture_widget(
470                self.to_glib_none().0,
471            ))
472        }
473    }
474
475    /// Returns whether the search mode is on or off.
476    ///
477    /// # Returns
478    ///
479    /// whether search mode is toggled on
480    #[doc(alias = "gtk_search_bar_get_search_mode")]
481    #[doc(alias = "get_search_mode")]
482    #[doc(alias = "search-mode-enabled")]
483    pub fn is_search_mode(&self) -> bool {
484        unsafe { from_glib(ffi::gtk_search_bar_get_search_mode(self.to_glib_none().0)) }
485    }
486
487    /// Returns whether the close button is shown.
488    ///
489    /// # Returns
490    ///
491    /// whether the close button is shown
492    #[doc(alias = "gtk_search_bar_get_show_close_button")]
493    #[doc(alias = "get_show_close_button")]
494    #[doc(alias = "show-close-button")]
495    pub fn shows_close_button(&self) -> bool {
496        unsafe {
497            from_glib(ffi::gtk_search_bar_get_show_close_button(
498                self.to_glib_none().0,
499            ))
500        }
501    }
502
503    /// Sets the child widget of @self.
504    /// ## `child`
505    /// the child widget
506    #[doc(alias = "gtk_search_bar_set_child")]
507    #[doc(alias = "child")]
508    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
509        unsafe {
510            ffi::gtk_search_bar_set_child(
511                self.to_glib_none().0,
512                child.map(|p| p.as_ref()).to_glib_none().0,
513            );
514        }
515    }
516
517    /// Sets @widget as the widget that @self will capture key events
518    /// from.
519    ///
520    /// If key events are handled by the search bar, the bar will
521    /// be shown, and the entry populated with the entered text.
522    ///
523    /// Note that despite the name of this function, the events
524    /// are only 'captured' in the bubble phase, which means that
525    /// editable child widgets of @widget will receive text input
526    /// before it gets captured. If that is not desired, you can
527    /// capture and forward the events yourself with
528    /// [`EventControllerKey::forward()`][crate::EventControllerKey::forward()].
529    /// ## `widget`
530    /// a [`Widget`][crate::Widget]
531    #[doc(alias = "gtk_search_bar_set_key_capture_widget")]
532    #[doc(alias = "key-capture-widget")]
533    pub fn set_key_capture_widget(&self, widget: Option<&impl IsA<Widget>>) {
534        unsafe {
535            ffi::gtk_search_bar_set_key_capture_widget(
536                self.to_glib_none().0,
537                widget.map(|p| p.as_ref()).to_glib_none().0,
538            );
539        }
540    }
541
542    /// Switches the search mode on or off.
543    /// ## `search_mode`
544    /// the new state of the search mode
545    #[doc(alias = "gtk_search_bar_set_search_mode")]
546    #[doc(alias = "search-mode-enabled")]
547    pub fn set_search_mode(&self, search_mode: bool) {
548        unsafe {
549            ffi::gtk_search_bar_set_search_mode(self.to_glib_none().0, search_mode.into_glib());
550        }
551    }
552
553    /// Shows or hides the close button.
554    ///
555    /// Applications that already have a “search” toggle button should not
556    /// show a close button in their search bar, as it duplicates the role
557    /// of the toggle button.
558    /// ## `visible`
559    /// whether the close button will be shown or not
560    #[doc(alias = "gtk_search_bar_set_show_close_button")]
561    #[doc(alias = "show-close-button")]
562    pub fn set_show_close_button(&self, visible: bool) {
563        unsafe {
564            ffi::gtk_search_bar_set_show_close_button(self.to_glib_none().0, visible.into_glib());
565        }
566    }
567
568    #[doc(alias = "child")]
569    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
570        unsafe extern "C" fn notify_child_trampoline<F: Fn(&SearchBar) + 'static>(
571            this: *mut ffi::GtkSearchBar,
572            _param_spec: glib::ffi::gpointer,
573            f: glib::ffi::gpointer,
574        ) {
575            unsafe {
576                let f: &F = &*(f as *const F);
577                f(&from_glib_borrow(this))
578            }
579        }
580        unsafe {
581            let f: Box_<F> = Box_::new(f);
582            connect_raw(
583                self.as_ptr() as *mut _,
584                c"notify::child".as_ptr() as *const _,
585                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
586                    notify_child_trampoline::<F> as *const (),
587                )),
588                Box_::into_raw(f),
589            )
590        }
591    }
592
593    #[doc(alias = "key-capture-widget")]
594    pub fn connect_key_capture_widget_notify<F: Fn(&Self) + 'static>(
595        &self,
596        f: F,
597    ) -> SignalHandlerId {
598        unsafe extern "C" fn notify_key_capture_widget_trampoline<F: Fn(&SearchBar) + 'static>(
599            this: *mut ffi::GtkSearchBar,
600            _param_spec: glib::ffi::gpointer,
601            f: glib::ffi::gpointer,
602        ) {
603            unsafe {
604                let f: &F = &*(f as *const F);
605                f(&from_glib_borrow(this))
606            }
607        }
608        unsafe {
609            let f: Box_<F> = Box_::new(f);
610            connect_raw(
611                self.as_ptr() as *mut _,
612                c"notify::key-capture-widget".as_ptr() as *const _,
613                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
614                    notify_key_capture_widget_trampoline::<F> as *const (),
615                )),
616                Box_::into_raw(f),
617            )
618        }
619    }
620
621    #[doc(alias = "search-mode-enabled")]
622    pub fn connect_search_mode_enabled_notify<F: Fn(&Self) + 'static>(
623        &self,
624        f: F,
625    ) -> SignalHandlerId {
626        unsafe extern "C" fn notify_search_mode_enabled_trampoline<F: Fn(&SearchBar) + 'static>(
627            this: *mut ffi::GtkSearchBar,
628            _param_spec: glib::ffi::gpointer,
629            f: glib::ffi::gpointer,
630        ) {
631            unsafe {
632                let f: &F = &*(f as *const F);
633                f(&from_glib_borrow(this))
634            }
635        }
636        unsafe {
637            let f: Box_<F> = Box_::new(f);
638            connect_raw(
639                self.as_ptr() as *mut _,
640                c"notify::search-mode-enabled".as_ptr() as *const _,
641                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
642                    notify_search_mode_enabled_trampoline::<F> as *const (),
643                )),
644                Box_::into_raw(f),
645            )
646        }
647    }
648
649    #[doc(alias = "show-close-button")]
650    pub fn connect_show_close_button_notify<F: Fn(&Self) + 'static>(
651        &self,
652        f: F,
653    ) -> SignalHandlerId {
654        unsafe extern "C" fn notify_show_close_button_trampoline<F: Fn(&SearchBar) + 'static>(
655            this: *mut ffi::GtkSearchBar,
656            _param_spec: glib::ffi::gpointer,
657            f: glib::ffi::gpointer,
658        ) {
659            unsafe {
660                let f: &F = &*(f as *const F);
661                f(&from_glib_borrow(this))
662            }
663        }
664        unsafe {
665            let f: Box_<F> = Box_::new(f);
666            connect_raw(
667                self.as_ptr() as *mut _,
668                c"notify::show-close-button".as_ptr() as *const _,
669                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
670                    notify_show_close_button_trampoline::<F> as *const (),
671                )),
672                Box_::into_raw(f),
673            )
674        }
675    }
676}
677
678impl Default for SearchBar {
679    fn default() -> Self {
680        Self::new()
681    }
682}
683
684// rustdoc-stripper-ignore-next
685/// A [builder-pattern] type to construct [`SearchBar`] objects.
686///
687/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
688#[must_use = "The builder must be built to be used"]
689pub struct SearchBarBuilder {
690    builder: glib::object::ObjectBuilder<'static, SearchBar>,
691}
692
693impl SearchBarBuilder {
694    fn new() -> Self {
695        Self {
696            builder: glib::object::Object::builder(),
697        }
698    }
699
700    /// The child widget.
701    pub fn child(self, child: &impl IsA<Widget>) -> Self {
702        Self {
703            builder: self.builder.property("child", child.clone().upcast()),
704        }
705    }
706
707    /// The key capture widget.
708    pub fn key_capture_widget(self, key_capture_widget: &impl IsA<Widget>) -> Self {
709        Self {
710            builder: self
711                .builder
712                .property("key-capture-widget", key_capture_widget.clone().upcast()),
713        }
714    }
715
716    /// Whether the search mode is on and the search bar shown.
717    pub fn search_mode_enabled(self, search_mode_enabled: bool) -> Self {
718        Self {
719            builder: self
720                .builder
721                .property("search-mode-enabled", search_mode_enabled),
722        }
723    }
724
725    /// Whether to show the close button in the search bar.
726    pub fn show_close_button(self, show_close_button: bool) -> Self {
727        Self {
728            builder: self
729                .builder
730                .property("show-close-button", show_close_button),
731        }
732    }
733
734    /// Whether the widget or any of its descendents can accept
735    /// the input focus.
736    ///
737    /// This property is meant to be set by widget implementations,
738    /// typically in their instance init function.
739    pub fn can_focus(self, can_focus: bool) -> Self {
740        Self {
741            builder: self.builder.property("can-focus", can_focus),
742        }
743    }
744
745    /// Whether the widget can receive pointer events.
746    pub fn can_target(self, can_target: bool) -> Self {
747        Self {
748            builder: self.builder.property("can-target", can_target),
749        }
750    }
751
752    /// A list of css classes applied to this widget.
753    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
754        Self {
755            builder: self.builder.property("css-classes", css_classes.into()),
756        }
757    }
758
759    /// The name of this widget in the CSS tree.
760    ///
761    /// This property is meant to be set by widget implementations,
762    /// typically in their instance init function.
763    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
764        Self {
765            builder: self.builder.property("css-name", css_name.into()),
766        }
767    }
768
769    /// The cursor used by @widget.
770    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
771        Self {
772            builder: self.builder.property("cursor", cursor.clone()),
773        }
774    }
775
776    /// Whether the widget should grab focus when it is clicked with the mouse.
777    ///
778    /// This property is only relevant for widgets that can take focus.
779    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
780        Self {
781            builder: self.builder.property("focus-on-click", focus_on_click),
782        }
783    }
784
785    /// Whether this widget itself will accept the input focus.
786    pub fn focusable(self, focusable: bool) -> Self {
787        Self {
788            builder: self.builder.property("focusable", focusable),
789        }
790    }
791
792    /// How to distribute horizontal space if widget gets extra space.
793    pub fn halign(self, halign: Align) -> Self {
794        Self {
795            builder: self.builder.property("halign", halign),
796        }
797    }
798
799    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
800    /// signal on @widget.
801    ///
802    /// A true value indicates that @widget can have a tooltip, in this case
803    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
804    /// determine whether it will provide a tooltip or not.
805    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
806        Self {
807            builder: self.builder.property("has-tooltip", has_tooltip),
808        }
809    }
810
811    /// Overrides for height request of the widget.
812    ///
813    /// If this is -1, the natural request will be used.
814    pub fn height_request(self, height_request: i32) -> Self {
815        Self {
816            builder: self.builder.property("height-request", height_request),
817        }
818    }
819
820    /// Whether to expand horizontally.
821    pub fn hexpand(self, hexpand: bool) -> Self {
822        Self {
823            builder: self.builder.property("hexpand", hexpand),
824        }
825    }
826
827    /// Whether to use the `hexpand` property.
828    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
829        Self {
830            builder: self.builder.property("hexpand-set", hexpand_set),
831        }
832    }
833
834    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
835    /// the preferred size of the widget, and allocate its children.
836    ///
837    /// This property is meant to be set by widget implementations,
838    /// typically in their instance init function.
839    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
840        Self {
841            builder: self
842                .builder
843                .property("layout-manager", layout_manager.clone().upcast()),
844        }
845    }
846
847    /// Makes this widget act like a modal dialog, with respect to
848    /// event delivery.
849    ///
850    /// Global event controllers will not handle events with targets
851    /// inside the widget, unless they are set up to ignore propagation
852    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
853    #[cfg(feature = "v4_18")]
854    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
855    pub fn limit_events(self, limit_events: bool) -> Self {
856        Self {
857            builder: self.builder.property("limit-events", limit_events),
858        }
859    }
860
861    /// Margin on bottom side of widget.
862    ///
863    /// This property adds margin outside of the widget's normal size
864    /// request, the margin will be added in addition to the size from
865    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
866    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
867        Self {
868            builder: self.builder.property("margin-bottom", margin_bottom),
869        }
870    }
871
872    /// Margin on end of widget, horizontally.
873    ///
874    /// This property supports left-to-right and right-to-left text
875    /// directions.
876    ///
877    /// This property adds margin outside of the widget's normal size
878    /// request, the margin will be added in addition to the size from
879    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
880    pub fn margin_end(self, margin_end: i32) -> Self {
881        Self {
882            builder: self.builder.property("margin-end", margin_end),
883        }
884    }
885
886    /// Margin on start of widget, horizontally.
887    ///
888    /// This property supports left-to-right and right-to-left text
889    /// directions.
890    ///
891    /// This property adds margin outside of the widget's normal size
892    /// request, the margin will be added in addition to the size from
893    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
894    pub fn margin_start(self, margin_start: i32) -> Self {
895        Self {
896            builder: self.builder.property("margin-start", margin_start),
897        }
898    }
899
900    /// Margin on top side of widget.
901    ///
902    /// This property adds margin outside of the widget's normal size
903    /// request, the margin will be added in addition to the size from
904    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
905    pub fn margin_top(self, margin_top: i32) -> Self {
906        Self {
907            builder: self.builder.property("margin-top", margin_top),
908        }
909    }
910
911    /// The name of the widget.
912    pub fn name(self, name: impl Into<glib::GString>) -> Self {
913        Self {
914            builder: self.builder.property("name", name.into()),
915        }
916    }
917
918    /// The requested opacity of the widget.
919    pub fn opacity(self, opacity: f64) -> Self {
920        Self {
921            builder: self.builder.property("opacity", opacity),
922        }
923    }
924
925    /// How content outside the widget's content area is treated.
926    ///
927    /// This property is meant to be set by widget implementations,
928    /// typically in their instance init function.
929    pub fn overflow(self, overflow: Overflow) -> Self {
930        Self {
931            builder: self.builder.property("overflow", overflow),
932        }
933    }
934
935    /// Whether the widget will receive the default action when it is focused.
936    pub fn receives_default(self, receives_default: bool) -> Self {
937        Self {
938            builder: self.builder.property("receives-default", receives_default),
939        }
940    }
941
942    /// Whether the widget responds to input.
943    pub fn sensitive(self, sensitive: bool) -> Self {
944        Self {
945            builder: self.builder.property("sensitive", sensitive),
946        }
947    }
948
949    /// Sets the text of tooltip to be the given string, which is marked up
950    /// with Pango markup.
951    ///
952    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
953    ///
954    /// This is a convenience property which will take care of getting the
955    /// tooltip shown if the given string is not `NULL`:
956    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
957    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
958    /// the default signal handler.
959    ///
960    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
961    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
962    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
963        Self {
964            builder: self
965                .builder
966                .property("tooltip-markup", tooltip_markup.into()),
967        }
968    }
969
970    /// Sets the text of tooltip to be the given string.
971    ///
972    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
973    ///
974    /// This is a convenience property which will take care of getting the
975    /// tooltip shown if the given string is not `NULL`:
976    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
977    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
978    /// the default signal handler.
979    ///
980    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
981    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
982    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
983        Self {
984            builder: self.builder.property("tooltip-text", tooltip_text.into()),
985        }
986    }
987
988    /// How to distribute vertical space if widget gets extra space.
989    pub fn valign(self, valign: Align) -> Self {
990        Self {
991            builder: self.builder.property("valign", valign),
992        }
993    }
994
995    /// Whether to expand vertically.
996    pub fn vexpand(self, vexpand: bool) -> Self {
997        Self {
998            builder: self.builder.property("vexpand", vexpand),
999        }
1000    }
1001
1002    /// Whether to use the `vexpand` property.
1003    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1004        Self {
1005            builder: self.builder.property("vexpand-set", vexpand_set),
1006        }
1007    }
1008
1009    /// Whether the widget is visible.
1010    pub fn visible(self, visible: bool) -> Self {
1011        Self {
1012            builder: self.builder.property("visible", visible),
1013        }
1014    }
1015
1016    /// Overrides for width request of the widget.
1017    ///
1018    /// If this is -1, the natural request will be used.
1019    pub fn width_request(self, width_request: i32) -> Self {
1020        Self {
1021            builder: self.builder.property("width-request", width_request),
1022        }
1023    }
1024
1025    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1026    ///
1027    /// The accessible role cannot be changed once set.
1028    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1029        Self {
1030            builder: self.builder.property("accessible-role", accessible_role),
1031        }
1032    }
1033
1034    // rustdoc-stripper-ignore-next
1035    /// Build the [`SearchBar`].
1036    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1037    pub fn build(self) -> SearchBar {
1038        assert_initialized_main_thread!();
1039        self.builder.build()
1040    }
1041}