Expose system module through feature flag

This commit is contained in:
Héctor Ramón Jiménez 2022-04-30 13:37:57 +02:00
parent 5eefa5d4ea
commit 93bfe2c75e
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
8 changed files with 30 additions and 14 deletions

View file

@ -12,12 +12,12 @@ categories = ["gui"]
[features]
debug = ["iced_native/debug"]
system = ["sysinfo"]
[dependencies]
window_clipboard = "0.2"
log = "0.4"
thiserror = "1.0"
sysinfo = "0.23"
[dependencies.winit]
version = "0.26"
@ -42,3 +42,7 @@ version = "0.3.6"
[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
version = "0.3"
features = ["Document", "Window"]
[dependencies.sysinfo]
version = "0.23"
optional = true

View file

@ -542,7 +542,7 @@ pub fn run_command<Message: 'static + std::fmt::Debug + Send, E: Executor>(
clipboard: &mut Clipboard,
proxy: &mut winit::event_loop::EventLoopProxy<Message>,
window: &winit::window::Window,
graphics_info: impl FnOnce() -> compositor::Information + Copy,
_graphics_info: impl FnOnce() -> compositor::Information + Copy,
) {
use iced_native::command;
use iced_native::system;
@ -580,15 +580,18 @@ pub fn run_command<Message: 'static + std::fmt::Debug + Send, E: Executor>(
}
},
command::Action::System(action) => match action {
system::Action::QueryInformation(tag) => {
let information =
crate::system::information(graphics_info());
system::Action::QueryInformation(_tag) => {
#[cfg(feature = "sysinfo")]
{
let information =
crate::system::information(_graphics_info());
let message = tag(information);
let message = _tag(information);
proxy
.send_event(message)
.expect("Send message to event loop");
proxy
.send_event(message)
.expect("Send message to event loop");
}
}
},
}

View file

@ -31,9 +31,11 @@ pub mod application;
pub mod clipboard;
pub mod conversion;
pub mod settings;
pub mod system;
pub mod window;
#[cfg(feature = "system")]
pub mod system;
mod error;
mod mode;
mod position;