lang barrier bypassed

This commit is contained in:
Ward from fusion-voyager-3 2024-08-18 21:50:25 +03:00
parent fc9c39b087
commit 991b42ab49
2 changed files with 35 additions and 11 deletions

View File

@ -1,19 +1,11 @@
use std::{cell::RefCell, env, rc::Rc, sync::OnceLock};
use adw::{prelude::*, subclass::prelude::*, *};
use gtk::{glib as glib, Orientation::Horizontal, SizeGroup};
use gtk::{glib as glib, Orientation::Horizontal};
use glib::{clone, subclass::Signal, Properties};
use crate::partitioning_page::FstabEntry;
struct DriveSizeGroup(gtk::SizeGroup);
impl Default for DriveSizeGroup {
pub fn default(&self) -> Self {
DriveSizeGroup::
}
}
// ANCHOR: custom_button
// Object holding the state
#[derive(Properties, Default)]
@ -30,7 +22,7 @@ pub struct DriveMountRow {
#[property(get, set)]
partitionscroll: Rc<RefCell<gtk::ScrolledWindow>>,
#[property(get, set)]
sizegroup: Rc<RefCell<DriveSizeGroup>>,
sizegroup: Rc<RefCell<Option<gtk::SizeGroup>>>,
}
// ANCHOR_END: custom_button
@ -132,6 +124,31 @@ impl ObjectImpl for DriveMountRow {
obj.append(&partition_row_delete_button);
obj.connect_sizegroup_notify(clone!(
#[weak]
obj,
#[weak]
partition_row_expander_adw_listbox,
#[weak]
mountpoint_entry_row,
#[weak]
mountopts_entry_row,
move |_|
{
match obj.sizegroup() {
Some(t) => {
t.add_widget(&partition_row_expander_adw_listbox);
t.add_widget(&mountpoint_entry_row);
t.add_widget(&mountopts_entry_row);
}
None => {
}
}
}
)
);
// Bind label to number
// `SYNC_CREATE` ensures that the label will be immediately set
let obj = self.obj();

View File

@ -36,6 +36,10 @@ pub fn manual_partitioning_page(
//
let drive_rows_size_group = gtk::SizeGroup::new(gtk::SizeGroupMode::Horizontal);
//
let content_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.hexpand(true)
@ -77,7 +81,7 @@ pub fn manual_partitioning_page(
partition_method_manual_fstab_entry_array_refcell,
move |_|
{
drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox, &partition_array_refcell.borrow(), &partition_changed_action, &used_partition_array_refcell, &do_used_part_check_refcell))
drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox, &drive_rows_size_group, &partition_array_refcell.borrow(), &partition_changed_action, &used_partition_array_refcell, &do_used_part_check_refcell))
}
)
);
@ -147,6 +151,7 @@ pub fn manual_partitioning_page(
fn create_mount_row(
listbox: &gtk::ListBox,
drive_rows_size_group: &gtk::SizeGroup,
partition_array: &Vec<Partition>,
partition_changed_action: &gio::SimpleAction,
used_partition_array_refcell: &Rc<RefCell<Vec<String>>>,
@ -167,6 +172,8 @@ fn create_mount_row(
row.set_deletable(true);
row.set_sizegroup(drive_rows_size_group);
let null_checkbutton = gtk::CheckButton::builder().build();
for partition in partition_array {