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