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