From 10f44e28ec2d82a233f787a5cedb252c3f83c57e Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Fri, 11 Oct 2024 19:11:15 +0300 Subject: [PATCH] add disk names and impl scroll overflow --- data/scripts/partition-utility.sh | 5 +++++ src/automatic_partitioning_page/mod.rs | 4 ++-- src/build_ui.rs | 1 + src/eula_page/mod.rs | 5 ++++- src/keyboard_page/mod.rs | 5 +++-- src/language_page/mod.rs | 5 +++-- src/partitioning_page/mod.rs | 20 ++++++++++++++++++++ src/style.css | 26 ++++++++++++++++++++++++++ src/timezone_page/mod.rs | 5 +++-- 9 files changed, 67 insertions(+), 9 deletions(-) diff --git a/data/scripts/partition-utility.sh b/data/scripts/partition-utility.sh index e9bd1c5..492c60f 100755 --- a/data/scripts/partition-utility.sh +++ b/data/scripts/partition-utility.sh @@ -14,6 +14,11 @@ then lsblk -b --output SIZE -n -d /dev/"$2" fi +if [[ "$1" = "get_block_model" ]] +then + cat /sys/class/block/"$2"/device/model +fi + if [[ "$1" = "has_encryption" ]] then if blkid -o value -s TYPE $(lsblk -sJp | jq -r --arg dsk /dev/"$2" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name') | grep -i luks > /dev/null 2>&1 diff --git a/src/automatic_partitioning_page/mod.rs b/src/automatic_partitioning_page/mod.rs index 38e98b0..78b235a 100644 --- a/src/automatic_partitioning_page/mod.rs +++ b/src/automatic_partitioning_page/mod.rs @@ -377,8 +377,8 @@ pub fn automatic_partitioning_page( device_button.set_group(Some(&null_checkbutton)); let device_row = adw::ActionRow::builder() .activatable_widget(&device_button) - .title(&device.block_name) - .subtitle(&device.block_size_pretty) + .title(&device.block_model) + .subtitle(device.clone().block_name + " " + &device.block_size_pretty) .build(); device_row.add_prefix(&device_button); devices_selection_expander_row_viewport_box.append(&device_row); diff --git a/src/build_ui.rs b/src/build_ui.rs index b0f379c..71de3a5 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -34,6 +34,7 @@ pub struct PikaKeymap { #[derive(Default, Clone, Debug)] pub struct BlockDevice { pub block_name: String, + pub block_model: String, pub block_size: f64, pub block_size_pretty: String, } diff --git a/src/eula_page/mod.rs b/src/eula_page/mod.rs index c80c562..aad504e 100644 --- a/src/eula_page/mod.rs +++ b/src/eula_page/mod.rs @@ -24,15 +24,18 @@ pub fn eula_page(main_carousel: &adw::Carousel, language_changed_action: &gio::S .vexpand(true) .editable(false) .buffer(&eula_buffer) + .right_margin(10) + .left_margin(10) .build(); let eula_selection_text_scroll = gtk::ScrolledWindow::builder() .vexpand(true) .hexpand(true) .has_frame(true) + .overflow(gtk::Overflow::Hidden) .child(&eula_selection_text_view) .build(); - eula_selection_text_scroll.add_css_class("round-all-scroll"); + eula_selection_text_scroll.add_css_class("round-all-scroll-no-padding"); let eula_accept_checkbutton = gtk::CheckButton::builder() .margin_top(15) diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs index b52a72c..3315a7d 100644 --- a/src/keyboard_page/mod.rs +++ b/src/keyboard_page/mod.rs @@ -29,16 +29,17 @@ pub fn keyboard_page( .selection_mode(gtk::SelectionMode::None) .build(); keyboard_selection_row_viewport_listbox.add_css_class("boxed-list"); - keyboard_selection_row_viewport_listbox.add_css_class("round-border-only"); + keyboard_selection_row_viewport_listbox.add_css_class("no-round-borders"); let keyboard_selection_row_viewport = gtk::ScrolledWindow::builder() .vexpand(true) .hexpand(true) .has_frame(true) + .overflow(gtk::Overflow::Hidden) .child(&keyboard_selection_row_viewport_listbox) .build(); - keyboard_selection_row_viewport.add_css_class("round-border-only-top-with-padding"); + keyboard_selection_row_viewport.add_css_class("round-border-only-top-with-no-padding"); let keyboard_search_bar = gtk::SearchEntry::builder() .hexpand(true) diff --git a/src/language_page/mod.rs b/src/language_page/mod.rs index 519b74c..6011090 100644 --- a/src/language_page/mod.rs +++ b/src/language_page/mod.rs @@ -32,16 +32,17 @@ pub fn language_page( .selection_mode(gtk::SelectionMode::None) .build(); language_selection_row_viewport_listbox.add_css_class("boxed-list"); - language_selection_row_viewport_listbox.add_css_class("round-all-scroll"); + language_selection_row_viewport_listbox.add_css_class("no-round-borders"); let language_selection_row_viewport = gtk::ScrolledWindow::builder() .vexpand(true) .hexpand(true) .has_frame(true) + .overflow(gtk::Overflow::Hidden) .child(&language_selection_row_viewport_listbox) .build(); - language_selection_row_viewport.add_css_class("round-all-scroll"); + language_selection_row_viewport.add_css_class("round-all-scroll-no-padding"); let language_search_bar = gtk::SearchEntry::builder() .hexpand(true) diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 0b7f8b9..72b54f8 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -196,8 +196,10 @@ pub fn get_block_devices() -> Vec { match blockdev { Ok(r) => { let block_size = get_block_size(&r); + let block_model = get_block_model(&r); block_devices.push(BlockDevice { block_name: r, + block_model, block_size, block_size_pretty: pretty_bytes::converter::convert(block_size), }) @@ -230,6 +232,24 @@ fn get_block_size(block_dev: &str) -> f64 { size } +fn get_block_model(block_dev: &str) -> String { + let command = match std::process::Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_block_model") + .arg(block_dev) + .output() + { + Ok(t) => t, + Err(_) => return "Unknown".to_owned(), + }; + let model = match String::from_utf8(command.stdout) { + Ok(t) => t.trim().to_owned(), + Err(_) => "Unknown".to_owned(), + }; + + model +} + pub fn get_partitions() -> Vec { let mut partitions = Vec::new(); diff --git a/src/style.css b/src/style.css index a8f2c59..28f1479 100644 --- a/src/style.css +++ b/src/style.css @@ -72,6 +72,28 @@ padding-bottom: 3px; } +.round-all-scroll-no-padding { + border-top-right-radius: 15px; + border-top-left-radius: 15px; + border-bottom-right-radius: 15px; + border-bottom-left-radius: 15px; + padding-top: 0px; + padding-right: 0px; + padding-left: 0px; + padding-bottom: 0px; +} + +.round-border-only-top-with-no-padding { + border-top-right-radius: 15px; + border-top-left-radius: 15px; + border-bottom-right-radius: 0px; + border-bottom-left-radius: 0px; + padding-top: 0px; + padding-right: 0px; + padding-left: 0px; + padding-bottom: 0px; +} + .round-border-only-bottom { border-top-right-radius: 0px; border-top-left-radius: 0px; @@ -84,6 +106,10 @@ border-top-left-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; + padding-top: 0px; + padding-right: 0px; + padding-left: 0px; + padding-bottom: 0px; } diff --git a/src/timezone_page/mod.rs b/src/timezone_page/mod.rs index 4587659..21dc4b9 100644 --- a/src/timezone_page/mod.rs +++ b/src/timezone_page/mod.rs @@ -28,16 +28,17 @@ pub fn timezone_page( .selection_mode(gtk::SelectionMode::None) .build(); timezone_selection_row_viewport_listbox.add_css_class("boxed-list"); - timezone_selection_row_viewport_listbox.add_css_class("round-all-scroll"); + timezone_selection_row_viewport_listbox.add_css_class("no-round-borders"); let timezone_selection_row_viewport = gtk::ScrolledWindow::builder() .vexpand(true) .hexpand(true) .has_frame(true) + .overflow(gtk::Overflow::Hidden) .child(&timezone_selection_row_viewport_listbox) .build(); - timezone_selection_row_viewport.add_css_class("round-all-scroll"); + timezone_selection_row_viewport.add_css_class("round-all-scroll-no-padding"); let timezone_search_bar = gtk::SearchEntry::builder() .hexpand(true)