Skip to main content

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