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    ///  Emitted when the widget’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    /// Emits the “response” 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    /// Sets the last widget in the info bar’s action area with
730    /// the given response_id as the default widget for the dialog.
731    ///
732    /// Pressing “Enter” normally activates the default widget.
733    ///
734    /// Note that this function currently requires @self to
735    /// be added to a widget hierarchy.
736    ///
737    /// # Deprecated since 4.10
738    ///
739    /// ## `response_id`
740    /// a response ID
741    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
742    #[allow(deprecated)]
743    #[doc(alias = "gtk_info_bar_set_default_response")]
744    pub fn set_default_response(&self, response_id: ResponseType) {
745        unsafe {
746            ffi::gtk_info_bar_set_default_response(self.to_glib_none().0, response_id.into_glib());
747        }
748    }
749
750    /// Sets the message type of the message area.
751    ///
752    /// GTK uses this type to determine how the message is displayed.
753    ///
754    /// # Deprecated since 4.10
755    ///
756    /// ## `message_type`
757    /// a [`MessageType`][crate::MessageType]
758    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
759    #[allow(deprecated)]
760    #[doc(alias = "gtk_info_bar_set_message_type")]
761    #[doc(alias = "message-type")]
762    pub fn set_message_type(&self, message_type: MessageType) {
763        unsafe {
764            ffi::gtk_info_bar_set_message_type(self.to_glib_none().0, message_type.into_glib());
765        }
766    }
767
768    /// Sets the sensitivity of action widgets for @response_id.
769    ///
770    /// Calls `gtk_widget_set_sensitive (widget, setting)` for each
771    /// widget in the info bars’s action area with the given @response_id.
772    /// A convenient way to sensitize/desensitize buttons.
773    ///
774    /// # Deprecated since 4.10
775    ///
776    /// ## `response_id`
777    /// a response ID
778    /// ## `setting`
779    /// TRUE for sensitive
780    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
781    #[allow(deprecated)]
782    #[doc(alias = "gtk_info_bar_set_response_sensitive")]
783    pub fn set_response_sensitive(&self, response_id: ResponseType, setting: bool) {
784        unsafe {
785            ffi::gtk_info_bar_set_response_sensitive(
786                self.to_glib_none().0,
787                response_id.into_glib(),
788                setting.into_glib(),
789            );
790        }
791    }
792
793    /// Sets whether the [`InfoBar`][crate::InfoBar] is revealed.
794    ///
795    /// Changing this will make @self reveal or conceal
796    /// itself via a sliding transition.
797    ///
798    /// Note: this does not show or hide @self in the
799    /// [`visible`][struct@crate::Widget#visible] sense, so revealing has no effect
800    /// if [`visible`][struct@crate::Widget#visible] is [`false`].
801    ///
802    /// # Deprecated since 4.10
803    ///
804    /// ## `revealed`
805    /// The new value of the property
806    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
807    #[allow(deprecated)]
808    #[doc(alias = "gtk_info_bar_set_revealed")]
809    #[doc(alias = "revealed")]
810    pub fn set_revealed(&self, revealed: bool) {
811        unsafe {
812            ffi::gtk_info_bar_set_revealed(self.to_glib_none().0, revealed.into_glib());
813        }
814    }
815
816    /// If true, a standard close button is shown.
817    ///
818    /// When clicked it emits the response [`ResponseType::Close`][crate::ResponseType::Close].
819    ///
820    /// # Deprecated since 4.10
821    ///
822    /// ## `setting`
823    /// [`true`] to include a close button
824    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
825    #[allow(deprecated)]
826    #[doc(alias = "gtk_info_bar_set_show_close_button")]
827    #[doc(alias = "show-close-button")]
828    pub fn set_show_close_button(&self, setting: bool) {
829        unsafe {
830            ffi::gtk_info_bar_set_show_close_button(self.to_glib_none().0, setting.into_glib());
831        }
832    }
833
834    /// Gets emitted when the user uses a keybinding to dismiss the info bar.
835    ///
836    /// The ::close signal is a [keybinding signal](class.SignalAction.html).
837    ///
838    /// The default binding for this signal is the Escape key.
839    #[doc(alias = "close")]
840    pub fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
841        unsafe extern "C" fn close_trampoline<F: Fn(&InfoBar) + 'static>(
842            this: *mut ffi::GtkInfoBar,
843            f: glib::ffi::gpointer,
844        ) {
845            unsafe {
846                let f: &F = &*(f as *const F);
847                f(&from_glib_borrow(this))
848            }
849        }
850        unsafe {
851            let f: Box_<F> = Box_::new(f);
852            connect_raw(
853                self.as_ptr() as *mut _,
854                c"close".as_ptr(),
855                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
856                    close_trampoline::<F> as *const (),
857                )),
858                Box_::into_raw(f),
859            )
860        }
861    }
862
863    pub fn emit_close(&self) {
864        self.emit_by_name::<()>("close", &[]);
865    }
866
867    /// Emitted when an action widget is clicked.
868    ///
869    /// The signal is also emitted when the application programmer
870    /// calls [`response()`][Self::response()]. The @response_id depends
871    /// on which action widget was clicked.
872    /// ## `response_id`
873    /// the response ID
874    #[doc(alias = "response")]
875    pub fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId {
876        unsafe extern "C" fn response_trampoline<F: Fn(&InfoBar, ResponseType) + 'static>(
877            this: *mut ffi::GtkInfoBar,
878            response_id: ffi::GtkResponseType,
879            f: glib::ffi::gpointer,
880        ) {
881            unsafe {
882                let f: &F = &*(f as *const F);
883                f(&from_glib_borrow(this), from_glib(response_id))
884            }
885        }
886        unsafe {
887            let f: Box_<F> = Box_::new(f);
888            connect_raw(
889                self.as_ptr() as *mut _,
890                c"response".as_ptr(),
891                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
892                    response_trampoline::<F> as *const (),
893                )),
894                Box_::into_raw(f),
895            )
896        }
897    }
898
899    #[doc(alias = "message-type")]
900    pub fn connect_message_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
901        unsafe extern "C" fn notify_message_type_trampoline<F: Fn(&InfoBar) + 'static>(
902            this: *mut ffi::GtkInfoBar,
903            _param_spec: glib::ffi::gpointer,
904            f: glib::ffi::gpointer,
905        ) {
906            unsafe {
907                let f: &F = &*(f as *const F);
908                f(&from_glib_borrow(this))
909            }
910        }
911        unsafe {
912            let f: Box_<F> = Box_::new(f);
913            connect_raw(
914                self.as_ptr() as *mut _,
915                c"notify::message-type".as_ptr(),
916                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
917                    notify_message_type_trampoline::<F> as *const (),
918                )),
919                Box_::into_raw(f),
920            )
921        }
922    }
923
924    #[doc(alias = "revealed")]
925    pub fn connect_revealed_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
926        unsafe extern "C" fn notify_revealed_trampoline<F: Fn(&InfoBar) + 'static>(
927            this: *mut ffi::GtkInfoBar,
928            _param_spec: glib::ffi::gpointer,
929            f: glib::ffi::gpointer,
930        ) {
931            unsafe {
932                let f: &F = &*(f as *const F);
933                f(&from_glib_borrow(this))
934            }
935        }
936        unsafe {
937            let f: Box_<F> = Box_::new(f);
938            connect_raw(
939                self.as_ptr() as *mut _,
940                c"notify::revealed".as_ptr(),
941                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
942                    notify_revealed_trampoline::<F> as *const (),
943                )),
944                Box_::into_raw(f),
945            )
946        }
947    }
948
949    #[doc(alias = "show-close-button")]
950    pub fn connect_show_close_button_notify<F: Fn(&Self) + 'static>(
951        &self,
952        f: F,
953    ) -> SignalHandlerId {
954        unsafe extern "C" fn notify_show_close_button_trampoline<F: Fn(&InfoBar) + 'static>(
955            this: *mut ffi::GtkInfoBar,
956            _param_spec: glib::ffi::gpointer,
957            f: glib::ffi::gpointer,
958        ) {
959            unsafe {
960                let f: &F = &*(f as *const F);
961                f(&from_glib_borrow(this))
962            }
963        }
964        unsafe {
965            let f: Box_<F> = Box_::new(f);
966            connect_raw(
967                self.as_ptr() as *mut _,
968                c"notify::show-close-button".as_ptr(),
969                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
970                    notify_show_close_button_trampoline::<F> as *const (),
971                )),
972                Box_::into_raw(f),
973            )
974        }
975    }
976}
977
978impl Default for InfoBar {
979    fn default() -> Self {
980        Self::new()
981    }
982}
983
984// rustdoc-stripper-ignore-next
985/// A [builder-pattern] type to construct [`InfoBar`] objects.
986///
987/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
988#[must_use = "The builder must be built to be used"]
989pub struct InfoBarBuilder {
990    builder: glib::object::ObjectBuilder<'static, InfoBar>,
991}
992
993impl InfoBarBuilder {
994    fn new() -> Self {
995        Self {
996            builder: glib::object::Object::builder(),
997        }
998    }
999
1000    /// The type of the message.
1001    ///
1002    /// The type may be used to determine the appearance of the info bar.
1003    pub fn message_type(self, message_type: MessageType) -> Self {
1004        Self {
1005            builder: self.builder.property("message-type", message_type),
1006        }
1007    }
1008
1009    /// Whether the info bar shows its contents.
1010    pub fn revealed(self, revealed: bool) -> Self {
1011        Self {
1012            builder: self.builder.property("revealed", revealed),
1013        }
1014    }
1015
1016    /// Whether to include a standard close button.
1017    pub fn show_close_button(self, show_close_button: bool) -> Self {
1018        Self {
1019            builder: self
1020                .builder
1021                .property("show-close-button", show_close_button),
1022        }
1023    }
1024
1025    /// Whether the widget or any of its descendents can accept
1026    /// the input focus.
1027    ///
1028    /// This property is meant to be set by widget implementations,
1029    /// typically in their instance init function.
1030    pub fn can_focus(self, can_focus: bool) -> Self {
1031        Self {
1032            builder: self.builder.property("can-focus", can_focus),
1033        }
1034    }
1035
1036    /// Whether the widget can receive pointer events.
1037    pub fn can_target(self, can_target: bool) -> Self {
1038        Self {
1039            builder: self.builder.property("can-target", can_target),
1040        }
1041    }
1042
1043    /// A list of css classes applied to this widget.
1044    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1045        Self {
1046            builder: self.builder.property("css-classes", css_classes.into()),
1047        }
1048    }
1049
1050    /// The name of this widget in the CSS tree.
1051    ///
1052    /// This property is meant to be set by widget implementations,
1053    /// typically in their instance init function.
1054    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1055        Self {
1056            builder: self.builder.property("css-name", css_name.into()),
1057        }
1058    }
1059
1060    /// The cursor used by @widget.
1061    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1062        Self {
1063            builder: self.builder.property("cursor", cursor.clone()),
1064        }
1065    }
1066
1067    /// Whether the widget should grab focus when it is clicked with the mouse.
1068    ///
1069    /// This property is only relevant for widgets that can take focus.
1070    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1071        Self {
1072            builder: self.builder.property("focus-on-click", focus_on_click),
1073        }
1074    }
1075
1076    /// Whether this widget itself will accept the input focus.
1077    pub fn focusable(self, focusable: bool) -> Self {
1078        Self {
1079            builder: self.builder.property("focusable", focusable),
1080        }
1081    }
1082
1083    /// How to distribute horizontal space if widget gets extra space.
1084    pub fn halign(self, halign: Align) -> Self {
1085        Self {
1086            builder: self.builder.property("halign", halign),
1087        }
1088    }
1089
1090    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1091    /// signal on @widget.
1092    ///
1093    /// A true value indicates that @widget can have a tooltip, in this case
1094    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1095    /// determine whether it will provide a tooltip or not.
1096    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1097        Self {
1098            builder: self.builder.property("has-tooltip", has_tooltip),
1099        }
1100    }
1101
1102    /// Overrides for height request of the widget.
1103    ///
1104    /// If this is -1, the natural request will be used.
1105    pub fn height_request(self, height_request: i32) -> Self {
1106        Self {
1107            builder: self.builder.property("height-request", height_request),
1108        }
1109    }
1110
1111    /// Whether to expand horizontally.
1112    pub fn hexpand(self, hexpand: bool) -> Self {
1113        Self {
1114            builder: self.builder.property("hexpand", hexpand),
1115        }
1116    }
1117
1118    /// Whether to use the `hexpand` property.
1119    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1120        Self {
1121            builder: self.builder.property("hexpand-set", hexpand_set),
1122        }
1123    }
1124
1125    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1126    /// the preferred size of the widget, and allocate its children.
1127    ///
1128    /// This property is meant to be set by widget implementations,
1129    /// typically in their instance init function.
1130    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1131        Self {
1132            builder: self
1133                .builder
1134                .property("layout-manager", layout_manager.clone().upcast()),
1135        }
1136    }
1137
1138    /// Makes this widget act like a modal dialog, with respect to
1139    /// event delivery.
1140    ///
1141    /// Global event controllers will not handle events with targets
1142    /// inside the widget, unless they are set up to ignore propagation
1143    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1144    #[cfg(feature = "v4_18")]
1145    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1146    pub fn limit_events(self, limit_events: bool) -> Self {
1147        Self {
1148            builder: self.builder.property("limit-events", limit_events),
1149        }
1150    }
1151
1152    /// Margin on bottom side of widget.
1153    ///
1154    /// This property adds margin outside of the widget's normal size
1155    /// request, the margin will be added in addition to the size from
1156    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1157    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1158        Self {
1159            builder: self.builder.property("margin-bottom", margin_bottom),
1160        }
1161    }
1162
1163    /// Margin on end of widget, horizontally.
1164    ///
1165    /// This property supports left-to-right and right-to-left text
1166    /// directions.
1167    ///
1168    /// This property adds margin outside of the widget's normal size
1169    /// request, the margin will be added in addition to the size from
1170    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1171    pub fn margin_end(self, margin_end: i32) -> Self {
1172        Self {
1173            builder: self.builder.property("margin-end", margin_end),
1174        }
1175    }
1176
1177    /// Margin on start of widget, horizontally.
1178    ///
1179    /// This property supports left-to-right and right-to-left text
1180    /// directions.
1181    ///
1182    /// This property adds margin outside of the widget's normal size
1183    /// request, the margin will be added in addition to the size from
1184    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1185    pub fn margin_start(self, margin_start: i32) -> Self {
1186        Self {
1187            builder: self.builder.property("margin-start", margin_start),
1188        }
1189    }
1190
1191    /// Margin on top side of widget.
1192    ///
1193    /// This property adds margin outside of the widget's normal size
1194    /// request, the margin will be added in addition to the size from
1195    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1196    pub fn margin_top(self, margin_top: i32) -> Self {
1197        Self {
1198            builder: self.builder.property("margin-top", margin_top),
1199        }
1200    }
1201
1202    /// The name of the widget.
1203    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1204        Self {
1205            builder: self.builder.property("name", name.into()),
1206        }
1207    }
1208
1209    /// The requested opacity of the widget.
1210    pub fn opacity(self, opacity: f64) -> Self {
1211        Self {
1212            builder: self.builder.property("opacity", opacity),
1213        }
1214    }
1215
1216    /// How content outside the widget's content area is treated.
1217    ///
1218    /// This property is meant to be set by widget implementations,
1219    /// typically in their instance init function.
1220    pub fn overflow(self, overflow: Overflow) -> Self {
1221        Self {
1222            builder: self.builder.property("overflow", overflow),
1223        }
1224    }
1225
1226    /// Whether the widget will receive the default action when it is focused.
1227    pub fn receives_default(self, receives_default: bool) -> Self {
1228        Self {
1229            builder: self.builder.property("receives-default", receives_default),
1230        }
1231    }
1232
1233    /// Whether the widget responds to input.
1234    pub fn sensitive(self, sensitive: bool) -> Self {
1235        Self {
1236            builder: self.builder.property("sensitive", sensitive),
1237        }
1238    }
1239
1240    /// Sets the text of tooltip to be the given string, which is marked up
1241    /// with Pango markup.
1242    ///
1243    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1244    ///
1245    /// This is a convenience property which will take care of getting the
1246    /// tooltip shown if the given string is not `NULL`:
1247    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1248    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1249    /// the default signal handler.
1250    ///
1251    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1252    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1253    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1254        Self {
1255            builder: self
1256                .builder
1257                .property("tooltip-markup", tooltip_markup.into()),
1258        }
1259    }
1260
1261    /// Sets the text of tooltip to be the given string.
1262    ///
1263    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1264    ///
1265    /// This is a convenience property which will take care of getting the
1266    /// tooltip shown if the given string is not `NULL`:
1267    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1268    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1269    /// the default signal handler.
1270    ///
1271    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1272    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1273    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1274        Self {
1275            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1276        }
1277    }
1278
1279    /// How to distribute vertical space if widget gets extra space.
1280    pub fn valign(self, valign: Align) -> Self {
1281        Self {
1282            builder: self.builder.property("valign", valign),
1283        }
1284    }
1285
1286    /// Whether to expand vertically.
1287    pub fn vexpand(self, vexpand: bool) -> Self {
1288        Self {
1289            builder: self.builder.property("vexpand", vexpand),
1290        }
1291    }
1292
1293    /// Whether to use the `vexpand` property.
1294    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1295        Self {
1296            builder: self.builder.property("vexpand-set", vexpand_set),
1297        }
1298    }
1299
1300    /// Whether the widget is visible.
1301    pub fn visible(self, visible: bool) -> Self {
1302        Self {
1303            builder: self.builder.property("visible", visible),
1304        }
1305    }
1306
1307    /// Overrides for width request of the widget.
1308    ///
1309    /// If this is -1, the natural request will be used.
1310    pub fn width_request(self, width_request: i32) -> Self {
1311        Self {
1312            builder: self.builder.property("width-request", width_request),
1313        }
1314    }
1315
1316    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1317    ///
1318    /// The accessible role cannot be changed once set.
1319    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1320        Self {
1321            builder: self.builder.property("accessible-role", accessible_role),
1322        }
1323    }
1324
1325    // rustdoc-stripper-ignore-next
1326    /// Build the [`InfoBar`].
1327    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1328    pub fn build(self) -> InfoBar {
1329        assert_initialized_main_thread!();
1330        self.builder.build()
1331    }
1332}