Skip to main content

gtk4/auto/
info_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#![allow(deprecated)]
5
6#[cfg(feature = "v4_10")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
8use crate::Accessible;
9use crate::{
10    AccessibleRole, Align, Buildable, Button, ConstraintTarget, LayoutManager, MessageType,
11    Overflow, ResponseType, Widget, ffi,
12};
13use glib::{
14    object::ObjectType as _,
15    prelude::*,
16    signal::{SignalHandlerId, connect_raw},
17    translate::*,
18};
19use std::boxed::Box as Box_;
20
21#[cfg(feature = "v4_10")]
22#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
23glib::wrapper! {
24    /// There is no replacement in GTK for an "info bar" widget;
25    ///   you can use [`Revealer`][crate::Revealer] with a [`Box`][crate::Box] containing a
26    ///   [`Label`][crate::Label] and an optional [`Button`][crate::Button], according to
27    ///   your application's design.
28    /// ` element.
29    ///
30    /// # CSS nodes
31    ///
32    /// [`InfoBar`][crate::InfoBar] has a single CSS node with name infobar. The node may get
33    /// one of the style classes .info, .warning, .error or .question, depending
34    /// on the message type.
35    /// If the info bar shows a close button, that button will have the .close
36    /// style class applied.
37    ///
38    /// ## Properties
39    ///
40    ///
41    /// #### `message-type`
42    ///  The type of the message.
43    ///
44    /// The type may be used to determine the appearance of the info bar.
45    ///
46    /// Readable | Writable | Construct
47    ///
48    ///
49    /// #### `revealed`
50    ///  Whether the info bar shows its contents.
51    ///
52    /// Readable | Writable
53    ///
54    ///
55    /// #### `show-close-button`
56    ///  Whether to include a standard close button.
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    /// ## Signals
360    ///
361    ///
362    /// #### `close`
363    ///  Gets emitted when the user uses a keybinding to dismiss the info bar.
364    ///
365    /// The ::close signal is a [keybinding signal](class.SignalAction.html).
366    ///
367    /// The default binding for this signal is the Escape key.
368    ///
369    /// Action
370    ///
371    ///
372    /// #### `response`
373    ///  Emitted when an action widget is clicked.
374    ///
375    /// The signal is also emitted when the application programmer
376    /// calls [`InfoBar::response()`][crate::InfoBar::response()]. The @response_id depends
377    /// on which action widget was clicked.
378    ///
379    ///
380    /// <details><summary><h4>Widget</h4></summary>
381    ///
382    ///
383    /// #### `destroy`
384    ///  Signals that all holders of a reference to the widget should release
385    /// the reference that they hold.
386    ///
387    /// May result in finalization of the widget if all references are released.
388    ///
389    /// This signal is not suitable for saving widget state.
390    ///
391    ///
392    ///
393    ///
394    /// #### `direction-changed`
395    ///  Emitted when the text direction of a widget changes.
396    ///
397    ///
398    ///
399    ///
400    /// #### `hide`
401    ///  Emitted when @widget is hidden.
402    ///
403    ///
404    ///
405    ///
406    /// #### `keynav-failed`
407    ///  Emitted if keyboard navigation fails.
408    ///
409    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
410    ///
411    ///
412    ///
413    ///
414    /// #### `map`
415    ///  Emitted when @widget is going to be mapped.
416    ///
417    /// A widget is mapped when the widget is visible (which is controlled with
418    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
419    /// are also visible.
420    ///
421    /// The `::map` signal can be used to determine whether a widget will be drawn,
422    /// for instance it can resume an animation that was stopped during the
423    /// emission of [`unmap`][struct@crate::Widget#unmap].
424    ///
425    ///
426    ///
427    ///
428    /// #### `mnemonic-activate`
429    ///  Emitted when a widget is activated via a mnemonic.
430    ///
431    /// The default handler for this signal activates @widget if @group_cycling
432    /// is false, or just makes @widget grab focus if @group_cycling is true.
433    ///
434    ///
435    ///
436    ///
437    /// #### `move-focus`
438    ///   to move backward.
439    ///
440    /// Action
441    ///
442    ///
443    /// #### `query-tooltip`
444    ///  s tooltip is about to be shown.
445    ///
446    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
447    /// is true and the hover timeout has expired with the cursor hovering
448    /// above @widget; or emitted when @widget got focus in keyboard mode.
449    ///
450    /// Using the given coordinates, the signal handler should determine
451    /// whether a tooltip should be shown for @widget. If this is the case
452    /// true should be returned, false otherwise. Note that if @keyboard_mode
453    /// is true, the values of @x and @y are undefined and should not be used.
454    ///
455    /// The signal handler is free to manipulate @tooltip with the therefore
456    /// destined function calls.
457    ///
458    ///
459    ///
460    ///
461    /// #### `realize`
462    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
463    ///
464    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
465    /// or the widget has been mapped (that is, it is going to be drawn).
466    ///
467    ///
468    ///
469    ///
470    /// #### `show`
471    ///  Emitted when @widget is shown.
472    ///
473    ///
474    ///
475    ///
476    /// #### `state-flags-changed`
477    ///  Emitted when the widget state changes.
478    ///
479    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
480    ///
481    ///
482    ///
483    ///
484    /// #### `unmap`
485    ///  Emitted when @widget is going to be unmapped.
486    ///
487    /// A widget is unmapped when either it or any of its parents up to the
488    /// toplevel widget have been set as hidden.
489    ///
490    /// As `::unmap` indicates that a widget will not be shown any longer,
491    /// it can be used to, for example, stop an animation on the widget.
492    ///
493    ///
494    ///
495    ///
496    /// #### `unrealize`
497    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
498    ///
499    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
500    /// or the widget has been unmapped (that is, it is going to be hidden).
501    ///
502    ///
503    /// </details>
504    ///
505    /// # Implements
506    ///
507    /// [`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]
508    #[doc(alias = "GtkInfoBar")]
509    pub struct InfoBar(Object<ffi::GtkInfoBar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
510
511    match fn {
512        type_ => || ffi::gtk_info_bar_get_type(),
513    }
514}
515
516#[cfg(not(feature = "v4_10"))]
517glib::wrapper! {
518    #[doc(alias = "GtkInfoBar")]
519    pub struct InfoBar(Object<ffi::GtkInfoBar>) @extends Widget, @implements Buildable, ConstraintTarget;
520
521    match fn {
522        type_ => || ffi::gtk_info_bar_get_type(),
523    }
524}
525
526impl InfoBar {
527    /// Creates a new [`InfoBar`][crate::InfoBar] object.
528    ///
529    /// # Deprecated since 4.10
530    ///
531    ///
532    /// # Returns
533    ///
534    /// a new [`InfoBar`][crate::InfoBar] object
535    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
536    #[allow(deprecated)]
537    #[doc(alias = "gtk_info_bar_new")]
538    pub fn new() -> InfoBar {
539        assert_initialized_main_thread!();
540        unsafe { Widget::from_glib_none(ffi::gtk_info_bar_new()).unsafe_cast() }
541    }
542
543    // rustdoc-stripper-ignore-next
544    /// Creates a new builder-pattern struct instance to construct [`InfoBar`] objects.
545    ///
546    /// This method returns an instance of [`InfoBarBuilder`](crate::builders::InfoBarBuilder) which can be used to create [`InfoBar`] objects.
547    pub fn builder() -> InfoBarBuilder {
548        InfoBarBuilder::new()
549    }
550
551    /// Add an activatable widget to the action area of a [`InfoBar`][crate::InfoBar].
552    ///
553    /// This also connects a signal handler that will emit the
554    /// [`response`][struct@crate::InfoBar#response] signal on the message area
555    /// when the widget is activated. The widget is appended to the
556    /// end of the message areas action area.
557    ///
558    /// # Deprecated since 4.10
559    ///
560    /// ## `child`
561    /// an activatable widget
562    /// ## `response_id`
563    /// response ID for @child
564    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
565    #[allow(deprecated)]
566    #[doc(alias = "gtk_info_bar_add_action_widget")]
567    pub fn add_action_widget(&self, child: &impl IsA<Widget>, response_id: ResponseType) {
568        unsafe {
569            ffi::gtk_info_bar_add_action_widget(
570                self.to_glib_none().0,
571                child.as_ref().to_glib_none().0,
572                response_id.into_glib(),
573            );
574        }
575    }
576
577    /// Adds a button with the given text.
578    ///
579    /// Clicking the button will emit the [`response`][struct@crate::InfoBar#response]
580    /// signal with the given response_id. The button is appended to the
581    /// end of the info bar's action area. The button widget is returned,
582    /// but usually you don't need it.
583    ///
584    /// # Deprecated since 4.10
585    ///
586    /// ## `button_text`
587    /// text of button
588    /// ## `response_id`
589    /// response ID for the button
590    ///
591    /// # Returns
592    ///
593    /// the [`Button`][crate::Button] widget
594    /// that was added
595    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
596    #[allow(deprecated)]
597    #[doc(alias = "gtk_info_bar_add_button")]
598    pub fn add_button(&self, button_text: &str, response_id: ResponseType) -> Button {
599        unsafe {
600            from_glib_none(ffi::gtk_info_bar_add_button(
601                self.to_glib_none().0,
602                button_text.to_glib_none().0,
603                response_id.into_glib(),
604            ))
605        }
606    }
607
608    /// Adds a widget to the content area of the info bar.
609    ///
610    /// # Deprecated since 4.10
611    ///
612    /// ## `widget`
613    /// the child to be added
614    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
615    #[allow(deprecated)]
616    #[doc(alias = "gtk_info_bar_add_child")]
617    pub fn add_child(&self, widget: &impl IsA<Widget>) {
618        unsafe {
619            ffi::gtk_info_bar_add_child(self.to_glib_none().0, widget.as_ref().to_glib_none().0);
620        }
621    }
622
623    /// Returns the message type of the message area.
624    ///
625    /// # Deprecated since 4.10
626    ///
627    ///
628    /// # Returns
629    ///
630    /// the message type of the message area.
631    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
632    #[allow(deprecated)]
633    #[doc(alias = "gtk_info_bar_get_message_type")]
634    #[doc(alias = "get_message_type")]
635    #[doc(alias = "message-type")]
636    pub fn message_type(&self) -> MessageType {
637        unsafe { from_glib(ffi::gtk_info_bar_get_message_type(self.to_glib_none().0)) }
638    }
639
640    /// Returns whether the info bar is currently revealed.
641    ///
642    /// # Deprecated since 4.10
643    ///
644    ///
645    /// # Returns
646    ///
647    /// the current value of the [`revealed`][struct@crate::InfoBar#revealed] property
648    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
649    #[allow(deprecated)]
650    #[doc(alias = "gtk_info_bar_get_revealed")]
651    #[doc(alias = "get_revealed")]
652    #[doc(alias = "revealed")]
653    pub fn is_revealed(&self) -> bool {
654        unsafe { from_glib(ffi::gtk_info_bar_get_revealed(self.to_glib_none().0)) }
655    }
656
657    /// Returns whether the widget will display a standard close button.
658    ///
659    /// # Deprecated since 4.10
660    ///
661    ///
662    /// # Returns
663    ///
664    /// [`true`] if the widget displays standard close button
665    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
666    #[allow(deprecated)]
667    #[doc(alias = "gtk_info_bar_get_show_close_button")]
668    #[doc(alias = "get_show_close_button")]
669    #[doc(alias = "show-close-button")]
670    pub fn shows_close_button(&self) -> bool {
671        unsafe {
672            from_glib(ffi::gtk_info_bar_get_show_close_button(
673                self.to_glib_none().0,
674            ))
675        }
676    }
677
678    /// Removes a widget from the action area of @self.
679    ///
680    /// The widget must have been put there by a call to
681    /// [`add_action_widget()`][Self::add_action_widget()] or [`add_button()`][Self::add_button()].
682    ///
683    /// # Deprecated since 4.10
684    ///
685    /// ## `widget`
686    /// an action widget to remove
687    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
688    #[allow(deprecated)]
689    #[doc(alias = "gtk_info_bar_remove_action_widget")]
690    pub fn remove_action_widget(&self, widget: &impl IsA<Widget>) {
691        unsafe {
692            ffi::gtk_info_bar_remove_action_widget(
693                self.to_glib_none().0,
694                widget.as_ref().to_glib_none().0,
695            );
696        }
697    }
698
699    /// Removes a widget from the content area of the info bar.
700    ///
701    /// # Deprecated since 4.10
702    ///
703    /// ## `widget`
704    /// a child that has been added to the content area
705    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
706    #[allow(deprecated)]
707    #[doc(alias = "gtk_info_bar_remove_child")]
708    pub fn remove_child(&self, widget: &impl IsA<Widget>) {
709        unsafe {
710            ffi::gtk_info_bar_remove_child(self.to_glib_none().0, widget.as_ref().to_glib_none().0);
711        }
712    }
713
714    ///  signal with the given @response_id.
715    ///
716    /// # Deprecated since 4.10
717    ///
718    /// ## `response_id`
719    /// a response ID
720    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
721    #[allow(deprecated)]
722    #[doc(alias = "gtk_info_bar_response")]
723    pub fn response(&self, response_id: ResponseType) {
724        unsafe {
725            ffi::gtk_info_bar_response(self.to_glib_none().0, response_id.into_glib());
726        }
727    }
728
729    ///  normally activates the default widget.
730    ///
731    /// Note that this function currently requires @self to
732    /// be added to a widget hierarchy.
733    ///
734    /// # Deprecated since 4.10
735    ///
736    /// ## `response_id`
737    /// a response ID
738    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
739    #[allow(deprecated)]
740    #[doc(alias = "gtk_info_bar_set_default_response")]
741    pub fn set_default_response(&self, response_id: ResponseType) {
742        unsafe {
743            ffi::gtk_info_bar_set_default_response(self.to_glib_none().0, response_id.into_glib());
744        }
745    }
746
747    /// Sets the message type of the message area.
748    ///
749    /// GTK uses this type to determine how the message is displayed.
750    ///
751    /// # Deprecated since 4.10
752    ///
753    /// ## `message_type`
754    /// a [`MessageType`][crate::MessageType]
755    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
756    #[allow(deprecated)]
757    #[doc(alias = "gtk_info_bar_set_message_type")]
758    #[doc(alias = "message-type")]
759    pub fn set_message_type(&self, message_type: MessageType) {
760        unsafe {
761            ffi::gtk_info_bar_set_message_type(self.to_glib_none().0, message_type.into_glib());
762        }
763    }
764
765    /// s action area with the given @response_id.
766    /// A convenient way to sensitize/desensitize buttons.
767    ///
768    /// # Deprecated since 4.10
769    ///
770    /// ## `response_id`
771    /// a response ID
772    /// ## `setting`
773    /// TRUE for sensitive
774    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
775    #[allow(deprecated)]
776    #[doc(alias = "gtk_info_bar_set_response_sensitive")]
777    pub fn set_response_sensitive(&self, response_id: ResponseType, setting: bool) {
778        unsafe {
779            ffi::gtk_info_bar_set_response_sensitive(
780                self.to_glib_none().0,
781                response_id.into_glib(),
782                setting.into_glib(),
783            );
784        }
785    }
786
787    /// Sets whether the [`InfoBar`][crate::InfoBar] is revealed.
788    ///
789    /// Changing this will make @self reveal or conceal
790    /// itself via a sliding transition.
791    ///
792    /// Note: this does not show or hide @self in the
793    /// [`visible`][struct@crate::Widget#visible] sense, so revealing has no effect
794    /// if [`visible`][struct@crate::Widget#visible] is [`false`].
795    ///
796    /// # Deprecated since 4.10
797    ///
798    /// ## `revealed`
799    /// The new value of the property
800    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
801    #[allow(deprecated)]
802    #[doc(alias = "gtk_info_bar_set_revealed")]
803    #[doc(alias = "revealed")]
804    pub fn set_revealed(&self, revealed: bool) {
805        unsafe {
806            ffi::gtk_info_bar_set_revealed(self.to_glib_none().0, revealed.into_glib());
807        }
808    }
809
810    /// If true, a standard close button is shown.
811    ///
812    /// When clicked it emits the response [`ResponseType::Close`][crate::ResponseType::Close].
813    ///
814    /// # Deprecated since 4.10
815    ///
816    /// ## `setting`
817    /// [`true`] to include a close button
818    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
819    #[allow(deprecated)]
820    #[doc(alias = "gtk_info_bar_set_show_close_button")]
821    #[doc(alias = "show-close-button")]
822    pub fn set_show_close_button(&self, setting: bool) {
823        unsafe {
824            ffi::gtk_info_bar_set_show_close_button(self.to_glib_none().0, setting.into_glib());
825        }
826    }
827
828    /// Gets emitted when the user uses a keybinding to dismiss the info bar.
829    ///
830    /// The ::close signal is a [keybinding signal](class.SignalAction.html).
831    ///
832    /// The default binding for this signal is the Escape key.
833    #[doc(alias = "close")]
834    pub fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
835        unsafe extern "C" fn close_trampoline<F: Fn(&InfoBar) + 'static>(
836            this: *mut ffi::GtkInfoBar,
837            f: glib::ffi::gpointer,
838        ) {
839            unsafe {
840                let f: &F = &*(f as *const F);
841                f(&from_glib_borrow(this))
842            }
843        }
844        unsafe {
845            let f: Box_<F> = Box_::new(f);
846            connect_raw(
847                self.as_ptr() as *mut _,
848                c"close".as_ptr(),
849                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
850                    close_trampoline::<F> as *const (),
851                )),
852                Box_::into_raw(f),
853            )
854        }
855    }
856
857    pub fn emit_close(&self) {
858        self.emit_by_name::<()>("close", &[]);
859    }
860
861    /// Emitted when an action widget is clicked.
862    ///
863    /// The signal is also emitted when the application programmer
864    /// calls [`response()`][Self::response()]. The @response_id depends
865    /// on which action widget was clicked.
866    /// ## `response_id`
867    /// the response ID
868    #[doc(alias = "response")]
869    pub fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId {
870        unsafe extern "C" fn response_trampoline<F: Fn(&InfoBar, ResponseType) + 'static>(
871            this: *mut ffi::GtkInfoBar,
872            response_id: ffi::GtkResponseType,
873            f: glib::ffi::gpointer,
874        ) {
875            unsafe {
876                let f: &F = &*(f as *const F);
877                f(&from_glib_borrow(this), from_glib(response_id))
878            }
879        }
880        unsafe {
881            let f: Box_<F> = Box_::new(f);
882            connect_raw(
883                self.as_ptr() as *mut _,
884                c"response".as_ptr(),
885                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
886                    response_trampoline::<F> as *const (),
887                )),
888                Box_::into_raw(f),
889            )
890        }
891    }
892
893    #[doc(alias = "message-type")]
894    pub fn connect_message_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
895        unsafe extern "C" fn notify_message_type_trampoline<F: Fn(&InfoBar) + 'static>(
896            this: *mut ffi::GtkInfoBar,
897            _param_spec: glib::ffi::gpointer,
898            f: glib::ffi::gpointer,
899        ) {
900            unsafe {
901                let f: &F = &*(f as *const F);
902                f(&from_glib_borrow(this))
903            }
904        }
905        unsafe {
906            let f: Box_<F> = Box_::new(f);
907            connect_raw(
908                self.as_ptr() as *mut _,
909                c"notify::message-type".as_ptr(),
910                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
911                    notify_message_type_trampoline::<F> as *const (),
912                )),
913                Box_::into_raw(f),
914            )
915        }
916    }
917
918    #[doc(alias = "revealed")]
919    pub fn connect_revealed_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
920        unsafe extern "C" fn notify_revealed_trampoline<F: Fn(&InfoBar) + 'static>(
921            this: *mut ffi::GtkInfoBar,
922            _param_spec: glib::ffi::gpointer,
923            f: glib::ffi::gpointer,
924        ) {
925            unsafe {
926                let f: &F = &*(f as *const F);
927                f(&from_glib_borrow(this))
928            }
929        }
930        unsafe {
931            let f: Box_<F> = Box_::new(f);
932            connect_raw(
933                self.as_ptr() as *mut _,
934                c"notify::revealed".as_ptr(),
935                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
936                    notify_revealed_trampoline::<F> as *const (),
937                )),
938                Box_::into_raw(f),
939            )
940        }
941    }
942
943    #[doc(alias = "show-close-button")]
944    pub fn connect_show_close_button_notify<F: Fn(&Self) + 'static>(
945        &self,
946        f: F,
947    ) -> SignalHandlerId {
948        unsafe extern "C" fn notify_show_close_button_trampoline<F: Fn(&InfoBar) + 'static>(
949            this: *mut ffi::GtkInfoBar,
950            _param_spec: glib::ffi::gpointer,
951            f: glib::ffi::gpointer,
952        ) {
953            unsafe {
954                let f: &F = &*(f as *const F);
955                f(&from_glib_borrow(this))
956            }
957        }
958        unsafe {
959            let f: Box_<F> = Box_::new(f);
960            connect_raw(
961                self.as_ptr() as *mut _,
962                c"notify::show-close-button".as_ptr(),
963                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
964                    notify_show_close_button_trampoline::<F> as *const (),
965                )),
966                Box_::into_raw(f),
967            )
968        }
969    }
970}
971
972impl Default for InfoBar {
973    fn default() -> Self {
974        Self::new()
975    }
976}
977
978// rustdoc-stripper-ignore-next
979/// A [builder-pattern] type to construct [`InfoBar`] objects.
980///
981/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
982#[must_use = "The builder must be built to be used"]
983pub struct InfoBarBuilder {
984    builder: glib::object::ObjectBuilder<'static, InfoBar>,
985}
986
987impl InfoBarBuilder {
988    fn new() -> Self {
989        Self {
990            builder: glib::object::Object::builder(),
991        }
992    }
993
994    /// The type of the message.
995    ///
996    /// The type may be used to determine the appearance of the info bar.
997    pub fn message_type(self, message_type: MessageType) -> Self {
998        Self {
999            builder: self.builder.property("message-type", message_type),
1000        }
1001    }
1002
1003    /// Whether the info bar shows its contents.
1004    pub fn revealed(self, revealed: bool) -> Self {
1005        Self {
1006            builder: self.builder.property("revealed", revealed),
1007        }
1008    }
1009
1010    /// Whether to include a standard close button.
1011    pub fn show_close_button(self, show_close_button: bool) -> Self {
1012        Self {
1013            builder: self
1014                .builder
1015                .property("show-close-button", show_close_button),
1016        }
1017    }
1018
1019    /// Whether the widget or any of its descendents can accept
1020    /// the input focus.
1021    ///
1022    /// This property is meant to be set by widget implementations,
1023    /// typically in their instance init function.
1024    pub fn can_focus(self, can_focus: bool) -> Self {
1025        Self {
1026            builder: self.builder.property("can-focus", can_focus),
1027        }
1028    }
1029
1030    /// Whether the widget can receive pointer events.
1031    pub fn can_target(self, can_target: bool) -> Self {
1032        Self {
1033            builder: self.builder.property("can-target", can_target),
1034        }
1035    }
1036
1037    /// A list of css classes applied to this widget.
1038    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1039        Self {
1040            builder: self.builder.property("css-classes", css_classes.into()),
1041        }
1042    }
1043
1044    /// The name of this widget in the CSS tree.
1045    ///
1046    /// This property is meant to be set by widget implementations,
1047    /// typically in their instance init function.
1048    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1049        Self {
1050            builder: self.builder.property("css-name", css_name.into()),
1051        }
1052    }
1053
1054    /// The cursor used by @widget.
1055    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1056        Self {
1057            builder: self.builder.property("cursor", cursor.clone()),
1058        }
1059    }
1060
1061    /// Whether the widget should grab focus when it is clicked with the mouse.
1062    ///
1063    /// This property is only relevant for widgets that can take focus.
1064    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1065        Self {
1066            builder: self.builder.property("focus-on-click", focus_on_click),
1067        }
1068    }
1069
1070    /// Whether this widget itself will accept the input focus.
1071    pub fn focusable(self, focusable: bool) -> Self {
1072        Self {
1073            builder: self.builder.property("focusable", focusable),
1074        }
1075    }
1076
1077    /// How to distribute horizontal space if widget gets extra space.
1078    pub fn halign(self, halign: Align) -> Self {
1079        Self {
1080            builder: self.builder.property("halign", halign),
1081        }
1082    }
1083
1084    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1085    /// signal on @widget.
1086    ///
1087    /// A true value indicates that @widget can have a tooltip, in this case
1088    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1089    /// determine whether it will provide a tooltip or not.
1090    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1091        Self {
1092            builder: self.builder.property("has-tooltip", has_tooltip),
1093        }
1094    }
1095
1096    /// Overrides for height request of the widget.
1097    ///
1098    /// If this is -1, the natural request will be used.
1099    pub fn height_request(self, height_request: i32) -> Self {
1100        Self {
1101            builder: self.builder.property("height-request", height_request),
1102        }
1103    }
1104
1105    /// Whether to expand horizontally.
1106    pub fn hexpand(self, hexpand: bool) -> Self {
1107        Self {
1108            builder: self.builder.property("hexpand", hexpand),
1109        }
1110    }
1111
1112    /// Whether to use the `hexpand` property.
1113    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1114        Self {
1115            builder: self.builder.property("hexpand-set", hexpand_set),
1116        }
1117    }
1118
1119    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1120    /// the preferred size of the widget, and allocate its children.
1121    ///
1122    /// This property is meant to be set by widget implementations,
1123    /// typically in their instance init function.
1124    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1125        Self {
1126            builder: self
1127                .builder
1128                .property("layout-manager", layout_manager.clone().upcast()),
1129        }
1130    }
1131
1132    /// Makes this widget act like a modal dialog, with respect to
1133    /// event delivery.
1134    ///
1135    /// Global event controllers will not handle events with targets
1136    /// inside the widget, unless they are set up to ignore propagation
1137    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1138    #[cfg(feature = "v4_18")]
1139    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1140    pub fn limit_events(self, limit_events: bool) -> Self {
1141        Self {
1142            builder: self.builder.property("limit-events", limit_events),
1143        }
1144    }
1145
1146    /// Margin on bottom side of widget.
1147    ///
1148    /// This property adds margin outside of the widget's normal size
1149    /// request, the margin will be added in addition to the size from
1150    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1151    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1152        Self {
1153            builder: self.builder.property("margin-bottom", margin_bottom),
1154        }
1155    }
1156
1157    /// Margin on end of widget, horizontally.
1158    ///
1159    /// This property supports left-to-right and right-to-left text
1160    /// directions.
1161    ///
1162    /// This property adds margin outside of the widget's normal size
1163    /// request, the margin will be added in addition to the size from
1164    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1165    pub fn margin_end(self, margin_end: i32) -> Self {
1166        Self {
1167            builder: self.builder.property("margin-end", margin_end),
1168        }
1169    }
1170
1171    /// Margin on start of widget, horizontally.
1172    ///
1173    /// This property supports left-to-right and right-to-left text
1174    /// directions.
1175    ///
1176    /// This property adds margin outside of the widget's normal size
1177    /// request, the margin will be added in addition to the size from
1178    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1179    pub fn margin_start(self, margin_start: i32) -> Self {
1180        Self {
1181            builder: self.builder.property("margin-start", margin_start),
1182        }
1183    }
1184
1185    /// Margin on top side of widget.
1186    ///
1187    /// This property adds margin outside of the widget's normal size
1188    /// request, the margin will be added in addition to the size from
1189    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1190    pub fn margin_top(self, margin_top: i32) -> Self {
1191        Self {
1192            builder: self.builder.property("margin-top", margin_top),
1193        }
1194    }
1195
1196    /// The name of the widget.
1197    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1198        Self {
1199            builder: self.builder.property("name", name.into()),
1200        }
1201    }
1202
1203    /// The requested opacity of the widget.
1204    pub fn opacity(self, opacity: f64) -> Self {
1205        Self {
1206            builder: self.builder.property("opacity", opacity),
1207        }
1208    }
1209
1210    /// How content outside the widget's content area is treated.
1211    ///
1212    /// This property is meant to be set by widget implementations,
1213    /// typically in their instance init function.
1214    pub fn overflow(self, overflow: Overflow) -> Self {
1215        Self {
1216            builder: self.builder.property("overflow", overflow),
1217        }
1218    }
1219
1220    /// Whether the widget will receive the default action when it is focused.
1221    pub fn receives_default(self, receives_default: bool) -> Self {
1222        Self {
1223            builder: self.builder.property("receives-default", receives_default),
1224        }
1225    }
1226
1227    /// Whether the widget responds to input.
1228    pub fn sensitive(self, sensitive: bool) -> Self {
1229        Self {
1230            builder: self.builder.property("sensitive", sensitive),
1231        }
1232    }
1233
1234    /// Sets the text of tooltip to be the given string, which is marked up
1235    /// with Pango markup.
1236    ///
1237    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1238    ///
1239    /// This is a convenience property which will take care of getting the
1240    /// tooltip shown if the given string is not `NULL`:
1241    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1242    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1243    /// the default signal handler.
1244    ///
1245    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1246    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1247    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1248        Self {
1249            builder: self
1250                .builder
1251                .property("tooltip-markup", tooltip_markup.into()),
1252        }
1253    }
1254
1255    /// Sets the text of tooltip to be the given string.
1256    ///
1257    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1258    ///
1259    /// This is a convenience property which will take care of getting the
1260    /// tooltip shown if the given string is not `NULL`:
1261    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1262    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1263    /// the default signal handler.
1264    ///
1265    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1266    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1267    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1268        Self {
1269            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1270        }
1271    }
1272
1273    /// How to distribute vertical space if widget gets extra space.
1274    pub fn valign(self, valign: Align) -> Self {
1275        Self {
1276            builder: self.builder.property("valign", valign),
1277        }
1278    }
1279
1280    /// Whether to expand vertically.
1281    pub fn vexpand(self, vexpand: bool) -> Self {
1282        Self {
1283            builder: self.builder.property("vexpand", vexpand),
1284        }
1285    }
1286
1287    /// Whether to use the `vexpand` property.
1288    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1289        Self {
1290            builder: self.builder.property("vexpand-set", vexpand_set),
1291        }
1292    }
1293
1294    /// Whether the widget is visible.
1295    pub fn visible(self, visible: bool) -> Self {
1296        Self {
1297            builder: self.builder.property("visible", visible),
1298        }
1299    }
1300
1301    /// Overrides for width request of the widget.
1302    ///
1303    /// If this is -1, the natural request will be used.
1304    pub fn width_request(self, width_request: i32) -> Self {
1305        Self {
1306            builder: self.builder.property("width-request", width_request),
1307        }
1308    }
1309
1310    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1311    ///
1312    /// The accessible role cannot be changed once set.
1313    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1314        Self {
1315            builder: self.builder.property("accessible-role", accessible_role),
1316        }
1317    }
1318
1319    // rustdoc-stripper-ignore-next
1320    /// Build the [`InfoBar`].
1321    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1322    pub fn build(self) -> InfoBar {
1323        assert_initialized_main_thread!();
1324        self.builder.build()
1325    }
1326}