Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit d84be1a

Browse files
Merge pull request #828 from GuillaumeGomez/add-missing-import
Fix compilation
2 parents aed7c94 + 14b6761 commit d84be1a

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

src/pad_action_entry.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
// See the COPYRIGHT file at the top-level directory of this distribution.
33
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
44

5-
use glib::translate::*;
6-
use gtk_sys;
7-
use std::ffi::CStr;
85
use PadActionType;
96

107
#[derive(Debug, Clone)]
118
pub struct PadActionEntry {
12-
pub(crate) type_: PadActionType,
13-
pub(crate) index: i32,
14-
pub(crate) mode: i32,
15-
pub(crate) label: String,
16-
pub(crate) action_name: String,
9+
type_: PadActionType,
10+
index: i32,
11+
mode: i32,
12+
label: String,
13+
action_name: String,
1714
}
1815

1916
impl PadActionEntry {
@@ -46,11 +43,11 @@ impl PadActionEntry {
4643
self.mode
4744
}
4845

49-
pub fn get_label(&self) -> Option<&str> {
50-
Some(&self.label)
46+
pub fn get_label(&self) -> &str {
47+
&self.label
5148
}
5249

53-
pub fn get_action_name(&self) -> Option<&str> {
54-
Some(&self.action_name)
50+
pub fn get_action_name(&self) -> &str {
51+
&self.action_name
5552
}
5653
}

src/pad_controller.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,25 @@ use PadActionEntry;
99
use PadController;
1010

1111
pub trait PadControllerExtManual: 'static {
12-
#[cfg(any(feature = "v3_22", feature = "dox"))]
1312
fn set_action_entries(&self, entries: &[PadActionEntry]);
1413
}
1514

1615
impl<O: IsA<PadController>> PadControllerExtManual for O {
17-
#[cfg(any(feature = "v3_22", feature = "dox"))]
1816
fn set_action_entries(&self, entries: &[PadActionEntry]) {
1917
let n_entries = entries.len() as i32;
2018
let entry_strings = entries
2119
.iter()
22-
.map(|e| (CString::new(&e.label), CString::new(&e.action_name)))
23-
.collect::<Vec<_>>();
20+
.map(|e| (e.get_label().to_glib_none(), e.get_action_name().to_glib_none()))
21+
.collect::<Vec<(Stash<_, _>, Stash<_, _>)>>();
2422
let entries = entries
2523
.iter()
2624
.zip(entry_strings.iter())
2725
.map(|(e, (label, action_name))| gtk_sys::GtkPadActionEntry {
28-
type_: e.type_.to_glib(),
29-
index: e.index,
30-
mode: e.mode,
31-
label: label.as_ptr() as *mut _,
32-
action_name: action_name.as_ptr() as *mut _,
26+
type_: e.get_type().to_glib(),
27+
index: e.get_index(),
28+
mode: e.get_mode(),
29+
label: label.0,
30+
action_name: action_name.0,
3331
})
3432
.collect::<Vec<_>>();
3533
unsafe {

0 commit comments

Comments
 (0)