diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index f79cf52..7d1c760 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -1,4 +1,4 @@ -use std::{cell::RefCell, env, rc::Rc, sync::OnceLock}; +use std::{cell::RefCell, rc::Rc, sync::OnceLock}; use adw::{prelude::*, subclass::prelude::*, *}; use gtk::{glib as glib, Orientation::Horizontal}; @@ -22,7 +22,9 @@ pub struct DriveMountRow { #[property(get, set)] partitionscroll: Rc>, #[property(get, set)] - sizegroup: Rc>>, + sizegroup: RefCell>, + #[property(get, set)] + langaction: RefCell> } // ANCHOR_END: custom_button @@ -43,11 +45,6 @@ impl ObjectImpl for DriveMountRow { SIGNALS.get_or_init(|| vec![Signal::builder("row-deleted").build()]) } fn constructed(&self) { - let current_locale = match env::var_os("LANG") { - Some(v) => v.into_string().unwrap(), - None => panic!("$LANG is not set"), - }; - rust_i18n::set_locale(current_locale.strip_suffix(".UTF-8").unwrap()); self.parent_constructed(); @@ -211,6 +208,8 @@ impl ObjectImpl for DriveMountRow { obj.connect_partitionscroll_notify(clone!( #[weak] obj, + #[weak] + partition_row_expander, move |_| { partition_row_expander.add_row(&obj.property::("partitionscroll")); @@ -218,6 +217,44 @@ impl ObjectImpl for DriveMountRow { ) ); + obj.connect_langaction_notify(clone!( + #[weak] + obj, + #[weak] + partition_row_expander, + #[weak] + mountpoint_entry_row, + #[weak] + mountopts_entry_row, + move |_| + { + match obj.langaction() { + Some(t) => { + t.connect_activate( + clone!( + #[weak] + partition_row_expander, + #[weak] + mountpoint_entry_row, + #[weak] + mountopts_entry_row, + move |_, _| + { + partition_row_expander.set_subtitle(&t!("subtitle_partition")); + mountpoint_entry_row.set_title(&t!("title_mountpoint")); + mountopts_entry_row.set_title(&t!("title_mountopts")); + } + ) + ); + } + None => { + + } + } + } + ) + ); + obj.set_child(Some(&action_row_content_box)); } } diff --git a/src/manual_partitioning_page/mod.rs b/src/manual_partitioning_page/mod.rs index e5d1d65..3e0b907 100644 --- a/src/manual_partitioning_page/mod.rs +++ b/src/manual_partitioning_page/mod.rs @@ -78,10 +78,12 @@ pub fn manual_partitioning_page( #[strong] partition_array_refcell, #[strong] - partition_method_manual_fstab_entry_array_refcell, + language_changed_action, + #[strong] + partition_changed_action, move |_| { - 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, &language_changed_action, &used_partition_array_refcell, &do_used_part_check_refcell); } ) ); @@ -154,6 +156,7 @@ fn create_mount_row( drive_rows_size_group: >k::SizeGroup, partition_array: &Vec, partition_changed_action: &gio::SimpleAction, + language_changed_action: &gio::SimpleAction, used_partition_array_refcell: &Rc>>, do_used_part_check_refcell: &Rc>, ) { @@ -174,6 +177,8 @@ fn create_mount_row( row.set_sizegroup(drive_rows_size_group); + row.set_langaction(language_changed_action); + let null_checkbutton = gtk::CheckButton::builder().build(); for partition in partition_array {