chore: start work on callback refactor
This commit is contained in:
parent
8032e5014c
commit
6977e836bc
2 changed files with 5 additions and 4 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -635,11 +635,10 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "wmenu"
|
||||
name = "wmenu-rs"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"gag",
|
||||
"pangocairo-sys",
|
||||
"wmenu-sys",
|
||||
]
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ use std::{
|
|||
|
||||
use wmenu_sys::bindings;
|
||||
|
||||
type Callback = fn(menu: &mut Menu, text: &str) -> bool;
|
||||
|
||||
unsafe extern "C" fn print_item(menu: *mut bindings::menu, text: *mut i8, exit: bool) {
|
||||
wmenu_sys::bindings::puts(text);
|
||||
wmenu_sys::bindings::fflush(bindings::stdout);
|
||||
|
@ -45,9 +47,9 @@ pub struct Menu {
|
|||
}
|
||||
|
||||
impl Menu {
|
||||
pub fn new() -> Menu {
|
||||
pub fn new(callback: Callback) -> Menu {
|
||||
Self {
|
||||
ctx: unsafe { bindings::menu_create(Some(print_item)) },
|
||||
ctx: unsafe { bindings::menu_create(Some(callback)) },
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue