add some funcs
This commit is contained in:
parent
cdc1ca25ae
commit
53271d1f16
@ -1,6 +1,8 @@
|
||||
use adw::gio;
|
||||
use crate::installer_stack_page;
|
||||
use gtk::{prelude::*, glib as glib};
|
||||
use crate::partitioning_page::{get_block_devices};
|
||||
use adw::{prelude::*};
|
||||
use glib::{clone, closure_local};
|
||||
|
||||
pub fn automatic_partitioning_page(
|
||||
@ -33,5 +35,54 @@ pub fn automatic_partitioning_page(
|
||||
)
|
||||
);
|
||||
|
||||
//
|
||||
|
||||
let devices_selection_expander_row = adw::ExpanderRow::builder()
|
||||
.name("status:disk=none,")
|
||||
.build();
|
||||
|
||||
let null_checkbutton = gtk::CheckButton::builder().build();
|
||||
|
||||
|
||||
let devices_selection_expander_row_viewport_box = gtk::ListBox::builder()
|
||||
.selection_mode(gtk::SelectionMode::None)
|
||||
.build();
|
||||
devices_selection_expander_row_viewport_box.add_css_class("boxed-list");
|
||||
devices_selection_expander_row_viewport_box.add_css_class("round-all-scroll");
|
||||
|
||||
let devices_selection_expander_row_viewport =
|
||||
gtk::ScrolledWindow::builder()
|
||||
.vexpand(true)
|
||||
.hexpand(true)
|
||||
.has_frame(true)
|
||||
.child(&devices_selection_expander_row_viewport_box)
|
||||
.build();
|
||||
|
||||
devices_selection_expander_row_viewport.add_css_class("round-all-scroll");
|
||||
|
||||
devices_selection_expander_row.add_row(&devices_selection_expander_row_viewport);
|
||||
|
||||
|
||||
//
|
||||
language_changed_action.connect_activate(
|
||||
clone!(
|
||||
#[weak]
|
||||
automatic_partitioning_page,
|
||||
#[weak]
|
||||
devices_selection_expander_row,
|
||||
move |_, _| {
|
||||
automatic_partitioning_page.set_page_title(t!("auto_part_installer"));
|
||||
automatic_partitioning_page.set_page_subtitle(t!("choose_drive_auto"));
|
||||
automatic_partitioning_page.set_back_tooltip_label(t!("back"));
|
||||
automatic_partitioning_page.set_next_tooltip_label(t!("next"));
|
||||
//
|
||||
if devices_selection_expander_row.widget_name() == "status:disk=none," {
|
||||
devices_selection_expander_row.set_title(&t!("no_drive_auto_selected"));
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
//
|
||||
|
||||
main_carousel.append(&automatic_partitioning_page);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ use crate::installer_stack_page;
|
||||
use gtk::{prelude::*, glib as glib, gio as gio};
|
||||
use glib::{clone, closure_local};
|
||||
use crate::{automatic_partitioning_page};
|
||||
use std::io::BufRead;
|
||||
|
||||
pub fn partitioning_page(
|
||||
main_carousel: &adw::Carousel,
|
||||
@ -100,4 +101,29 @@ pub fn partitioning_page(
|
||||
);
|
||||
|
||||
main_carousel.append(&partitioning_carousel)
|
||||
}
|
||||
|
||||
pub fn get_block_devices() -> Result<Vec<String>, std::io::Error> {
|
||||
let command = std::process::Command::new("sudo")
|
||||
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
|
||||
.arg("get_block_devices")
|
||||
.stdin(std::process::Stdio::piped())
|
||||
.stdout(std::process::Stdio::piped())
|
||||
.spawn()?;
|
||||
|
||||
let mut block_devices = Vec::new();
|
||||
|
||||
match command.stdout {
|
||||
Some(t) => {
|
||||
for blockdev in std::io::BufReader::new(t).lines() {
|
||||
match blockdev {
|
||||
Ok(r) => block_devices.push(r),
|
||||
Err(e) => return Err(e)
|
||||
}
|
||||
}
|
||||
},
|
||||
None => return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "No stdout")),
|
||||
};
|
||||
|
||||
Ok(block_devices)
|
||||
}
|
Loading…
Reference in New Issue
Block a user