print: Use inch for US and LR
Closes #143 Part-of: <https://gitlab.gnome.org/GNOME/loupe/-/merge_requests/240>
This commit is contained in:
parent
172ce9d976
commit
aac476134f
3 changed files with 31 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1610,6 +1610,7 @@ dependencies = [
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"futures",
|
"futures",
|
||||||
"gettext-rs",
|
"gettext-rs",
|
||||||
|
"gettext-sys",
|
||||||
"gio",
|
"gio",
|
||||||
"glycin",
|
"glycin",
|
||||||
"gtk4",
|
"gtk4",
|
||||||
|
|
|
||||||
|
|
@ -52,3 +52,7 @@ features = ["v1_4"]
|
||||||
[dependencies.gettext-rs]
|
[dependencies.gettext-rs]
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
features = ["gettext-system"]
|
features = ["gettext-system"]
|
||||||
|
|
||||||
|
[dependencies.gettext-sys]
|
||||||
|
version = "0.21.3"
|
||||||
|
features = ["gettext-system"]
|
||||||
|
|
@ -380,6 +380,20 @@ mod imp {
|
||||||
.round(obj.image().image_size().0 as f64 * obj.width_unit_factor()),
|
.round(obj.image().image_size().0 as f64 * obj.width_unit_factor()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Default to inch for USA and Liberia
|
||||||
|
if let Some(unit_locale) = getlocale(gettextrs::LocaleCategory::LcMeasurement) {
|
||||||
|
if let Some(locale) = unit_locale
|
||||||
|
.split(|x| *x == b'_')
|
||||||
|
.nth(1)
|
||||||
|
.and_then(|x| x.get(0..2))
|
||||||
|
{
|
||||||
|
if locale == b"US" || locale == b"LR" {
|
||||||
|
imp.margin_unit.set_selected(Unit::Inch as u32);
|
||||||
|
imp.size_unit.set_selected(Unit::Inch as u32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
imp.print_operation.cancel();
|
imp.print_operation.cancel();
|
||||||
|
|
||||||
let orientation = match obj.page_setup().orientation() {
|
let orientation = match obj.page_setup().orientation() {
|
||||||
|
|
@ -902,3 +916,15 @@ extern "C" {
|
||||||
max: std::ffi::c_double,
|
max: std::ffi::c_double,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Upstream to gettext if possible
|
||||||
|
pub fn getlocale(category: gettextrs::LocaleCategory) -> Option<Vec<u8>> {
|
||||||
|
unsafe {
|
||||||
|
let ret = gettext_sys::setlocale(category as i32, std::ptr::null());
|
||||||
|
if ret.is_null() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(std::ffi::CStr::from_ptr(ret).to_bytes().to_owned())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue