diff --git a/src/build_ui.rs b/src/build_ui.rs index d5a750c..cf2eb20 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -6,7 +6,7 @@ use adw::*; // application crates /// first setup crates -use crate::first_setup::first_setup::first_setup; +use crate::first_setup::*; pub fn build_ui(app: &adw::Application) { // setup glib diff --git a/src/first_setup/codec_carousel.rs b/src/first_setup/codec_carousel/mod.rs similarity index 100% rename from src/first_setup/codec_carousel.rs rename to src/first_setup/codec_carousel/mod.rs diff --git a/src/first_setup/driver_carousel.rs b/src/first_setup/driver_carousel/mod.rs similarity index 100% rename from src/first_setup/driver_carousel.rs rename to src/first_setup/driver_carousel/mod.rs diff --git a/src/first_setup/final_carousel.rs b/src/first_setup/final_carousel/mod.rs similarity index 100% rename from src/first_setup/final_carousel.rs rename to src/first_setup/final_carousel/mod.rs diff --git a/src/first_setup/first_setup.rs b/src/first_setup/first_setup.rs deleted file mode 100644 index 0e31ccc..0000000 --- a/src/first_setup/first_setup.rs +++ /dev/null @@ -1,74 +0,0 @@ -// GTK crates -use adw::prelude::*; -use adw::*; -use glib::*; -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) - -use gettextrs::gettext; - -// -use std::cell::RefCell; -use std::rc::Rc; - -// carousel crates -use crate::first_setup::initial_carousel::initial_carousel; -use crate::first_setup::internet_carousel::internet_carousel; -use crate::first_setup::update_carousel::update_carousel; -use crate::first_setup::user_carousel::user_carousel; -use crate::first_setup::driver_carousel::driver_carousel; -use crate::first_setup::codec_carousel::codec_carousel; -use crate::first_setup::gameutils_carousel::gameutils_carousel; -use crate::first_setup::final_carousel::final_carousel; - -pub fn first_setup(window: &adw::ApplicationWindow) { - let first_setup_carousel = adw::Carousel::builder() - .allow_long_swipes(false) - .allow_mouse_drag(false) - .allow_scroll_wheel(false) - .interactive(false) - .vexpand(true) - .hexpand(true) - .build(); - - let first_setup_carousel_indicator = adw::CarouselIndicatorDots::builder() - .carousel(&first_setup_carousel) - .build(); - - let first_setup_window_headerbar_back_button = gtk::Button::builder().label(gettext("first_setup_window_headerbar_back_button_label")).build(); - - let first_setup_window_headerbar = adw::HeaderBar::builder() - .show_start_title_buttons(true) - .title_widget(&first_setup_carousel_indicator) - .build(); - - let first_setup_window_toolbarview = adw::ToolbarView::builder() - .top_bar_style(ToolbarStyle::Flat) - .content(&first_setup_carousel) - .build(); - - let internet_connected = Rc::new(RefCell::new(false)); - - first_setup_window_headerbar.pack_start(&first_setup_window_headerbar_back_button); - first_setup_window_toolbarview.add_top_bar(&first_setup_window_headerbar); - - first_setup_window_headerbar_back_button.connect_clicked(clone!(@weak first_setup_carousel => move |_| { - let first_setup_prev_page = first_setup_carousel.position() - 1.0; - first_setup_carousel.scroll_to(&first_setup_carousel.nth_page(first_setup_prev_page as u32), true) - })); - - // CAROUSELS - - // Initial Carousel - initial_carousel(&first_setup_carousel); - internet_carousel(&first_setup_carousel, &internet_connected, &window); - user_carousel(&first_setup_carousel); - update_carousel(&first_setup_carousel, &internet_connected, &window); - driver_carousel(&first_setup_carousel, &internet_connected); - codec_carousel(&first_setup_carousel, &internet_connected, &window); - gameutils_carousel(&first_setup_carousel, &internet_connected, &window); - final_carousel(&first_setup_carousel); - - // Add file to window - window.set_content(Some(&first_setup_window_toolbarview)) -} diff --git a/src/first_setup/gameutils_carousel.rs b/src/first_setup/gameutils_carousel/mod.rs similarity index 100% rename from src/first_setup/gameutils_carousel.rs rename to src/first_setup/gameutils_carousel/mod.rs diff --git a/src/first_setup/initial_carousel.rs b/src/first_setup/initial_carousel/mod.rs similarity index 100% rename from src/first_setup/initial_carousel.rs rename to src/first_setup/initial_carousel/mod.rs diff --git a/src/first_setup/internet_carousel.rs b/src/first_setup/internet_carousel/mod.rs similarity index 100% rename from src/first_setup/internet_carousel.rs rename to src/first_setup/internet_carousel/mod.rs diff --git a/src/first_setup/mod.rs b/src/first_setup/mod.rs index f03c7ba..35d7591 100644 --- a/src/first_setup/mod.rs +++ b/src/first_setup/mod.rs @@ -1,9 +1,83 @@ -pub mod first_setup; -pub mod initial_carousel; -pub mod internet_carousel; -pub mod update_carousel; -pub mod user_carousel; -pub mod driver_carousel; -pub mod codec_carousel; -pub mod gameutils_carousel; -pub mod final_carousel; +// GTK crates +use adw::prelude::*; +use adw::*; +use glib::*; +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) + +use gettextrs::gettext; + +// +use std::cell::RefCell; +use std::rc::Rc; + +// carousel crates +mod initial_carousel; +mod internet_carousel; +mod user_carousel; +mod update_carousel; +mod driver_carousel; +mod codec_carousel; +mod gameutils_carousel; +mod final_carousel; + +use initial_carousel::*; +use internet_carousel::*; +use user_carousel::*; +use update_carousel::*; +use driver_carousel::*; +use codec_carousel::*; +use gameutils_carousel::*; +use final_carousel::*; + +pub fn first_setup(window: &adw::ApplicationWindow) { + let first_setup_carousel = adw::Carousel::builder() + .allow_long_swipes(false) + .allow_mouse_drag(false) + .allow_scroll_wheel(false) + .interactive(false) + .vexpand(true) + .hexpand(true) + .build(); + + let first_setup_carousel_indicator = adw::CarouselIndicatorDots::builder() + .carousel(&first_setup_carousel) + .build(); + + let first_setup_window_headerbar_back_button = gtk::Button::builder().label(gettext("first_setup_window_headerbar_back_button_label")).build(); + + let first_setup_window_headerbar = adw::HeaderBar::builder() + .show_start_title_buttons(true) + .title_widget(&first_setup_carousel_indicator) + .build(); + + let first_setup_window_toolbarview = adw::ToolbarView::builder() + .top_bar_style(ToolbarStyle::Flat) + .content(&first_setup_carousel) + .build(); + + let internet_connected = Rc::new(RefCell::new(false)); + + first_setup_window_headerbar.pack_start(&first_setup_window_headerbar_back_button); + first_setup_window_toolbarview.add_top_bar(&first_setup_window_headerbar); + + first_setup_window_headerbar_back_button.connect_clicked(clone!(@weak first_setup_carousel => move |_| { + let first_setup_prev_page = first_setup_carousel.position() - 1.0; + first_setup_carousel.scroll_to(&first_setup_carousel.nth_page(first_setup_prev_page as u32), true) + })); + + // CAROUSELS + + // Initial Carousel + initial_carousel(&first_setup_carousel); + internet_carousel(&first_setup_carousel, &internet_connected, &window); + user_carousel(&first_setup_carousel); + update_carousel(&first_setup_carousel, &internet_connected, &window); + driver_carousel(&first_setup_carousel, &internet_connected); + codec_carousel(&first_setup_carousel, &internet_connected, &window); + gameutils_carousel(&first_setup_carousel, &internet_connected, &window); + final_carousel(&first_setup_carousel); + + // Add file to window + window.set_content(Some(&first_setup_window_toolbarview)) +} diff --git a/src/first_setup/update_carousel.rs b/src/first_setup/update_carousel/mod.rs similarity index 100% rename from src/first_setup/update_carousel.rs rename to src/first_setup/update_carousel/mod.rs diff --git a/src/first_setup/user_carousel.rs b/src/first_setup/user_carousel/mod.rs similarity index 95% rename from src/first_setup/user_carousel.rs rename to src/first_setup/user_carousel/mod.rs index e6a0350..fafd275 100644 --- a/src/first_setup/user_carousel.rs +++ b/src/first_setup/user_carousel/mod.rs @@ -203,32 +203,32 @@ pub fn user_carousel(first_setup_carousel: &adw::Carousel) { user_info_username.set_position(-1); } - let mut username_is_root = false; - let mut username_is_pikaos = false; - let mut username_is_special = false; + let mut _username_is_root = false; + let mut _username_is_pikaos = false; + let mut _username_is_special = false; if user_info_username_string != "root" { - username_is_root=false; + _username_is_root=false; } else { error_label.set_label(&gettext("error_label_is_root_label")); - username_is_root=true; + _username_is_root=true; } if user_info_username_string != "pikaos" { - username_is_pikaos=false; + _username_is_pikaos=false; } else { error_label.set_label(&gettext("error_label_is_pikaos_label")); - username_is_pikaos=true; + _username_is_pikaos=true; } if only_alphanumeric(&user_info_username_string) { - username_is_special=false; + _username_is_special=false; } else { error_label.set_label(&gettext("error_label_is_special_label")); - username_is_special=true; + _username_is_special=true; } - if username_is_root == false && username_is_pikaos == false && username_is_special == false { + if _username_is_root == false && _username_is_pikaos == false && _username_is_special == false { error_label.set_visible(false); if !user_info_username.text().is_empty() { *user_info_username_valid.borrow_mut()=true;