1
0
forked from vitrine/wmaker

Reimplment the WMCreateCommandButton macro in Rust.

This is a macro in C, and it would be helpful to be able to do the same thing in Rust. It is simply ported over as a Rust function.
This commit is contained in:
2025-12-15 13:52:37 -05:00
parent 52fc9eec43
commit 39efd22bed
3 changed files with 23 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ AUTOMAKE_OPTIONS =
RUST_SOURCES = \
src/WINGsP.rs \
src/button.rs \
src/configuration.rs \
src/font.rs \
src/lib.rs \

View File

@@ -0,0 +1,21 @@
pub mod ffi {
use crate::WINGsP::*;
/// Creates a button like an "Ok" button to dismiss a dialog.
///
/// ## Rust rewrite notes
///
/// This was originally a macro.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn WMCreateCommandButton(parent: *mut WMWidget) -> *mut WMButton {
unsafe {
WMCreateCustomButton(
parent,
(WMButtonBehaviorMask_WBBSpringLoadedMask
| WMButtonBehaviorMask_WBBPushInMask
| WMButtonBehaviorMask_WBBPushLightMask
| WMButtonBehaviorMask_WBBPushChangeMask) as i32,
)
}
}
}

View File

@@ -3,6 +3,7 @@
#[allow(non_snake_case)]
#[allow(non_upper_case_globals)]
pub mod WINGsP;
pub mod button;
pub mod configuration;
pub mod font;
pub(crate) mod pango_extras;