Skip to content

Commit

Permalink
feat: containers, nix, appman, flatseal and redshift (#68)
Browse files Browse the repository at this point in the history
* feat: containers, nix, zap and redshift
plus some small fixes and QoL improvements

* chore: update versions

* chore: cargo fmt

* chore: cargo clippy

* fix: cargo clippy again
I hate clippy pedantic

* fix: cargo fmt once more
Did I mention I hate clippy pedantic?

* chan: replace zap with appman

* fix: arch and apt/pacstall container packages

* fix: `-Q` flag

* feat: add flatseal
also fmt, clippy and devel profile fixes

* ref: no need to git clone

* fix: cargo fmt, yet again

* upd: relm4 v0.9

* fix: `time` on rust 1.80 regression

* fix: docker as user, remove docker-desktop

* fix: shell commands

* fix: `tabs` command issue on `pacstall -U`

* fix: cleanups

---------

Co-authored-by: oklopfer <[email protected]>
  • Loading branch information
D-Brox and oklopfer authored Aug 14, 2024
1 parent 6eedaad commit e16f48d
Show file tree
Hide file tree
Showing 11 changed files with 920 additions and 350 deletions.
593 changes: 339 additions & 254 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rhino-setup"
version = "0.1.0"
version = "0.2.0"
edition = "2021"

[profile.release]
Expand All @@ -10,8 +10,9 @@ lto = true

[dependencies]
gettext-rs = { version = "0.7.0", features = ["gettext-system"] }
relm4 = { version = "0.5.1", features = ["libadwaita"] }
relm4-components = "0.5.1"
relm4 = { version = "0.9.0", features = ["libadwaita"] }
relm4-components = "0.9.1"
tracing = "0.1.37"
tracing-appender = "0.2.2"
tracing-subscriber = "0.3.17"
time = "=0.3.36"
94 changes: 51 additions & 43 deletions src/carousel.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
use relm4::adw::prelude::*;
use relm4::{adw, Component, ComponentController, ComponentParts, Controller, SimpleComponent};

use crate::containers::{ContainersModel, ContainersOutput};
use crate::done::DoneModel;
use crate::extra_settings::{ExtraSettingsModel, ExtraSettingsOutput};
use crate::package_manager::{PackageManagerModel, PackageManagerOutput};
use crate::progress::{ProgressInput, ProgressModel, ProgressOutput};
use crate::theme::{ThemeModel, ThemeOutput};
use crate::welcome::{WelcomeModel, WelcomeOutput};

pub(crate) struct CarouselModel {
current_page: u32,
pub(crate) struct CarouselPagesModel {
current: u32,

welcome_page: Controller<WelcomeModel>,
theme_page: Controller<ThemeModel>,
package_manager_page: Controller<PackageManagerModel>,
extra_settings_page: Controller<ExtraSettingsModel>,
progress_page: Controller<ProgressModel>,
done_page: Controller<DoneModel>,
welcome: Controller<WelcomeModel>,
theme: Controller<ThemeModel>,
package_manager: Controller<PackageManagerModel>,
containers: Controller<ContainersModel>,
extra_settings: Controller<ExtraSettingsModel>,
progress: Controller<ProgressModel>,
done: Controller<DoneModel>,
}

#[derive(Debug)]
Expand All @@ -27,7 +29,7 @@ pub(crate) enum CarouselInput {
/// Move to the previous page.
PreviousPage,
/// An error has occurred in one of the pages.
/// Move to the [crate::done] page, with the error state.
/// Move to the [`crate::done`] page, with the error state.
SkipToErrorPage,
}

Expand All @@ -40,7 +42,7 @@ pub(crate) enum CarouselOutput {
}

#[relm4::component(pub)]
impl SimpleComponent for CarouselModel {
impl SimpleComponent for CarouselPagesModel {
type Init = ();
type Input = CarouselInput;
type Output = CarouselOutput;
Expand All @@ -55,54 +57,60 @@ impl SimpleComponent for CarouselModel {
set_allow_mouse_drag: false,
set_allow_long_swipes: false,

append: model.welcome_page.widget(),
append: model.theme_page.widget(),
append: model.package_manager_page.widget(),
append: model.extra_settings_page.widget(),
append: model.progress_page.widget(),
append: model.done_page.widget(),
append: model.welcome.widget(),
append: model.theme.widget(),
append: model.package_manager.widget(),
append: model.containers.widget(),
append: model.extra_settings.widget(),
append: model.progress.widget(),
append: model.done.widget(),
}
}

fn init(
_init: Self::Init,
root: &Self::Root,
root: Self::Root,
sender: relm4::ComponentSender<Self>,
) -> relm4::ComponentParts<Self> {
let model = CarouselModel {
current_page: 0,
welcome_page: WelcomeModel::builder().launch(()).forward(
sender.input_sender(),
|msg| match msg {
WelcomeOutput::NextPage => CarouselInput::NextPage,
},
),
theme_page: ThemeModel::builder()
let model = CarouselPagesModel {
current: 0,
welcome: WelcomeModel::builder()
.launch(())
.forward(sender.input_sender(), |msg| match msg {
WelcomeOutput::NextPage => CarouselInput::NextPage,
}),
theme: ThemeModel::builder().launch(()).forward(
sender.input_sender(),
|msg| match msg {
ThemeOutput::NextPage => CarouselInput::NextPage,
ThemeOutput::ErrorOccured => CarouselInput::SkipToErrorPage,
}),
package_manager_page: PackageManagerModel::builder().launch(()).forward(
},
),
package_manager: PackageManagerModel::builder().launch(()).forward(
sender.input_sender(),
|msg| match msg {
PackageManagerOutput::NextPage => CarouselInput::NextPage,
},
),
extra_settings_page: ExtraSettingsModel::builder().launch(()).forward(
containers: ContainersModel::builder().launch(()).forward(
sender.input_sender(),
|msg| match msg {
ExtraSettingsOutput::NextPage => CarouselInput::NextPage,
ContainersOutput::NextPage => CarouselInput::NextPage,
},
),
progress_page: ProgressModel::builder().launch(()).forward(
extra_settings: ExtraSettingsModel::builder().launch(()).forward(
sender.input_sender(),
|msg| match msg {
ProgressOutput::InstallationComplete => CarouselInput::NextPage,
ProgressOutput::InstallationError => CarouselInput::SkipToErrorPage,
ExtraSettingsOutput::NextPage => CarouselInput::NextPage,
},
),
done_page: DoneModel::builder().launch(()).detach(),
progress: ProgressModel::builder()
.launch(())
.forward(sender.input_sender(), |msg| match msg {
ProgressOutput::InstallationComplete => CarouselInput::NextPage,
ProgressOutput::InstallationError => CarouselInput::SkipToErrorPage,
}),
done: DoneModel::builder().launch(()).detach(),
};

let widgets = view_output!();
Expand All @@ -113,36 +121,36 @@ impl SimpleComponent for CarouselModel {
fn update(&mut self, message: Self::Input, sender: relm4::ComponentSender<Self>) {
match message {
CarouselInput::NextPage => {
self.current_page += 1;
self.current += 1;

// If the user hasn't reached the progress page yet.
if self.current_page < 4 {
if self.current < 5 {
sender.output(CarouselOutput::ShowBackButton).unwrap();
}

// When the user is at the progress page.
if self.current_page == 4 {
if self.current == 5 {
// Hide the back button, as the user is not supposed to return to previous pages
// after this point.
sender.output(CarouselOutput::HideBackButton).unwrap();

self.progress_page
self.progress
.sender()
.send(ProgressInput::StartInstallation)
.unwrap();
}
},
CarouselInput::PreviousPage => {
self.current_page -= 1;
self.current -= 1;

// When on the first page (pages starts from 0), disable the back button.
if self.current_page == 0 {
if self.current == 0 {
sender.output(CarouselOutput::HideBackButton).unwrap();
}
},
CarouselInput::SkipToErrorPage => {
self.current_page = 5;
self.done_page
self.current = 6;
self.done
.sender()
.send(crate::done::DoneInput::SwitchToErrorState)
.unwrap();
Expand All @@ -151,5 +159,5 @@ impl SimpleComponent for CarouselModel {
}
}

fn post_view() { carousel.scroll_to(&carousel.nth_page(model.current_page), true); }
fn post_view() { carousel.scroll_to(&carousel.nth_page(model.current), true); }
}
Loading

0 comments on commit e16f48d

Please sign in to comment.