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
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::{PadActionEntry, PadController};
use glib::translate::*;

impl PadController {
    /// A convenience function to add a group of action entries on
    /// @self.
    ///
    /// See [`PadActionEntry`][crate::PadActionEntry] and [`set_action()`][Self::set_action()].
    /// ## `entries`
    /// the action entries to set on @self
    #[doc(alias = "gtk_pad_controller_set_action_entries")]
    pub fn set_action_entries(&self, entries: &[PadActionEntry]) {
        let n_entries = entries.len() as i32;
        let entry_strings = entries
            .iter()
            .map(|e| (e.label().to_glib_none(), e.action_name().to_glib_none()))
            .collect::<Vec<_>>();
        let entries = entries
            .iter()
            .zip(entry_strings.iter())
            .map(|(e, (label, action_name))| ffi::GtkPadActionEntry {
                type_: e.type_().into_glib(),
                index: e.index(),
                mode: e.mode(),
                label: label.0,
                action_name: action_name.0,
            })
            .collect::<Vec<_>>();
        unsafe {
            ffi::gtk_pad_controller_set_action_entries(
                self.to_glib_none().0,
                entries.as_ptr(),
                n_entries,
            );
        }
    }
}