mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Move push macro to seperate module
This commit is contained in:
parent
06d181447c
commit
59171e705b
4 changed files with 28 additions and 25 deletions
24
src/macros.rs
Normal file
24
src/macros.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/// Simplification for pushing new screens.
|
||||
///
|
||||
/// This macro can be invoked in two forms.
|
||||
///
|
||||
/// 1. To push screens without an input value:
|
||||
///
|
||||
/// ```
|
||||
/// let result = push!(handle, ScreenType).await;
|
||||
/// ```
|
||||
///
|
||||
/// 2. To push screens with an input value:
|
||||
///
|
||||
/// ```
|
||||
/// let result = push!(handle, ScreenType, input).await;
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! push {
|
||||
($handle:expr, $screen:ty) => {
|
||||
$handle.push::<_, _, $screen>(())
|
||||
};
|
||||
($handle:expr, $screen:ty, $input:ident) => {
|
||||
$handle.push::<_, _, $screen>($input)
|
||||
};
|
||||
}
|
||||
|
|
@ -11,6 +11,9 @@ use glib::clone;
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
mod backend;
|
||||
mod config;
|
||||
mod database;
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ sources = files(
|
|||
'widgets/section.rs',
|
||||
'config.rs',
|
||||
'config.rs.in',
|
||||
'macros.rs',
|
||||
'main.rs',
|
||||
'player.rs',
|
||||
'resources.rs',
|
||||
|
|
|
|||
|
|
@ -6,31 +6,6 @@ use gtk::prelude::*;
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::{Rc, Weak};
|
||||
|
||||
/// Simplification for pushing new screens.
|
||||
///
|
||||
/// This macro can be invoked in two forms.
|
||||
///
|
||||
/// 1. To push screens without an input value:
|
||||
///
|
||||
/// ```
|
||||
/// let result = push!(handle, ScreenType).await;
|
||||
/// ```
|
||||
///
|
||||
/// 2. To push screens with an input value:
|
||||
///
|
||||
/// ```
|
||||
/// let result = push!(handle, ScreenType, input).await;
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! push {
|
||||
($handle:expr, $screen:ty) => {
|
||||
$handle.push::<_, _, $screen>(())
|
||||
};
|
||||
($handle:expr, $screen:ty, $input:ident) => {
|
||||
$handle.push::<_, _, $screen>($input)
|
||||
};
|
||||
}
|
||||
|
||||
/// A widget that represents a logical unit of transient user interaction and
|
||||
/// that optionally resolves to a specific return value.
|
||||
pub trait Screen<I, O>: Widget {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue