minor fix

This commit is contained in:
Ward from fusion-voyager-3 2024-08-18 22:35:48 +03:00
parent 8631312248
commit ea6cc6cfec
3 changed files with 24 additions and 14 deletions

View File

@ -31,7 +31,7 @@ pub struct DriveMountRow {
impl ObjectSubclass for DriveMountRow { impl ObjectSubclass for DriveMountRow {
const NAME: &'static str = "DriveMountRow"; const NAME: &'static str = "DriveMountRow";
type Type = super::DriveMountRow; type Type = super::DriveMountRow;
type ParentType = gtk::Box; type ParentType = gtk::ListBoxRow;
} }
// ANCHOR: object_impl // ANCHOR: object_impl
@ -55,6 +55,13 @@ impl ObjectImpl for DriveMountRow {
// `SYNC_CREATE` ensures that the label will be immediately set // `SYNC_CREATE` ensures that the label will be immediately set
let obj = self.obj(); let obj = self.obj();
let action_row_content_box = gtk::Box::builder()
.orientation(Horizontal)
.spacing(0)
.vexpand(true)
.hexpand(true)
.build();
let partition_row_expander_adw_listbox = gtk::ListBox::builder() let partition_row_expander_adw_listbox = gtk::ListBox::builder()
.hexpand(true) .hexpand(true)
.vexpand(true) .vexpand(true)
@ -150,13 +157,13 @@ impl ObjectImpl for DriveMountRow {
// //
obj.append(&partition_row_expander_adw_listbox); action_row_content_box.append(&partition_row_expander_adw_listbox);
obj.append(&mountpoint_entry_row_adw_listbox); action_row_content_box.append(&mountpoint_entry_row_adw_listbox);
obj.append(&mountopts_entry_row_adw_listbox); action_row_content_box.append(&mountopts_entry_row_adw_listbox);
obj.append(&partition_row_delete_button); action_row_content_box.append(&partition_row_delete_button);
obj.connect_sizegroup_notify(clone!( obj.connect_sizegroup_notify(clone!(
#[weak] #[weak]
@ -210,9 +217,11 @@ impl ObjectImpl for DriveMountRow {
} }
) )
); );
obj.set_child(Some(&action_row_content_box));
} }
} }
// Trait shared by all widgets // Trait shared by all widgets
impl WidgetImpl for DriveMountRow {} impl WidgetImpl for DriveMountRow {}
impl BoxImpl for DriveMountRow {} impl ListBoxRowImpl for DriveMountRow {}

View File

@ -7,7 +7,7 @@ use crate::partitioning_page::FstabEntry;
glib::wrapper! { glib::wrapper! {
pub struct DriveMountRow(ObjectSubclass<imp::DriveMountRow>) pub struct DriveMountRow(ObjectSubclass<imp::DriveMountRow>)
@extends gtk::Box, gtk::Widget, @extends gtk::Widget, gtk::ListBoxRow,
@implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget; @implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;
} }

View File

@ -81,7 +81,7 @@ pub fn manual_partitioning_page(
partition_method_manual_fstab_entry_array_refcell, partition_method_manual_fstab_entry_array_refcell,
move |_| move |_|
{ {
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)) 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);
} }
) )
); );
@ -156,7 +156,7 @@ fn create_mount_row(
partition_changed_action: &gio::SimpleAction, partition_changed_action: &gio::SimpleAction,
used_partition_array_refcell: &Rc<RefCell<Vec<String>>>, used_partition_array_refcell: &Rc<RefCell<Vec<String>>>,
do_used_part_check_refcell: &Rc<RefCell<bool>>, do_used_part_check_refcell: &Rc<RefCell<bool>>,
) -> DriveMountRow { ) {
let partition_scroll_child = gtk::ListBox::builder() let partition_scroll_child = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.build(); .build();
@ -264,11 +264,15 @@ fn create_mount_row(
partition_scroll_child.append(&partition_row); partition_scroll_child.append(&partition_row);
} }
let listbox_clone = listbox.clone();
listbox.append(&row);
row.connect_closure( row.connect_closure(
"row-deleted", "row-deleted",
false, false,
closure_local!( closure_local!(
#[weak]
listbox,
#[strong] #[strong]
row, row,
#[strong] #[strong]
@ -277,13 +281,10 @@ fn create_mount_row(
partition_changed_action, partition_changed_action,
move |row: DriveMountRow| move |row: DriveMountRow|
{ {
listbox_clone.remove(&row); listbox.remove(&row);
(*used_partition_array_refcell.borrow_mut()).retain(|x| x != &row.partition()); (*used_partition_array_refcell.borrow_mut()).retain(|x| x != &row.partition());
partition_changed_action.activate(None); partition_changed_action.activate(None);
} }
), ),
); );
// Return row
row
} }