mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-04-05 04:39:02 +00:00
linux-rust: add --start-minimized
This commit is contained in:
@@ -25,6 +25,8 @@ struct Args {
|
|||||||
debug: bool,
|
debug: bool,
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
no_tray: bool,
|
no_tray: bool,
|
||||||
|
#[arg(long)]
|
||||||
|
start_minimized: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> iced::Result {
|
fn main() -> iced::Result {
|
||||||
@@ -41,7 +43,7 @@ fn main() -> iced::Result {
|
|||||||
rt.block_on(async_main(ui_tx)).unwrap();
|
rt.block_on(async_main(ui_tx)).unwrap();
|
||||||
});
|
});
|
||||||
|
|
||||||
ui::window::start_ui(ui_rx)
|
ui::window::start_ui(ui_rx, args.start_minimized)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ use std::sync::Arc;
|
|||||||
use log::debug;
|
use log::debug;
|
||||||
use tokio::sync::{mpsc::UnboundedReceiver, Mutex};
|
use tokio::sync::{mpsc::UnboundedReceiver, Mutex};
|
||||||
|
|
||||||
pub fn start_ui(ui_rx: UnboundedReceiver<()>) -> iced::Result {
|
pub fn start_ui(ui_rx: UnboundedReceiver<()>, start_minimized: bool) -> iced::Result {
|
||||||
daemon(App::title, App::update, App::view)
|
daemon(App::title, App::update, App::view)
|
||||||
.subscription(App::subscription)
|
.subscription(App::subscription)
|
||||||
.theme(App::theme)
|
.theme(App::theme)
|
||||||
.run_with(|| App::new(ui_rx))
|
.run_with(move || App::new(ui_rx, start_minimized))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct App {
|
pub struct App {
|
||||||
@@ -44,26 +44,32 @@ pub enum Pane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new(ui_rx: UnboundedReceiver<()>) -> (Self, Task<Message>) {
|
pub fn new(ui_rx: UnboundedReceiver<()>, start_minimized: bool) -> (Self, Task<Message>) {
|
||||||
let (mut panes, first_pane) = pane_grid::State::new(Pane::Sidebar);
|
let (mut panes, first_pane) = pane_grid::State::new(Pane::Sidebar);
|
||||||
let split = panes.split(pane_grid::Axis::Vertical, first_pane, Pane::Content);
|
let split = panes.split(pane_grid::Axis::Vertical, first_pane, Pane::Content);
|
||||||
panes.resize(split.unwrap().1, 0.2);
|
panes.resize(split.unwrap().1, 0.2);
|
||||||
|
|
||||||
let (_, open) = window::open(window::Settings::default());
|
|
||||||
|
|
||||||
let ui_rx = Arc::new(Mutex::new(ui_rx));
|
let ui_rx = Arc::new(Mutex::new(ui_rx));
|
||||||
let wait_task = Task::perform(
|
let wait_task = Task::perform(
|
||||||
wait_for_message(Arc::clone(&ui_rx)),
|
wait_for_message(Arc::clone(&ui_rx)),
|
||||||
|_| Message::OpenMainWindow,
|
|_| Message::OpenMainWindow,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let (window, open_task) = if start_minimized {
|
||||||
|
(None, Task::none())
|
||||||
|
} else {
|
||||||
|
let (id, open) = window::open(window::Settings::default());
|
||||||
|
(Some(id), open.map(Message::WindowOpened))
|
||||||
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
Self {
|
Self {
|
||||||
window: None,
|
window,
|
||||||
panes,
|
panes,
|
||||||
selected_tab: Tab::Device1,
|
selected_tab: Tab::Device1,
|
||||||
ui_rx,
|
ui_rx,
|
||||||
},
|
},
|
||||||
Task::batch(vec![open.map(Message::WindowOpened), wait_task]),
|
Task::batch(vec![open_task, wait_task]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user