81 lines
3.3 KiB
Rust
81 lines
3.3 KiB
Rust
use gtk4::prelude::*;
|
|
use gtk4::{Application, ApplicationWindow, Orientation, Paned, Stack};
|
|
|
|
use super::sidebar;
|
|
use super::views;
|
|
|
|
// About is a settings app's most GNOME-Settings-like landing page —
|
|
// identifies the machine, no config editor thrown at you first. Defined
|
|
// once here and threaded through to both the `Stack` and the sidebar's
|
|
// initial selection, so the two can't independently drift out of sync.
|
|
const DEFAULT_PAGE: &str = "about";
|
|
|
|
/// `requested_page` comes from `--page <id>` (e.g. breadhelp's "Learn more"
|
|
/// deep links) and overrides `DEFAULT_PAGE` when it names a real page.
|
|
pub fn build_ui(app: &Application, requested_page: Option<String>) {
|
|
let window = ApplicationWindow::builder()
|
|
.application(app)
|
|
.title("BOS Settings")
|
|
.default_width(960)
|
|
.default_height(640)
|
|
.build();
|
|
|
|
crate::theme::load(&WidgetExt::display(&window));
|
|
|
|
let hpaned = Paned::new(Orientation::Horizontal);
|
|
hpaned.set_position(210);
|
|
hpaned.set_shrink_start_child(false);
|
|
hpaned.set_resize_start_child(false);
|
|
|
|
let initial_page = requested_page.as_deref().unwrap_or(DEFAULT_PAGE);
|
|
let (sidebar_box, list) = sidebar::build(initial_page);
|
|
|
|
let stack = Stack::new();
|
|
stack.set_hexpand(true);
|
|
stack.set_vexpand(true);
|
|
|
|
stack.add_named(&views::about::build(), Some("about"));
|
|
stack.add_named(&views::network::build(), Some("network"));
|
|
stack.add_named(&views::bluetooth::build(), Some("bluetooth"));
|
|
stack.add_named(&views::sound::build(), Some("sound"));
|
|
stack.add_named(&views::datetime::build(), Some("datetime"));
|
|
stack.add_named(&views::power::build(), Some("power"));
|
|
stack.add_named(&views::firewall::build(), Some("firewall"));
|
|
stack.add_named(&views::users::build(), Some("users"));
|
|
stack.add_named(&views::snapshots::build(), Some("snapshots"));
|
|
stack.add_named(&views::packages::build(), Some("packages"));
|
|
stack.add_named(&views::firmware::build(), Some("firmware"));
|
|
stack.add_named(&views::aur::build(), Some("aur"));
|
|
stack.add_named(&views::bread::build(), Some("bread"));
|
|
stack.add_named(&views::breadbar::build(), Some("breadbar"));
|
|
stack.add_named(&views::breadbox::build(), Some("breadbox"));
|
|
stack.add_named(&views::breadclip::build(), Some("breadclip"));
|
|
stack.add_named(&views::breadcrumbs::build(), Some("breadcrumbs"));
|
|
stack.add_named(&views::breadpad::build(), Some("breadpad"));
|
|
stack.add_named(&views::breadpaper::build(), Some("breadpaper"));
|
|
stack.add_named(&views::breadsearch::build(), Some("breadsearch"));
|
|
stack.add_named(&views::hyprland::build(), Some("hyprland"));
|
|
stack.add_named(&views::keybinds::build(), Some("keybinds"));
|
|
stack.add_named(&views::appearance::build(), Some("appearance"));
|
|
stack.add_named(&views::autostart::build(), Some("autostart"));
|
|
|
|
stack.set_visible_child_name(initial_page);
|
|
|
|
{
|
|
let stack = stack.clone();
|
|
list.connect_row_selected(move |_, row| {
|
|
if let Some(row) = row {
|
|
let name = row.widget_name();
|
|
if !name.is_empty() {
|
|
stack.set_visible_child_name(&name);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
hpaned.set_start_child(Some(&sidebar_box));
|
|
hpaned.set_end_child(Some(&stack));
|
|
|
|
window.set_child(Some(&hpaned));
|
|
window.present();
|
|
}
|