Add GTK app shell with wizard navigation, step indicator, and actions

This commit is contained in:
2026-03-06 11:03:11 +02:00
parent 0bc39542ee
commit 9fe680dad5
4 changed files with 501 additions and 33 deletions

View File

@@ -0,0 +1,88 @@
pub struct WizardState {
pub current_step: usize,
pub total_steps: usize,
pub visited: Vec<bool>,
names: Vec<String>,
}
impl WizardState {
pub fn new() -> Self {
let names = vec![
"Workflow".into(),
"Images".into(),
"Resize".into(),
"Convert".into(),
"Compress".into(),
"Metadata".into(),
"Output".into(),
];
let total = names.len();
let mut visited = vec![false; total];
visited[0] = true;
Self {
current_step: 0,
total_steps: total,
visited,
names,
}
}
pub fn step_names(&self) -> Vec<String> {
self.names.clone()
}
pub fn can_go_next(&self) -> bool {
self.current_step < self.total_steps - 1
}
pub fn can_go_back(&self) -> bool {
self.current_step > 0
}
pub fn is_last_step(&self) -> bool {
self.current_step == self.total_steps - 1
}
pub fn go_next(&mut self) {
if self.can_go_next() {
self.current_step += 1;
self.visited[self.current_step] = true;
}
}
pub fn go_back(&mut self) {
if self.can_go_back() {
self.current_step -= 1;
}
}
}
pub fn build_wizard_pages() -> Vec<adw::NavigationPage> {
let steps = [
("step-workflow", "Choose a Workflow", "image-x-generic-symbolic", "Select a preset or build a custom workflow"),
("step-images", "Add Images", "folder-pictures-symbolic", "Drop images here or click Browse"),
("step-resize", "Resize", "view-fullscreen-symbolic", "Set output dimensions"),
("step-convert", "Convert", "document-save-symbolic", "Choose output format"),
("step-compress", "Compress", "system-file-manager-symbolic", "Set compression quality"),
("step-metadata", "Metadata", "security-high-symbolic", "Control metadata privacy"),
("step-output", "Output & Process", "emblem-ok-symbolic", "Review and process"),
];
steps
.iter()
.map(|(tag, title, icon, description)| {
let status_page = adw::StatusPage::builder()
.title(*title)
.description(*description)
.icon_name(*icon)
.build();
adw::NavigationPage::builder()
.title(*title)
.tag(*tag)
.child(&status_page)
.build()
})
.collect()
}