RR: Refactor module system
This commit is contained in:
parent
42fa310a5f
commit
5af8f03011
@ -22,8 +22,6 @@ use std::time::*;
|
|||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::install_page;
|
|
||||||
pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer) {
|
pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer) {
|
||||||
let partition_method_automatic_main_box = gtk::Box::builder()
|
let partition_method_automatic_main_box = gtk::Box::builder()
|
||||||
.orientation(Orientation::Vertical)
|
.orientation(Orientation::Vertical)
|
1
src/automatic_partitioning/mod.rs
Normal file
1
src/automatic_partitioning/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
@ -8,17 +8,26 @@ use adw::*;
|
|||||||
use glib::*;
|
use glib::*;
|
||||||
use gdk::Display;
|
use gdk::Display;
|
||||||
use gtk::subclass::layout_child;
|
use gtk::subclass::layout_child;
|
||||||
use crate::save_window_size;
|
|
||||||
use crate::welcome_page;
|
|
||||||
use crate::efi_error_page;
|
|
||||||
use crate::language_page;
|
|
||||||
use crate::eula_page;
|
|
||||||
use crate::timezone_page;
|
|
||||||
use crate::keyboard_page;
|
|
||||||
use crate::partitioning_page;
|
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
use crate::save_window_size::main::save_window_size;
|
||||||
|
|
||||||
|
use crate::welcome_page::main::welcome_page;
|
||||||
|
|
||||||
|
use crate::efi_error_page::main::efi_error_page;
|
||||||
|
|
||||||
|
use crate::language_page::main::language_page;
|
||||||
|
|
||||||
|
use crate::eula_page::main::eula_page;
|
||||||
|
|
||||||
|
use crate::timezone_page::main::timezone_page;
|
||||||
|
|
||||||
|
use crate::keyboard_page::main::keyboard_page;
|
||||||
|
|
||||||
|
use crate::partitioning_page::main::partitioning_page;
|
||||||
|
|
||||||
// build ui function linked to app startup above
|
// build ui function linked to app startup above
|
||||||
pub fn build_ui(app: &adw::Application) {
|
pub fn build_ui(app: &adw::Application) {
|
||||||
|
|
||||||
|
75
src/custom_button/imp.rs
Normal file
75
src/custom_button/imp.rs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
use gtk::glib;
|
||||||
|
use gtk::*;
|
||||||
|
use gtk::prelude::*;
|
||||||
|
use gtk::subclass::prelude::*;
|
||||||
|
use adw::subclass::prelude::*;
|
||||||
|
use adw::prelude::ActionRowExt;
|
||||||
|
use std::cell::{Cell, RefCell};
|
||||||
|
use glib::ObjectExt;
|
||||||
|
use gtk::Orientation::Horizontal;
|
||||||
|
use glib::GString;
|
||||||
|
|
||||||
|
// Object holding the state
|
||||||
|
#[derive(glib::Properties, Default)]
|
||||||
|
#[properties(wrapper_type = super::CustomButton)]
|
||||||
|
pub struct CustomButton {
|
||||||
|
#[property(get, set)]
|
||||||
|
filesystem: RefCell<String>,
|
||||||
|
partition: RefCell<String>,
|
||||||
|
mountpoint: RefCell<String>,
|
||||||
|
partition_scroll: gtk::ScrolledWindow
|
||||||
|
}
|
||||||
|
|
||||||
|
// The central trait for subclassing a GObject
|
||||||
|
#[glib::object_subclass]
|
||||||
|
impl ObjectSubclass for CustomButton {
|
||||||
|
const NAME: &'static str = "MyGtkAppCustomButton";
|
||||||
|
type Type = super::CustomButton;
|
||||||
|
type ParentType = adw::ActionRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trait shared by all GObjects
|
||||||
|
// Trait shared by all GObjects
|
||||||
|
#[glib::derived_properties]
|
||||||
|
impl ObjectImpl for CustomButton {
|
||||||
|
fn constructed(&self) {
|
||||||
|
self.parent_constructed();
|
||||||
|
|
||||||
|
// Bind label to number
|
||||||
|
// `SYNC_CREATE` ensures that the label will be immediately set
|
||||||
|
let obj = self.obj();
|
||||||
|
let action_row_content_box = gtk::Box::builder()
|
||||||
|
.orientation(Horizontal)
|
||||||
|
.spacing(0)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let partition_row_expander = adw::ExpanderRow::builder()
|
||||||
|
.title("Partition")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
action_row_content_box.append(&partition_row_expander);
|
||||||
|
|
||||||
|
obj.add_prefix(&action_row_content_box)
|
||||||
|
|
||||||
|
//obj.bind_property("number", obj.as_ref(), "label")
|
||||||
|
// .sync_create()
|
||||||
|
// .build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trait shared by all widgets
|
||||||
|
impl WidgetImpl for CustomButton {}
|
||||||
|
|
||||||
|
// Trait shared by all buttons
|
||||||
|
// Trait shared by all buttons
|
||||||
|
|
||||||
|
impl ListBoxRowImpl for CustomButton {}
|
||||||
|
|
||||||
|
impl PreferencesRowImpl for CustomButton {}
|
||||||
|
|
||||||
|
impl ActionRowImpl for CustomButton {
|
||||||
|
//fn clicked(&self) {
|
||||||
|
// let incremented_number = self.obj().number() + 1;
|
||||||
|
// self.obj().set_number(incremented_number);
|
||||||
|
//}
|
||||||
|
}
|
17
src/custom_button/mod.rs
Normal file
17
src/custom_button/mod.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
mod imp;
|
||||||
|
|
||||||
|
use glib::Object;
|
||||||
|
use gtk::glib;
|
||||||
|
use gtk::ListBoxRow;
|
||||||
|
|
||||||
|
glib::wrapper! {
|
||||||
|
pub struct CustomButton(ObjectSubclass<imp::CustomButton>)
|
||||||
|
@extends adw::ActionRow, gtk::Widget, gtk::ListBoxRow, adw::PreferencesRow,
|
||||||
|
@implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CustomButton {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Object::builder().build()
|
||||||
|
}
|
||||||
|
}
|
1
src/done_page/mod.rs
Normal file
1
src/done_page/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
1
src/efi_error_page/mod.rs
Normal file
1
src/efi_error_page/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
1
src/eula_page/mod.rs
Normal file
1
src/eula_page/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
@ -11,6 +11,7 @@ use gtk::subclass::layout_child;
|
|||||||
use vte::prelude::*;
|
use vte::prelude::*;
|
||||||
use vte::*;
|
use vte::*;
|
||||||
|
|
||||||
|
use crate::done_page::main::done_page;
|
||||||
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use pretty_bytes::converter::convert;
|
use pretty_bytes::converter::convert;
|
||||||
@ -18,8 +19,6 @@ use pretty_bytes::converter::convert;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::done_page;
|
|
||||||
|
|
||||||
pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) {
|
pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) {
|
||||||
|
|
||||||
// create the bottom box for next and back buttons
|
// create the bottom box for next and back buttons
|
1
src/install_page/mod.rs
Normal file
1
src/install_page/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
1
src/keyboard_page/mod.rs
Normal file
1
src/keyboard_page/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
@ -232,7 +232,7 @@ pub fn language_page(content_stack: >k::Stack) {
|
|||||||
Command::new("sudo")
|
Command::new("sudo")
|
||||||
.arg("localectl")
|
.arg("localectl")
|
||||||
.arg("set-locale")
|
.arg("set-locale")
|
||||||
.arg("LANG=".to_owned() + &lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string())
|
.arg("LANG=".to_owned() + &lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string() + ".UTF-8")
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("locale failed to start");
|
.expect("locale failed to start");
|
||||||
content_stack.set_visible_child_name("eula_page")
|
content_stack.set_visible_child_name("eula_page")
|
1
src/language_page/mod.rs
Normal file
1
src/language_page/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
19
src/main.rs
19
src/main.rs
@ -10,7 +10,6 @@ use glib::*;
|
|||||||
use gdk::Display;
|
use gdk::Display;
|
||||||
use gtk::subclass::layout_child;
|
use gtk::subclass::layout_child;
|
||||||
mod build_ui;
|
mod build_ui;
|
||||||
use crate::build_ui::build_ui;
|
|
||||||
mod save_window_size;
|
mod save_window_size;
|
||||||
mod welcome_page;
|
mod welcome_page;
|
||||||
mod efi_error_page;
|
mod efi_error_page;
|
||||||
@ -21,21 +20,9 @@ mod keyboard_page;
|
|||||||
mod partitioning_page;
|
mod partitioning_page;
|
||||||
mod install_page;
|
mod install_page;
|
||||||
mod done_page;
|
mod done_page;
|
||||||
mod automatic_paritioning;
|
mod automatic_partitioning;
|
||||||
mod manual_partitioning;
|
mod manual_partitioning;
|
||||||
|
mod custom_button;
|
||||||
use crate::save_window_size::save_window_size;
|
|
||||||
use crate::welcome_page::welcome_page;
|
|
||||||
use crate::efi_error_page::efi_error_page;
|
|
||||||
use crate::language_page::language_page;
|
|
||||||
use crate::eula_page::eula_page;
|
|
||||||
use crate::timezone_page::timezone_page;
|
|
||||||
use crate::keyboard_page::keyboard_page;
|
|
||||||
use crate::partitioning_page::partitioning_page;
|
|
||||||
use crate::automatic_paritioning::automatic_partitioning;
|
|
||||||
use crate::manual_partitioning::manual_partitioning;
|
|
||||||
use crate::install_page::install_page;
|
|
||||||
use crate::done_page::done_page;
|
|
||||||
|
|
||||||
/// main function
|
/// main function
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -52,7 +39,7 @@ fn main() {
|
|||||||
STYLE_PROVIDER_PRIORITY_APPLICATION,
|
STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||||
);
|
);
|
||||||
|
|
||||||
app.connect_activate(build_ui);
|
app.connect_activate(build_ui::build_ui);
|
||||||
});
|
});
|
||||||
application.run();
|
application.run();
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,25 @@ use std::time::*;
|
|||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use crate::custom_button::CustomButton;
|
||||||
|
|
||||||
use crate::install_page;
|
fn create_mount_row_list_box(device: &str) -> ActionRow {
|
||||||
|
// Create check button
|
||||||
|
let check_button = CheckButton::builder()
|
||||||
|
.valign(Align::Center)
|
||||||
|
.can_focus(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Create row
|
||||||
|
let row = ActionRow::builder()
|
||||||
|
.activatable_widget(&check_button)
|
||||||
|
.title(device)
|
||||||
|
.build();
|
||||||
|
row.add_prefix(&check_button);
|
||||||
|
|
||||||
|
// Return row
|
||||||
|
row
|
||||||
|
}
|
||||||
|
|
||||||
pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) {
|
pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) {
|
||||||
let partition_method_manual_main_box = gtk::Box::builder()
|
let partition_method_manual_main_box = gtk::Box::builder()
|
||||||
@ -207,6 +223,22 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack:
|
|||||||
partition_method_manual_main_box.append(&partition_method_manual_efi_error_label);
|
partition_method_manual_main_box.append(&partition_method_manual_efi_error_label);
|
||||||
partition_method_manual_main_box.append(&partition_method_manual_gparted_button);
|
partition_method_manual_main_box.append(&partition_method_manual_gparted_button);
|
||||||
|
|
||||||
|
let shit_button = CustomButton::new();
|
||||||
|
|
||||||
|
shit_button.set_title("haggar");
|
||||||
|
|
||||||
|
let create_mount_row_list_box = gtk::ListBox::builder()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
//shit_button.connect_clicked(clone!(@weak create_mount_row_list_box => move |_|{
|
||||||
|
// create_mount_row_list_box.append(&create_mount_row("col"))
|
||||||
|
//}));
|
||||||
|
|
||||||
|
partition_method_manual_main_box.append(&shit_button);
|
||||||
|
partition_method_manual_main_box.append(&create_mount_row_list_box);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// clone partition_method_manual_chroot_dir_file_dialog as rust becuase glib breaks it show function for some reason
|
// clone partition_method_manual_chroot_dir_file_dialog as rust becuase glib breaks it show function for some reason
|
||||||
let partition_method_manual_chroot_dir_file_dialog_clone = partition_method_manual_chroot_dir_file_dialog.clone();
|
let partition_method_manual_chroot_dir_file_dialog_clone = partition_method_manual_chroot_dir_file_dialog.clone();
|
||||||
partition_method_manual_chroot_dir_button.connect_clicked(move |_| {
|
partition_method_manual_chroot_dir_button.connect_clicked(move |_| {
|
||||||
@ -520,4 +552,4 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack:
|
|||||||
partitioning_stack.add_titled(&partition_method_manual_main_box, Some("partition_method_manual_page"), "partition_method_manual_page");
|
partitioning_stack.add_titled(&partition_method_manual_main_box, Some("partition_method_manual_page"), "partition_method_manual_page");
|
||||||
|
|
||||||
return(partition_method_manual_target_buffer, partition_method_manual_luks_buffer, partition_method_manual_luks_password_entry)
|
return(partition_method_manual_target_buffer, partition_method_manual_luks_buffer, partition_method_manual_luks_password_entry)
|
||||||
}
|
}
|
1
src/manual_partitioning/mod.rs
Normal file
1
src/manual_partitioning/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
@ -9,8 +9,9 @@ use glib::*;
|
|||||||
use gdk::Display;
|
use gdk::Display;
|
||||||
use gtk::subclass::layout_child;
|
use gtk::subclass::layout_child;
|
||||||
|
|
||||||
use crate::automatic_paritioning::automatic_partitioning;
|
use crate::automatic_partitioning::main::automatic_partitioning;
|
||||||
use crate::manual_partitioning::manual_partitioning;
|
use crate::manual_partitioning::main::manual_partitioning;
|
||||||
|
use crate::install_page::main::install_page;
|
||||||
|
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
@ -277,4 +278,4 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
1
src/partitioning_page/mod.rs
Normal file
1
src/partitioning_page/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
@ -16,4 +16,4 @@ pub fn save_window_size(window: &adw::ApplicationWindow, glib_settings: &gio::Se
|
|||||||
let _ = glib_settings.set_int("window-width", size.0);
|
let _ = glib_settings.set_int("window-width", size.0);
|
||||||
let _ = glib_settings.set_int("window-height", size.1);
|
let _ = glib_settings.set_int("window-height", size.1);
|
||||||
let _ = glib_settings.set_boolean("is-maximized", window.is_maximized());
|
let _ = glib_settings.set_boolean("is-maximized", window.is_maximized());
|
||||||
}
|
}
|
1
src/save_window_size/mod.rs
Normal file
1
src/save_window_size/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
1
src/timezone_page/mod.rs
Normal file
1
src/timezone_page/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
@ -166,4 +166,4 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack)
|
|||||||
|
|
||||||
install_media_button.connect_clicked(clone!(@weak content_stack => move |_| content_stack.set_visible_child_name("language_page")));
|
install_media_button.connect_clicked(clone!(@weak content_stack => move |_| content_stack.set_visible_child_name("language_page")));
|
||||||
live_media_button.connect_clicked(clone!(@weak window => move |_| window.close()));
|
live_media_button.connect_clicked(clone!(@weak window => move |_| window.close()));
|
||||||
}
|
}
|
1
src/welcome_page/mod.rs
Normal file
1
src/welcome_page/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod main;
|
Loading…
Reference in New Issue
Block a user