gtk4/info_bar.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::{InfoBar, ResponseType};
4
5impl InfoBar {
6 /// Creates a new [`InfoBar`][crate::InfoBar] with buttons.
7 ///
8 /// Button text/response ID pairs should be listed, with a [`None`] pointer
9 /// ending the list. A response ID can be any positive number,
10 /// or one of the values in the [`ResponseType`][crate::ResponseType] enumeration. If the
11 /// user clicks one of these dialog buttons, GtkInfoBar will emit
12 /// the [`response`][struct@crate::InfoBar#response] signal with the corresponding
13 /// response ID.
14 ///
15 /// # Deprecated since 4.10
16 ///
17 /// ## `first_button_text`
18 /// ext to go in first button
19 ///
20 /// # Returns
21 ///
22 /// a new [`InfoBar`][crate::InfoBar]
23 #[doc(alias = "gtk_info_bar_new_with_buttons")]
24 #[doc(alias = "new_with_buttons")]
25 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
26 #[allow(deprecated)]
27 pub fn with_buttons(buttons: &[(&str, ResponseType)]) -> Self {
28 assert_initialized_main_thread!();
29 let info_bar = InfoBar::new();
30 info_bar.add_buttons(buttons);
31 info_bar
32 }
33
34 /// Adds multiple buttons.
35 ///
36 /// This is the same as calling [`add_button()`][Self::add_button()]
37 /// repeatedly. The variable argument list should be [`None`]-terminated
38 /// as with [`with_buttons()`][Self::with_buttons()]. Each button must have both
39 /// text and response ID.
40 ///
41 /// # Deprecated since 4.10
42 ///
43 /// ## `first_button_text`
44 /// button text
45 #[doc(alias = "gtk_info_bar_add_buttons")]
46 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
47 #[allow(deprecated)]
48 pub fn add_buttons(&self, buttons: &[(&str, ResponseType)]) {
49 for &(text, id) in buttons {
50 self.add_button(text, id);
51 }
52 }
53}