1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::{InfoBar, ResponseType};

impl InfoBar {
    /// Creates a new [`InfoBar`][crate::InfoBar] with buttons.
    ///
    /// Button text/response ID pairs should be listed, with a [`None`] pointer
    /// ending the list. A response ID can be any positive number,
    /// or one of the values in the [`ResponseType`][crate::ResponseType] enumeration. If the
    /// user clicks one of these dialog buttons, GtkInfoBar will emit
    /// the `signal::InfoBar::response` signal with the corresponding
    /// response ID.
    /// ## `first_button_text`
    /// ext to go in first button
    ///
    /// # Returns
    ///
    /// a new [`InfoBar`][crate::InfoBar]
    #[doc(alias = "gtk_info_bar_new_with_buttons")]
    #[doc(alias = "new_with_buttons")]
    pub fn with_buttons(buttons: &[(&str, ResponseType)]) -> Self {
        assert_initialized_main_thread!();
        let info_bar = InfoBar::new();
        info_bar.add_buttons(buttons);
        info_bar
    }

    /// Adds multiple buttons.
    ///
    /// This is the same as calling [`add_button()`][Self::add_button()]
    /// repeatedly. The variable argument list should be [`None`]-terminated
    /// as with [`with_buttons()`][Self::with_buttons()]. Each button must have both
    /// text and response ID.
    /// ## `first_button_text`
    /// button text
    #[doc(alias = "gtk_info_bar_add_buttons")]
    pub fn add_buttons(&self, buttons: &[(&str, ResponseType)]) {
        for &(text, id) in buttons {
            self.add_button(text, id);
        }
    }
}