Add lang support to drive row
This commit is contained in:
parent
ea6cc6cfec
commit
f4110bde5b
@ -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 adw::{prelude::*, subclass::prelude::*, *};
|
||||||
use gtk::{glib as glib, Orientation::Horizontal};
|
use gtk::{glib as glib, Orientation::Horizontal};
|
||||||
@ -22,7 +22,9 @@ pub struct DriveMountRow {
|
|||||||
#[property(get, set)]
|
#[property(get, set)]
|
||||||
partitionscroll: Rc<RefCell<gtk::ScrolledWindow>>,
|
partitionscroll: Rc<RefCell<gtk::ScrolledWindow>>,
|
||||||
#[property(get, set)]
|
#[property(get, set)]
|
||||||
sizegroup: Rc<RefCell<Option<gtk::SizeGroup>>>,
|
sizegroup: RefCell<Option<gtk::SizeGroup>>,
|
||||||
|
#[property(get, set)]
|
||||||
|
langaction: RefCell<Option<gio::SimpleAction>>
|
||||||
}
|
}
|
||||||
// ANCHOR_END: custom_button
|
// ANCHOR_END: custom_button
|
||||||
|
|
||||||
@ -43,11 +45,6 @@ impl ObjectImpl for DriveMountRow {
|
|||||||
SIGNALS.get_or_init(|| vec![Signal::builder("row-deleted").build()])
|
SIGNALS.get_or_init(|| vec![Signal::builder("row-deleted").build()])
|
||||||
}
|
}
|
||||||
fn constructed(&self) {
|
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();
|
self.parent_constructed();
|
||||||
|
|
||||||
@ -211,6 +208,8 @@ impl ObjectImpl for DriveMountRow {
|
|||||||
obj.connect_partitionscroll_notify(clone!(
|
obj.connect_partitionscroll_notify(clone!(
|
||||||
#[weak]
|
#[weak]
|
||||||
obj,
|
obj,
|
||||||
|
#[weak]
|
||||||
|
partition_row_expander,
|
||||||
move |_|
|
move |_|
|
||||||
{
|
{
|
||||||
partition_row_expander.add_row(&obj.property::<gtk::ScrolledWindow>("partitionscroll"));
|
partition_row_expander.add_row(&obj.property::<gtk::ScrolledWindow>("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));
|
obj.set_child(Some(&action_row_content_box));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,10 +78,12 @@ pub fn manual_partitioning_page(
|
|||||||
#[strong]
|
#[strong]
|
||||||
partition_array_refcell,
|
partition_array_refcell,
|
||||||
#[strong]
|
#[strong]
|
||||||
partition_method_manual_fstab_entry_array_refcell,
|
language_changed_action,
|
||||||
|
#[strong]
|
||||||
|
partition_changed_action,
|
||||||
move |_|
|
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,
|
drive_rows_size_group: >k::SizeGroup,
|
||||||
partition_array: &Vec<Partition>,
|
partition_array: &Vec<Partition>,
|
||||||
partition_changed_action: &gio::SimpleAction,
|
partition_changed_action: &gio::SimpleAction,
|
||||||
|
language_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>>,
|
||||||
) {
|
) {
|
||||||
@ -174,6 +177,8 @@ fn create_mount_row(
|
|||||||
|
|
||||||
row.set_sizegroup(drive_rows_size_group);
|
row.set_sizegroup(drive_rows_size_group);
|
||||||
|
|
||||||
|
row.set_langaction(language_changed_action);
|
||||||
|
|
||||||
let null_checkbutton = gtk::CheckButton::builder().build();
|
let null_checkbutton = gtk::CheckButton::builder().build();
|
||||||
|
|
||||||
for partition in partition_array {
|
for partition in partition_array {
|
||||||
|
Loading…
Reference in New Issue
Block a user