libadwaita/auto/
banner.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::ffi;
7#[cfg(feature = "v1_7")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
9use crate::BannerButtonStyle;
10use glib::{
11    object::ObjectType as _,
12    prelude::*,
13    signal::{connect_raw, SignalHandlerId},
14    translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19    /// A bar with contextual information.
20    ///
21    /// <picture>
22    ///   <source srcset="banner-dark.png" media="(prefers-color-scheme: dark)">
23    ///   <img src="banner.png" alt="banner">
24    /// </picture>
25    ///
26    /// Banners are hidden by default, use [`revealed`][struct@crate::Banner#revealed] to show them.
27    ///
28    /// Banners have a title, set with [`title`][struct@crate::Banner#title]. Titles can be marked
29    /// up with Pango markup, use [`use-markup`][struct@crate::Banner#use-markup] to enable it.
30    ///
31    /// The title will be shown centered or left-aligned depending on available
32    /// space.
33    ///
34    /// Banners can optionally have a button with text on it, set through
35    /// [`button-label`][struct@crate::Banner#button-label]. The button can be used with a `GAction`,
36    /// or with the [`button-clicked`][struct@crate::Banner#button-clicked] signal. The button can have
37    /// different styles, a gray style and a suggested style.
38    ///
39    /// <picture>
40    ///   <source srcset="banner-suggested-dark.png" media="(prefers-color-scheme: dark)">
41    ///   <img src="banner-suggested.png" alt="banner with suggested button style">
42    /// </picture>
43    ///
44    /// ## CSS nodes
45    ///
46    /// [`Banner`][crate::Banner] has a main CSS node with the name `banner`.
47    ///
48    /// ## Properties
49    ///
50    ///
51    /// #### `button-label`
52    ///  The label to show on the button.
53    ///
54    /// If set to `""` or `NULL`, the button won't be shown.
55    ///
56    /// The button can be used with a `GAction`, or with the
57    /// [`button-clicked`][struct@crate::Banner#button-clicked] signal.
58    ///
59    /// Readable | Writeable
60    ///
61    ///
62    /// #### `button-style`
63    ///  The style class to use for the banner button.
64    ///
65    /// When set to `ADW_BANNER_BUTTON_DEFAULT`, the button stays grey.
66    /// When set to `ADW_BANNER_BUTTON_SUGGESTED`, the button follows the [`.suggested-action`](style-classes.html#suggested-action) style
67    ///
68    /// <picture>
69    ///   <source srcset="banner-suggested-dark.png" media="(prefers-color-scheme: dark)">
70    ///   <img src="banner-suggested.png" alt="banner with suggested button style">
71    /// </picture>
72    ///
73    /// Readable | Writeable
74    ///
75    ///
76    /// #### `revealed`
77    ///  Whether the banner is currently revealed.
78    ///
79    /// Readable | Writeable
80    ///
81    ///
82    /// #### `title`
83    ///  The title for this banner.
84    ///
85    /// See also: [`use-markup`][struct@crate::Banner#use-markup].
86    ///
87    /// Readable | Writeable
88    ///
89    ///
90    /// #### `use-markup`
91    ///  Whether to use Pango markup for the banner title.
92    ///
93    /// See also `parse_markup()`.
94    ///
95    /// Readable | Writeable
96    /// <details><summary><h4>Widget</h4></summary>
97    ///
98    ///
99    /// #### `can-focus`
100    ///  Whether the widget or any of its descendents can accept
101    /// the input focus.
102    ///
103    /// This property is meant to be set by widget implementations,
104    /// typically in their instance init function.
105    ///
106    /// Readable | Writeable
107    ///
108    ///
109    /// #### `can-target`
110    ///  Whether the widget can receive pointer events.
111    ///
112    /// Readable | Writeable
113    ///
114    ///
115    /// #### `css-classes`
116    ///  A list of css classes applied to this widget.
117    ///
118    /// Readable | Writeable
119    ///
120    ///
121    /// #### `css-name`
122    ///  The name of this widget in the CSS tree.
123    ///
124    /// This property is meant to be set by widget implementations,
125    /// typically in their instance init function.
126    ///
127    /// Readable | Writeable | Construct Only
128    ///
129    ///
130    /// #### `cursor`
131    ///  The cursor used by @widget.
132    ///
133    /// Readable | Writeable
134    ///
135    ///
136    /// #### `focus-on-click`
137    ///  Whether the widget should grab focus when it is clicked with the mouse.
138    ///
139    /// This property is only relevant for widgets that can take focus.
140    ///
141    /// Readable | Writeable
142    ///
143    ///
144    /// #### `focusable`
145    ///  Whether this widget itself will accept the input focus.
146    ///
147    /// Readable | Writeable
148    ///
149    ///
150    /// #### `halign`
151    ///  How to distribute horizontal space if widget gets extra space.
152    ///
153    /// Readable | Writeable
154    ///
155    ///
156    /// #### `has-default`
157    ///  Whether the widget is the default widget.
158    ///
159    /// Readable
160    ///
161    ///
162    /// #### `has-focus`
163    ///  Whether the widget has the input focus.
164    ///
165    /// Readable
166    ///
167    ///
168    /// #### `has-tooltip`
169    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
170    /// signal on @widget.
171    ///
172    /// A true value indicates that @widget can have a tooltip, in this case
173    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
174    /// determine whether it will provide a tooltip or not.
175    ///
176    /// Readable | Writeable
177    ///
178    ///
179    /// #### `height-request`
180    ///  Overrides for height request of the widget.
181    ///
182    /// If this is -1, the natural request will be used.
183    ///
184    /// Readable | Writeable
185    ///
186    ///
187    /// #### `hexpand`
188    ///  Whether to expand horizontally.
189    ///
190    /// Readable | Writeable
191    ///
192    ///
193    /// #### `hexpand-set`
194    ///  Whether to use the `hexpand` property.
195    ///
196    /// Readable | Writeable
197    ///
198    ///
199    /// #### `layout-manager`
200    ///  The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
201    /// the preferred size of the widget, and allocate its children.
202    ///
203    /// This property is meant to be set by widget implementations,
204    /// typically in their instance init function.
205    ///
206    /// Readable | Writeable
207    ///
208    ///
209    /// #### `limit-events`
210    ///  Makes this widget act like a modal dialog, with respect to
211    /// event delivery.
212    ///
213    /// Global event controllers will not handle events with targets
214    /// inside the widget, unless they are set up to ignore propagation
215    /// limits. See `Gtk::EventController::set_propagation_limit()`.
216    ///
217    /// Readable | Writeable
218    ///
219    ///
220    /// #### `margin-bottom`
221    ///  Margin on bottom side of widget.
222    ///
223    /// This property adds margin outside of the widget's normal size
224    /// request, the margin will be added in addition to the size from
225    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
226    ///
227    /// Readable | Writeable
228    ///
229    ///
230    /// #### `margin-end`
231    ///  Margin on end of widget, horizontally.
232    ///
233    /// This property supports left-to-right and right-to-left text
234    /// directions.
235    ///
236    /// This property adds margin outside of the widget's normal size
237    /// request, the margin will be added in addition to the size from
238    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
239    ///
240    /// Readable | Writeable
241    ///
242    ///
243    /// #### `margin-start`
244    ///  Margin on start of widget, horizontally.
245    ///
246    /// This property supports left-to-right and right-to-left text
247    /// directions.
248    ///
249    /// This property adds margin outside of the widget's normal size
250    /// request, the margin will be added in addition to the size from
251    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
252    ///
253    /// Readable | Writeable
254    ///
255    ///
256    /// #### `margin-top`
257    ///  Margin on top side of widget.
258    ///
259    /// This property adds margin outside of the widget's normal size
260    /// request, the margin will be added in addition to the size from
261    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
262    ///
263    /// Readable | Writeable
264    ///
265    ///
266    /// #### `name`
267    ///  The name of the widget.
268    ///
269    /// Readable | Writeable
270    ///
271    ///
272    /// #### `opacity`
273    ///  The requested opacity of the widget.
274    ///
275    /// Readable | Writeable
276    ///
277    ///
278    /// #### `overflow`
279    ///  How content outside the widget's content area is treated.
280    ///
281    /// This property is meant to be set by widget implementations,
282    /// typically in their instance init function.
283    ///
284    /// Readable | Writeable
285    ///
286    ///
287    /// #### `parent`
288    ///  The parent widget of this widget.
289    ///
290    /// Readable
291    ///
292    ///
293    /// #### `receives-default`
294    ///  Whether the widget will receive the default action when it is focused.
295    ///
296    /// Readable | Writeable
297    ///
298    ///
299    /// #### `root`
300    ///  The [`gtk::Root`][crate::gtk::Root] widget of the widget tree containing this widget.
301    ///
302    /// This will be `NULL` if the widget is not contained in a root widget.
303    ///
304    /// Readable
305    ///
306    ///
307    /// #### `scale-factor`
308    ///  The scale factor of the widget.
309    ///
310    /// Readable
311    ///
312    ///
313    /// #### `sensitive`
314    ///  Whether the widget responds to input.
315    ///
316    /// Readable | Writeable
317    ///
318    ///
319    /// #### `tooltip-markup`
320    ///  Sets the text of tooltip to be the given string, which is marked up
321    /// with Pango markup.
322    ///
323    /// Also see `Gtk::Tooltip::set_markup()`.
324    ///
325    /// This is a convenience property which will take care of getting the
326    /// tooltip shown if the given string is not `NULL`:
327    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
328    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
329    /// the default signal handler.
330    ///
331    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
332    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
333    ///
334    /// Readable | Writeable
335    ///
336    ///
337    /// #### `tooltip-text`
338    ///  Sets the text of tooltip to be the given string.
339    ///
340    /// Also see `Gtk::Tooltip::set_text()`.
341    ///
342    /// This is a convenience property which will take care of getting the
343    /// tooltip shown if the given string is not `NULL`:
344    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
345    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
346    /// the default signal handler.
347    ///
348    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
349    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
350    ///
351    /// Readable | Writeable
352    ///
353    ///
354    /// #### `valign`
355    ///  How to distribute vertical space if widget gets extra space.
356    ///
357    /// Readable | Writeable
358    ///
359    ///
360    /// #### `vexpand`
361    ///  Whether to expand vertically.
362    ///
363    /// Readable | Writeable
364    ///
365    ///
366    /// #### `vexpand-set`
367    ///  Whether to use the `vexpand` property.
368    ///
369    /// Readable | Writeable
370    ///
371    ///
372    /// #### `visible`
373    ///  Whether the widget is visible.
374    ///
375    /// Readable | Writeable
376    ///
377    ///
378    /// #### `width-request`
379    ///  Overrides for width request of the widget.
380    ///
381    /// If this is -1, the natural request will be used.
382    ///
383    /// Readable | Writeable
384    /// </details>
385    /// <details><summary><h4>Accessible</h4></summary>
386    ///
387    ///
388    /// #### `accessible-role`
389    ///  The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
390    ///
391    /// The accessible role cannot be changed once set.
392    ///
393    /// Readable | Writeable
394    /// </details>
395    /// <details><summary><h4>Actionable</h4></summary>
396    ///
397    ///
398    /// #### `action-name`
399    ///  The name of the action with which this widget should be associated.
400    ///
401    /// Readable | Writeable
402    ///
403    ///
404    /// #### `action-target`
405    ///  The target value of the actionable widget's action.
406    ///
407    /// Readable | Writeable
408    /// </details>
409    ///
410    /// ## Signals
411    ///
412    ///
413    /// #### `button-clicked`
414    ///  This signal is emitted after the action button has been clicked.
415    ///
416    /// It can be used as an alternative to setting an action.
417    ///
418    ///
419    /// <details><summary><h4>Widget</h4></summary>
420    ///
421    ///
422    /// #### `destroy`
423    ///  Signals that all holders of a reference to the widget should release
424    /// the reference that they hold.
425    ///
426    /// May result in finalization of the widget if all references are released.
427    ///
428    /// This signal is not suitable for saving widget state.
429    ///
430    ///
431    ///
432    ///
433    /// #### `direction-changed`
434    ///  Emitted when the text direction of a widget changes.
435    ///
436    ///
437    ///
438    ///
439    /// #### `hide`
440    ///  Emitted when @widget is hidden.
441    ///
442    ///
443    ///
444    ///
445    /// #### `keynav-failed`
446    ///  Emitted if keyboard navigation fails.
447    ///
448    /// See [`WidgetExtManual::keynav_failed()`][crate::gtk::prelude::WidgetExtManual::keynav_failed()] for details.
449    ///
450    ///
451    ///
452    ///
453    /// #### `map`
454    ///  Emitted when @widget is going to be mapped.
455    ///
456    /// A widget is mapped when the widget is visible (which is controlled with
457    /// [`visible`][struct@crate::gtk::Widget#visible]) and all its parents up to the toplevel widget
458    /// are also visible.
459    ///
460    /// The `::map` signal can be used to determine whether a widget will be drawn,
461    /// for instance it can resume an animation that was stopped during the
462    /// emission of [`unmap`][struct@crate::gtk::Widget#unmap].
463    ///
464    ///
465    ///
466    ///
467    /// #### `mnemonic-activate`
468    ///  Emitted when a widget is activated via a mnemonic.
469    ///
470    /// The default handler for this signal activates @widget if @group_cycling
471    /// is false, or just makes @widget grab focus if @group_cycling is true.
472    ///
473    ///
474    ///
475    ///
476    /// #### `move-focus`
477    ///  Emitted when the focus is moved.
478    ///
479    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
480    ///
481    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
482    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
483    ///
484    /// Action
485    ///
486    ///
487    /// #### `query-tooltip`
488    ///  Emitted when the widget’s tooltip is about to be shown.
489    ///
490    /// This happens when the [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] property
491    /// is true and the hover timeout has expired with the cursor hovering
492    /// above @widget; or emitted when @widget got focus in keyboard mode.
493    ///
494    /// Using the given coordinates, the signal handler should determine
495    /// whether a tooltip should be shown for @widget. If this is the case
496    /// true should be returned, false otherwise. Note that if @keyboard_mode
497    /// is true, the values of @x and @y are undefined and should not be used.
498    ///
499    /// The signal handler is free to manipulate @tooltip with the therefore
500    /// destined function calls.
501    ///
502    ///
503    ///
504    ///
505    /// #### `realize`
506    ///  Emitted when @widget is associated with a `GdkSurface`.
507    ///
508    /// This means that [`WidgetExtManual::realize()`][crate::gtk::prelude::WidgetExtManual::realize()] has been called
509    /// or the widget has been mapped (that is, it is going to be drawn).
510    ///
511    ///
512    ///
513    ///
514    /// #### `show`
515    ///  Emitted when @widget is shown.
516    ///
517    ///
518    ///
519    ///
520    /// #### `state-flags-changed`
521    ///  Emitted when the widget state changes.
522    ///
523    /// See [`WidgetExtManual::state_flags()`][crate::gtk::prelude::WidgetExtManual::state_flags()].
524    ///
525    ///
526    ///
527    ///
528    /// #### `unmap`
529    ///  Emitted when @widget is going to be unmapped.
530    ///
531    /// A widget is unmapped when either it or any of its parents up to the
532    /// toplevel widget have been set as hidden.
533    ///
534    /// As `::unmap` indicates that a widget will not be shown any longer,
535    /// it can be used to, for example, stop an animation on the widget.
536    ///
537    ///
538    ///
539    ///
540    /// #### `unrealize`
541    ///  Emitted when the `GdkSurface` associated with @widget is destroyed.
542    ///
543    /// This means that [`WidgetExtManual::unrealize()`][crate::gtk::prelude::WidgetExtManual::unrealize()] has been called
544    /// or the widget has been unmapped (that is, it is going to be hidden).
545    ///
546    ///
547    /// </details>
548    ///
549    /// # Implements
550    ///
551    /// [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`], [`trait@gtk::prelude::ActionableExt`]
552    #[doc(alias = "AdwBanner")]
553    pub struct Banner(Object<ffi::AdwBanner, ffi::AdwBannerClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
554
555    match fn {
556        type_ => || ffi::adw_banner_get_type(),
557    }
558}
559
560impl Banner {
561    /// Creates a new [`Banner`][crate::Banner].
562    /// ## `title`
563    /// the banner title
564    ///
565    /// # Returns
566    ///
567    /// the newly created [`Banner`][crate::Banner]
568    #[doc(alias = "adw_banner_new")]
569    pub fn new(title: &str) -> Banner {
570        assert_initialized_main_thread!();
571        unsafe {
572            gtk::Widget::from_glib_none(ffi::adw_banner_new(title.to_glib_none().0)).unsafe_cast()
573        }
574    }
575
576    // rustdoc-stripper-ignore-next
577    /// Creates a new builder-pattern struct instance to construct [`Banner`] objects.
578    ///
579    /// This method returns an instance of [`BannerBuilder`](crate::builders::BannerBuilder) which can be used to create [`Banner`] objects.
580    pub fn builder() -> BannerBuilder {
581        BannerBuilder::new()
582    }
583
584    /// Gets the button label for @self.
585    ///
586    /// # Returns
587    ///
588    /// the button label for @self
589    #[doc(alias = "adw_banner_get_button_label")]
590    #[doc(alias = "get_button_label")]
591    #[doc(alias = "button-label")]
592    pub fn button_label(&self) -> Option<glib::GString> {
593        unsafe { from_glib_none(ffi::adw_banner_get_button_label(self.to_glib_none().0)) }
594    }
595
596    /// Gets the style class in use for the banner button.
597    ///
598    /// # Returns
599    ///
600    /// the current button style
601    #[cfg(feature = "v1_7")]
602    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
603    #[doc(alias = "adw_banner_get_button_style")]
604    #[doc(alias = "get_button_style")]
605    #[doc(alias = "button-style")]
606    pub fn button_style(&self) -> BannerButtonStyle {
607        unsafe { from_glib(ffi::adw_banner_get_button_style(self.to_glib_none().0)) }
608    }
609
610    /// Gets if a banner is revealed
611    ///
612    /// # Returns
613    ///
614    /// Whether a banner is revealed
615    #[doc(alias = "adw_banner_get_revealed")]
616    #[doc(alias = "get_revealed")]
617    #[doc(alias = "revealed")]
618    pub fn is_revealed(&self) -> bool {
619        unsafe { from_glib(ffi::adw_banner_get_revealed(self.to_glib_none().0)) }
620    }
621
622    /// Gets the title for @self.
623    ///
624    /// # Returns
625    ///
626    /// the title for @self
627    #[doc(alias = "adw_banner_get_title")]
628    #[doc(alias = "get_title")]
629    pub fn title(&self) -> glib::GString {
630        unsafe { from_glib_none(ffi::adw_banner_get_title(self.to_glib_none().0)) }
631    }
632
633    /// Gets whether to use Pango markup for the banner title.
634    ///
635    /// # Returns
636    ///
637    /// whether to use markup
638    #[doc(alias = "adw_banner_get_use_markup")]
639    #[doc(alias = "get_use_markup")]
640    #[doc(alias = "use-markup")]
641    pub fn uses_markup(&self) -> bool {
642        unsafe { from_glib(ffi::adw_banner_get_use_markup(self.to_glib_none().0)) }
643    }
644
645    /// Sets the button label for @self.
646    ///
647    /// If set to `""` or `NULL`, the button won't be shown.
648    ///
649    /// The button can be used with a `GAction`, or with the
650    /// [`button-clicked`][struct@crate::Banner#button-clicked] signal.
651    /// ## `label`
652    /// the label
653    #[doc(alias = "adw_banner_set_button_label")]
654    #[doc(alias = "button-label")]
655    pub fn set_button_label(&self, label: Option<&str>) {
656        unsafe {
657            ffi::adw_banner_set_button_label(self.to_glib_none().0, label.to_glib_none().0);
658        }
659    }
660
661    /// Sets the style class to use for the banner button.
662    ///
663    /// When set to `ADW_BANNER_BUTTON_DEFAULT`, the button stays grey.
664    /// When set to `ADW_BANNER_BUTTON_SUGGESTED`, the button follows the [`.suggested-action`](style-classes.html#suggested-action) style
665    ///
666    /// <picture>
667    ///   <source srcset="banner-suggested-dark.png" media="(prefers-color-scheme: dark)">
668    ///   <img src="banner-suggested.png" alt="banner with suggested button style">
669    /// </picture>
670    /// ## `style`
671    /// a button style
672    #[cfg(feature = "v1_7")]
673    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
674    #[doc(alias = "adw_banner_set_button_style")]
675    #[doc(alias = "button-style")]
676    pub fn set_button_style(&self, style: BannerButtonStyle) {
677        unsafe {
678            ffi::adw_banner_set_button_style(self.to_glib_none().0, style.into_glib());
679        }
680    }
681
682    /// Sets whether a banner should be revealed
683    /// ## `revealed`
684    /// whether a banner should be revealed
685    #[doc(alias = "adw_banner_set_revealed")]
686    #[doc(alias = "revealed")]
687    pub fn set_revealed(&self, revealed: bool) {
688        unsafe {
689            ffi::adw_banner_set_revealed(self.to_glib_none().0, revealed.into_glib());
690        }
691    }
692
693    /// Sets the title for this banner.
694    ///
695    /// See also: [`use-markup`][struct@crate::Banner#use-markup].
696    /// ## `title`
697    /// the title
698    #[doc(alias = "adw_banner_set_title")]
699    #[doc(alias = "title")]
700    pub fn set_title(&self, title: &str) {
701        unsafe {
702            ffi::adw_banner_set_title(self.to_glib_none().0, title.to_glib_none().0);
703        }
704    }
705
706    /// Sets whether to use Pango markup for the banner title.
707    ///
708    /// See also `parse_markup()`.
709    /// ## `use_markup`
710    /// whether to use markup
711    #[doc(alias = "adw_banner_set_use_markup")]
712    #[doc(alias = "use-markup")]
713    pub fn set_use_markup(&self, use_markup: bool) {
714        unsafe {
715            ffi::adw_banner_set_use_markup(self.to_glib_none().0, use_markup.into_glib());
716        }
717    }
718
719    /// This signal is emitted after the action button has been clicked.
720    ///
721    /// It can be used as an alternative to setting an action.
722    #[cfg(feature = "v1_3")]
723    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
724    #[doc(alias = "button-clicked")]
725    pub fn connect_button_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
726        unsafe extern "C" fn button_clicked_trampoline<F: Fn(&Banner) + 'static>(
727            this: *mut ffi::AdwBanner,
728            f: glib::ffi::gpointer,
729        ) {
730            let f: &F = &*(f as *const F);
731            f(&from_glib_borrow(this))
732        }
733        unsafe {
734            let f: Box_<F> = Box_::new(f);
735            connect_raw(
736                self.as_ptr() as *mut _,
737                c"button-clicked".as_ptr() as *const _,
738                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
739                    button_clicked_trampoline::<F> as *const (),
740                )),
741                Box_::into_raw(f),
742            )
743        }
744    }
745
746    #[cfg(feature = "v1_3")]
747    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
748    #[doc(alias = "button-label")]
749    pub fn connect_button_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
750        unsafe extern "C" fn notify_button_label_trampoline<F: Fn(&Banner) + 'static>(
751            this: *mut ffi::AdwBanner,
752            _param_spec: glib::ffi::gpointer,
753            f: glib::ffi::gpointer,
754        ) {
755            let f: &F = &*(f as *const F);
756            f(&from_glib_borrow(this))
757        }
758        unsafe {
759            let f: Box_<F> = Box_::new(f);
760            connect_raw(
761                self.as_ptr() as *mut _,
762                c"notify::button-label".as_ptr() as *const _,
763                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
764                    notify_button_label_trampoline::<F> as *const (),
765                )),
766                Box_::into_raw(f),
767            )
768        }
769    }
770
771    #[cfg(feature = "v1_7")]
772    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
773    #[doc(alias = "button-style")]
774    pub fn connect_button_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
775        unsafe extern "C" fn notify_button_style_trampoline<F: Fn(&Banner) + 'static>(
776            this: *mut ffi::AdwBanner,
777            _param_spec: glib::ffi::gpointer,
778            f: glib::ffi::gpointer,
779        ) {
780            let f: &F = &*(f as *const F);
781            f(&from_glib_borrow(this))
782        }
783        unsafe {
784            let f: Box_<F> = Box_::new(f);
785            connect_raw(
786                self.as_ptr() as *mut _,
787                c"notify::button-style".as_ptr() as *const _,
788                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
789                    notify_button_style_trampoline::<F> as *const (),
790                )),
791                Box_::into_raw(f),
792            )
793        }
794    }
795
796    #[cfg(feature = "v1_3")]
797    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
798    #[doc(alias = "revealed")]
799    pub fn connect_revealed_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
800        unsafe extern "C" fn notify_revealed_trampoline<F: Fn(&Banner) + 'static>(
801            this: *mut ffi::AdwBanner,
802            _param_spec: glib::ffi::gpointer,
803            f: glib::ffi::gpointer,
804        ) {
805            let f: &F = &*(f as *const F);
806            f(&from_glib_borrow(this))
807        }
808        unsafe {
809            let f: Box_<F> = Box_::new(f);
810            connect_raw(
811                self.as_ptr() as *mut _,
812                c"notify::revealed".as_ptr() as *const _,
813                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
814                    notify_revealed_trampoline::<F> as *const (),
815                )),
816                Box_::into_raw(f),
817            )
818        }
819    }
820
821    #[cfg(feature = "v1_3")]
822    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
823    #[doc(alias = "title")]
824    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
825        unsafe extern "C" fn notify_title_trampoline<F: Fn(&Banner) + 'static>(
826            this: *mut ffi::AdwBanner,
827            _param_spec: glib::ffi::gpointer,
828            f: glib::ffi::gpointer,
829        ) {
830            let f: &F = &*(f as *const F);
831            f(&from_glib_borrow(this))
832        }
833        unsafe {
834            let f: Box_<F> = Box_::new(f);
835            connect_raw(
836                self.as_ptr() as *mut _,
837                c"notify::title".as_ptr() as *const _,
838                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
839                    notify_title_trampoline::<F> as *const (),
840                )),
841                Box_::into_raw(f),
842            )
843        }
844    }
845
846    #[cfg(feature = "v1_3")]
847    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
848    #[doc(alias = "use-markup")]
849    pub fn connect_use_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
850        unsafe extern "C" fn notify_use_markup_trampoline<F: Fn(&Banner) + 'static>(
851            this: *mut ffi::AdwBanner,
852            _param_spec: glib::ffi::gpointer,
853            f: glib::ffi::gpointer,
854        ) {
855            let f: &F = &*(f as *const F);
856            f(&from_glib_borrow(this))
857        }
858        unsafe {
859            let f: Box_<F> = Box_::new(f);
860            connect_raw(
861                self.as_ptr() as *mut _,
862                c"notify::use-markup".as_ptr() as *const _,
863                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
864                    notify_use_markup_trampoline::<F> as *const (),
865                )),
866                Box_::into_raw(f),
867            )
868        }
869    }
870}
871
872#[cfg(feature = "v1_3")]
873#[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
874impl Default for Banner {
875    fn default() -> Self {
876        glib::object::Object::new::<Self>()
877    }
878}
879
880// rustdoc-stripper-ignore-next
881/// A [builder-pattern] type to construct [`Banner`] objects.
882///
883/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
884#[must_use = "The builder must be built to be used"]
885pub struct BannerBuilder {
886    builder: glib::object::ObjectBuilder<'static, Banner>,
887}
888
889impl BannerBuilder {
890    fn new() -> Self {
891        Self {
892            builder: glib::object::Object::builder(),
893        }
894    }
895
896    /// The label to show on the button.
897    ///
898    /// If set to `""` or `NULL`, the button won't be shown.
899    ///
900    /// The button can be used with a `GAction`, or with the
901    /// [`button-clicked`][struct@crate::Banner#button-clicked] signal.
902    #[cfg(feature = "v1_3")]
903    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
904    pub fn button_label(self, button_label: impl Into<glib::GString>) -> Self {
905        Self {
906            builder: self.builder.property("button-label", button_label.into()),
907        }
908    }
909
910    /// The style class to use for the banner button.
911    ///
912    /// When set to `ADW_BANNER_BUTTON_DEFAULT`, the button stays grey.
913    /// When set to `ADW_BANNER_BUTTON_SUGGESTED`, the button follows the [`.suggested-action`](style-classes.html#suggested-action) style
914    ///
915    /// <picture>
916    ///   <source srcset="banner-suggested-dark.png" media="(prefers-color-scheme: dark)">
917    ///   <img src="banner-suggested.png" alt="banner with suggested button style">
918    /// </picture>
919    #[cfg(feature = "v1_7")]
920    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
921    pub fn button_style(self, button_style: BannerButtonStyle) -> Self {
922        Self {
923            builder: self.builder.property("button-style", button_style),
924        }
925    }
926
927    /// Whether the banner is currently revealed.
928    #[cfg(feature = "v1_3")]
929    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
930    pub fn revealed(self, revealed: bool) -> Self {
931        Self {
932            builder: self.builder.property("revealed", revealed),
933        }
934    }
935
936    /// The title for this banner.
937    ///
938    /// See also: [`use-markup`][struct@crate::Banner#use-markup].
939    #[cfg(feature = "v1_3")]
940    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
941    pub fn title(self, title: impl Into<glib::GString>) -> Self {
942        Self {
943            builder: self.builder.property("title", title.into()),
944        }
945    }
946
947    /// Whether to use Pango markup for the banner title.
948    ///
949    /// See also `parse_markup()`.
950    #[cfg(feature = "v1_3")]
951    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
952    pub fn use_markup(self, use_markup: bool) -> Self {
953        Self {
954            builder: self.builder.property("use-markup", use_markup),
955        }
956    }
957
958    /// Whether the widget or any of its descendents can accept
959    /// the input focus.
960    ///
961    /// This property is meant to be set by widget implementations,
962    /// typically in their instance init function.
963    pub fn can_focus(self, can_focus: bool) -> Self {
964        Self {
965            builder: self.builder.property("can-focus", can_focus),
966        }
967    }
968
969    /// Whether the widget can receive pointer events.
970    pub fn can_target(self, can_target: bool) -> Self {
971        Self {
972            builder: self.builder.property("can-target", can_target),
973        }
974    }
975
976    /// A list of css classes applied to this widget.
977    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
978        Self {
979            builder: self.builder.property("css-classes", css_classes.into()),
980        }
981    }
982
983    /// The name of this widget in the CSS tree.
984    ///
985    /// This property is meant to be set by widget implementations,
986    /// typically in their instance init function.
987    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
988        Self {
989            builder: self.builder.property("css-name", css_name.into()),
990        }
991    }
992
993    /// The cursor used by @widget.
994    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
995        Self {
996            builder: self.builder.property("cursor", cursor.clone()),
997        }
998    }
999
1000    /// Whether the widget should grab focus when it is clicked with the mouse.
1001    ///
1002    /// This property is only relevant for widgets that can take focus.
1003    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1004        Self {
1005            builder: self.builder.property("focus-on-click", focus_on_click),
1006        }
1007    }
1008
1009    /// Whether this widget itself will accept the input focus.
1010    pub fn focusable(self, focusable: bool) -> Self {
1011        Self {
1012            builder: self.builder.property("focusable", focusable),
1013        }
1014    }
1015
1016    /// How to distribute horizontal space if widget gets extra space.
1017    pub fn halign(self, halign: gtk::Align) -> Self {
1018        Self {
1019            builder: self.builder.property("halign", halign),
1020        }
1021    }
1022
1023    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
1024    /// signal on @widget.
1025    ///
1026    /// A true value indicates that @widget can have a tooltip, in this case
1027    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
1028    /// determine whether it will provide a tooltip or not.
1029    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1030        Self {
1031            builder: self.builder.property("has-tooltip", has_tooltip),
1032        }
1033    }
1034
1035    /// Overrides for height request of the widget.
1036    ///
1037    /// If this is -1, the natural request will be used.
1038    pub fn height_request(self, height_request: i32) -> Self {
1039        Self {
1040            builder: self.builder.property("height-request", height_request),
1041        }
1042    }
1043
1044    /// Whether to expand horizontally.
1045    pub fn hexpand(self, hexpand: bool) -> Self {
1046        Self {
1047            builder: self.builder.property("hexpand", hexpand),
1048        }
1049    }
1050
1051    /// Whether to use the `hexpand` property.
1052    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1053        Self {
1054            builder: self.builder.property("hexpand-set", hexpand_set),
1055        }
1056    }
1057
1058    /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
1059    /// the preferred size of the widget, and allocate its children.
1060    ///
1061    /// This property is meant to be set by widget implementations,
1062    /// typically in their instance init function.
1063    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
1064        Self {
1065            builder: self
1066                .builder
1067                .property("layout-manager", layout_manager.clone().upcast()),
1068        }
1069    }
1070
1071    /// Makes this widget act like a modal dialog, with respect to
1072    /// event delivery.
1073    ///
1074    /// Global event controllers will not handle events with targets
1075    /// inside the widget, unless they are set up to ignore propagation
1076    /// limits. See `Gtk::EventController::set_propagation_limit()`.
1077    #[cfg(feature = "gtk_v4_18")]
1078    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
1079    pub fn limit_events(self, limit_events: bool) -> Self {
1080        Self {
1081            builder: self.builder.property("limit-events", limit_events),
1082        }
1083    }
1084
1085    /// Margin on bottom side of widget.
1086    ///
1087    /// This property adds margin outside of the widget's normal size
1088    /// request, the margin will be added in addition to the size from
1089    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1090    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1091        Self {
1092            builder: self.builder.property("margin-bottom", margin_bottom),
1093        }
1094    }
1095
1096    /// Margin on end of widget, horizontally.
1097    ///
1098    /// This property supports left-to-right and right-to-left text
1099    /// directions.
1100    ///
1101    /// This property adds margin outside of the widget's normal size
1102    /// request, the margin will be added in addition to the size from
1103    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1104    pub fn margin_end(self, margin_end: i32) -> Self {
1105        Self {
1106            builder: self.builder.property("margin-end", margin_end),
1107        }
1108    }
1109
1110    /// Margin on start of widget, horizontally.
1111    ///
1112    /// This property supports left-to-right and right-to-left text
1113    /// directions.
1114    ///
1115    /// This property adds margin outside of the widget's normal size
1116    /// request, the margin will be added in addition to the size from
1117    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1118    pub fn margin_start(self, margin_start: i32) -> Self {
1119        Self {
1120            builder: self.builder.property("margin-start", margin_start),
1121        }
1122    }
1123
1124    /// Margin on top side of widget.
1125    ///
1126    /// This property adds margin outside of the widget's normal size
1127    /// request, the margin will be added in addition to the size from
1128    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1129    pub fn margin_top(self, margin_top: i32) -> Self {
1130        Self {
1131            builder: self.builder.property("margin-top", margin_top),
1132        }
1133    }
1134
1135    /// The name of the widget.
1136    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1137        Self {
1138            builder: self.builder.property("name", name.into()),
1139        }
1140    }
1141
1142    /// The requested opacity of the widget.
1143    pub fn opacity(self, opacity: f64) -> Self {
1144        Self {
1145            builder: self.builder.property("opacity", opacity),
1146        }
1147    }
1148
1149    /// How content outside the widget's content area is treated.
1150    ///
1151    /// This property is meant to be set by widget implementations,
1152    /// typically in their instance init function.
1153    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
1154        Self {
1155            builder: self.builder.property("overflow", overflow),
1156        }
1157    }
1158
1159    /// Whether the widget will receive the default action when it is focused.
1160    pub fn receives_default(self, receives_default: bool) -> Self {
1161        Self {
1162            builder: self.builder.property("receives-default", receives_default),
1163        }
1164    }
1165
1166    /// Whether the widget responds to input.
1167    pub fn sensitive(self, sensitive: bool) -> Self {
1168        Self {
1169            builder: self.builder.property("sensitive", sensitive),
1170        }
1171    }
1172
1173    /// Sets the text of tooltip to be the given string, which is marked up
1174    /// with Pango markup.
1175    ///
1176    /// Also see `Gtk::Tooltip::set_markup()`.
1177    ///
1178    /// This is a convenience property which will take care of getting the
1179    /// tooltip shown if the given string is not `NULL`:
1180    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1181    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1182    /// the default signal handler.
1183    ///
1184    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1185    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1186    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1187        Self {
1188            builder: self
1189                .builder
1190                .property("tooltip-markup", tooltip_markup.into()),
1191        }
1192    }
1193
1194    /// Sets the text of tooltip to be the given string.
1195    ///
1196    /// Also see `Gtk::Tooltip::set_text()`.
1197    ///
1198    /// This is a convenience property which will take care of getting the
1199    /// tooltip shown if the given string is not `NULL`:
1200    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1201    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1202    /// the default signal handler.
1203    ///
1204    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1205    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1206    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1207        Self {
1208            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1209        }
1210    }
1211
1212    /// How to distribute vertical space if widget gets extra space.
1213    pub fn valign(self, valign: gtk::Align) -> Self {
1214        Self {
1215            builder: self.builder.property("valign", valign),
1216        }
1217    }
1218
1219    /// Whether to expand vertically.
1220    pub fn vexpand(self, vexpand: bool) -> Self {
1221        Self {
1222            builder: self.builder.property("vexpand", vexpand),
1223        }
1224    }
1225
1226    /// Whether to use the `vexpand` property.
1227    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1228        Self {
1229            builder: self.builder.property("vexpand-set", vexpand_set),
1230        }
1231    }
1232
1233    /// Whether the widget is visible.
1234    pub fn visible(self, visible: bool) -> Self {
1235        Self {
1236            builder: self.builder.property("visible", visible),
1237        }
1238    }
1239
1240    /// Overrides for width request of the widget.
1241    ///
1242    /// If this is -1, the natural request will be used.
1243    pub fn width_request(self, width_request: i32) -> Self {
1244        Self {
1245            builder: self.builder.property("width-request", width_request),
1246        }
1247    }
1248
1249    /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
1250    ///
1251    /// The accessible role cannot be changed once set.
1252    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
1253        Self {
1254            builder: self.builder.property("accessible-role", accessible_role),
1255        }
1256    }
1257
1258    /// The name of the action with which this widget should be associated.
1259    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1260        Self {
1261            builder: self.builder.property("action-name", action_name.into()),
1262        }
1263    }
1264
1265    /// The target value of the actionable widget's action.
1266    pub fn action_target(self, action_target: &glib::Variant) -> Self {
1267        Self {
1268            builder: self
1269                .builder
1270                .property("action-target", action_target.clone()),
1271        }
1272    }
1273
1274    // rustdoc-stripper-ignore-next
1275    /// Build the [`Banner`].
1276    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1277    pub fn build(self) -> Banner {
1278        assert_initialized_main_thread!();
1279        self.builder.build()
1280    }
1281}