feat(printers): types de papier et mode de couleur par defaut
Le tiroir de details expose desormais MediaType et ColorModel en plus de PageSize, cupsPrintQuality et Duplex, avec des libellets localises pour les valeurs usuelles (papier ordinaire, photo brillante/mate/satinee, couleur, niveaux de gris...). Persiste via lpadmin -o comme les autres options.
This commit is contained in:
parent
8d528f9e45
commit
c2c7d9ccb1
4 changed files with 157 additions and 1 deletions
|
|
@ -203,11 +203,16 @@ pub async fn remove_printer(name: &str) -> Result<(), String> {
|
|||
/// Default job options supported by a queue, with their current values.
|
||||
///
|
||||
/// Values are taken from the queue's PPD view (`lpoptions -l`): `PageSize`,
|
||||
/// `cupsPrintQuality` and `Duplex`, which `lpadmin -o` can persist.
|
||||
/// `MediaType`, `ColorModel`, `cupsPrintQuality` and `Duplex`, which
|
||||
/// `lpadmin -o` can persist.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct PrinterOptions {
|
||||
pub media: Vec<String>,
|
||||
pub media_default: Option<String>,
|
||||
pub media_types: Vec<String>,
|
||||
pub media_type_default: Option<String>,
|
||||
pub color_models: Vec<String>,
|
||||
pub color_model_default: Option<String>,
|
||||
pub qualities: Vec<String>,
|
||||
pub quality_default: Option<String>,
|
||||
pub sides: Vec<String>,
|
||||
|
|
@ -237,6 +242,8 @@ pub async fn printer_options(name: &str) -> Result<PrinterOptions, String> {
|
|||
|
||||
let (list, default) = match key {
|
||||
"PageSize" => (&mut options.media, &mut options.media_default),
|
||||
"MediaType" => (&mut options.media_types, &mut options.media_type_default),
|
||||
"ColorModel" => (&mut options.color_models, &mut options.color_model_default),
|
||||
"cupsPrintQuality" => (&mut options.qualities, &mut options.quality_default),
|
||||
"Duplex" => (&mut options.sides, &mut options.sides_default),
|
||||
_ => continue,
|
||||
|
|
|
|||
|
|
@ -129,6 +129,41 @@ fn quality_label(value: &str) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn media_type_label(value: &str) -> String {
|
||||
match value {
|
||||
"Stationery" => fl!("printers-media-type-stationery"),
|
||||
"Photographic" => fl!("printers-media-type-photographic"),
|
||||
"PhotographicGlossy" => fl!("printers-media-type-photographic-glossy"),
|
||||
"PhotographicMatte" => fl!("printers-media-type-photographic-matte"),
|
||||
"PhotographicSatin" => fl!("printers-media-type-photographic-satin"),
|
||||
"StationeryCoated" => fl!("printers-media-type-stationery-coated"),
|
||||
"StationeryFine" => fl!("printers-media-type-stationery-fine"),
|
||||
"StationeryInkjet" => fl!("printers-media-type-stationery-inkjet"),
|
||||
"StationeryLetterhead" => fl!("printers-media-type-stationery-letterhead"),
|
||||
"StationeryPreprint" => fl!("printers-media-type-stationery-preprint"),
|
||||
"StationeryRecycled" => fl!("printers-media-type-stationery-recycled"),
|
||||
"Envelope" => fl!("printers-media-type-envelope"),
|
||||
"Transparency" => fl!("printers-media-type-transparency"),
|
||||
"Labels" => fl!("printers-media-type-labels"),
|
||||
"Cardstock" => fl!("printers-media-type-cardstock"),
|
||||
_ => value.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
fn color_model_label(value: &str) -> String {
|
||||
match value {
|
||||
"RGB" => fl!("printers-color-rgb"),
|
||||
"RGB16" => fl!("printers-color-rgb-16"),
|
||||
"RGB24" => fl!("printers-color-rgb-24"),
|
||||
"RGB48" => fl!("printers-color-rgb-48"),
|
||||
"Gray" | "KGray" => fl!("printers-color-gray"),
|
||||
"CMYK" => fl!("printers-color-cmyk"),
|
||||
"CMY" => fl!("printers-color-cmy"),
|
||||
"Black" => fl!("printers-color-black"),
|
||||
_ => value.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
fn sides_label(value: &str) -> String {
|
||||
match value {
|
||||
"None" => fl!("printers-sides-one-sided"),
|
||||
|
|
@ -551,6 +586,8 @@ impl Page {
|
|||
if let Some((options_name, options)) = self.options.as_ref()
|
||||
&& options_name == &printer.name
|
||||
&& (!options.media.is_empty()
|
||||
|| !options.media_types.is_empty()
|
||||
|| !options.color_models.is_empty()
|
||||
|| !options.qualities.is_empty()
|
||||
|| !options.sides.is_empty())
|
||||
{
|
||||
|
|
@ -589,6 +626,68 @@ impl Page {
|
|||
);
|
||||
}
|
||||
|
||||
if !options.media_types.is_empty() {
|
||||
let values = options.media_types.clone();
|
||||
let selected = options
|
||||
.media_type_default
|
||||
.as_ref()
|
||||
.and_then(|default| values.iter().position(|value| value == default));
|
||||
let labels: Vec<String> = values.iter().map(|v| media_type_label(v)).collect();
|
||||
let name = printer.name.clone();
|
||||
|
||||
list = list.add(
|
||||
widget::settings::item::builder(fl!("printers-option-media-type")).control(
|
||||
widget::dropdown::popup_dropdown(
|
||||
labels,
|
||||
selected,
|
||||
move |index| Message::SetOption {
|
||||
printer: name.clone(),
|
||||
option: "MediaType".to_string(),
|
||||
value: values.get(index).cloned().unwrap_or_default(),
|
||||
},
|
||||
cosmic::iced::window::Id::RESERVED,
|
||||
Message::Surface,
|
||||
|action| {
|
||||
crate::app::Message::PageMessage(
|
||||
crate::pages::Message::Printers(action),
|
||||
)
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if !options.color_models.is_empty() {
|
||||
let values = options.color_models.clone();
|
||||
let selected = options
|
||||
.color_model_default
|
||||
.as_ref()
|
||||
.and_then(|default| values.iter().position(|value| value == default));
|
||||
let labels: Vec<String> = values.iter().map(|v| color_model_label(v)).collect();
|
||||
let name = printer.name.clone();
|
||||
|
||||
list = list.add(
|
||||
widget::settings::item::builder(fl!("printers-option-color")).control(
|
||||
widget::dropdown::popup_dropdown(
|
||||
labels,
|
||||
selected,
|
||||
move |index| Message::SetOption {
|
||||
printer: name.clone(),
|
||||
option: "ColorModel".to_string(),
|
||||
value: values.get(index).cloned().unwrap_or_default(),
|
||||
},
|
||||
cosmic::iced::window::Id::RESERVED,
|
||||
Message::Surface,
|
||||
|action| {
|
||||
crate::app::Message::PageMessage(
|
||||
crate::pages::Message::Printers(action),
|
||||
)
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if !options.qualities.is_empty() {
|
||||
let values = options.qualities.clone();
|
||||
let selected = options
|
||||
|
|
|
|||
25
i18n/en/cosmic_settings.ftl
vendored
25
i18n/en/cosmic_settings.ftl
vendored
|
|
@ -649,6 +649,14 @@ printers-add = Add printer
|
|||
printers-add-in-progress = Adding printer…
|
||||
printers-added = Printer “{ $name }” added
|
||||
printers-cancel-job = Cancel job
|
||||
printers-color-black = Black
|
||||
printers-color-cmy = CMY
|
||||
printers-color-cmyk = CMYK
|
||||
printers-color-gray = Grayscale
|
||||
printers-color-rgb = Color
|
||||
printers-color-rgb-16 = Color (16-bit)
|
||||
printers-color-rgb-24 = Color (24-bit)
|
||||
printers-color-rgb-48 = Color (48-bit)
|
||||
printers-default = Default
|
||||
printers-details = Printer details
|
||||
printers-device = Device
|
||||
|
|
@ -667,13 +675,30 @@ printers-jobs = Print jobs
|
|||
printers-loading = Searching for devices…
|
||||
printers-location = Location
|
||||
printers-make-default = Set as default
|
||||
printers-media-type-cardstock = Cardstock
|
||||
printers-media-type-envelope = Envelope
|
||||
printers-media-type-labels = Labels
|
||||
printers-media-type-photographic = Photo paper
|
||||
printers-media-type-photographic-glossy = Glossy photo paper
|
||||
printers-media-type-photographic-matte = Matte photo paper
|
||||
printers-media-type-photographic-satin = Satin photo paper
|
||||
printers-media-type-stationery = Plain paper
|
||||
printers-media-type-stationery-coated = Coated paper
|
||||
printers-media-type-stationery-fine = Fine paper
|
||||
printers-media-type-stationery-inkjet = Inkjet paper
|
||||
printers-media-type-stationery-letterhead = Letterhead paper
|
||||
printers-media-type-stationery-preprint = Preprinted paper
|
||||
printers-media-type-stationery-recycled = Recycled paper
|
||||
printers-media-type-transparency = Transparency
|
||||
printers-name = Name
|
||||
printers-no-devices = No devices found
|
||||
printers-no-matching-drivers = No matching drivers
|
||||
printers-no-printers = No printers configured
|
||||
printers-no-printers-desc = Printers connected to this computer or discovered on the network will appear here.
|
||||
printers-not-accepting = Not accepting jobs
|
||||
printers-option-color = Color mode
|
||||
printers-option-media = Paper format
|
||||
printers-option-media-type = Paper type
|
||||
printers-option-quality = Print quality
|
||||
printers-option-sides = Two-sided printing
|
||||
printers-options = Print options
|
||||
|
|
|
|||
25
i18n/fr/cosmic_settings.ftl
vendored
25
i18n/fr/cosmic_settings.ftl
vendored
|
|
@ -437,6 +437,14 @@ printers-add = Ajouter une imprimante
|
|||
printers-add-in-progress = Ajout de l'imprimante…
|
||||
printers-added = Imprimante « { $name } » ajoutée
|
||||
printers-cancel-job = Annuler le travail
|
||||
printers-color-black = Noir
|
||||
printers-color-cmy = CMJ
|
||||
printers-color-cmyk = CMJN
|
||||
printers-color-gray = Niveaux de gris
|
||||
printers-color-rgb = Couleur
|
||||
printers-color-rgb-16 = Couleur (16 bits)
|
||||
printers-color-rgb-24 = Couleur (24 bits)
|
||||
printers-color-rgb-48 = Couleur (48 bits)
|
||||
printers-default = Par défaut
|
||||
printers-details = Détails de l'imprimante
|
||||
printers-device = Périphérique
|
||||
|
|
@ -455,13 +463,30 @@ printers-jobs = Travaux d'impression
|
|||
printers-loading = Recherche des périphériques…
|
||||
printers-location = Emplacement
|
||||
printers-make-default = Définir par défaut
|
||||
printers-media-type-cardstock = Papier cartonné
|
||||
printers-media-type-envelope = Enveloppe
|
||||
printers-media-type-labels = Étiquettes
|
||||
printers-media-type-photographic = Papier photo
|
||||
printers-media-type-photographic-glossy = Papier photo brillant
|
||||
printers-media-type-photographic-matte = Papier photo mat
|
||||
printers-media-type-photographic-satin = Papier photo satiné
|
||||
printers-media-type-stationery = Papier ordinaire
|
||||
printers-media-type-stationery-coated = Papier couché
|
||||
printers-media-type-stationery-fine = Papier fin
|
||||
printers-media-type-stationery-inkjet = Papier jet d'encre
|
||||
printers-media-type-stationery-letterhead = Papier à en-tête
|
||||
printers-media-type-stationery-preprint = Papier pré-imprimé
|
||||
printers-media-type-stationery-recycled = Papier recyclé
|
||||
printers-media-type-transparency = Transparent
|
||||
printers-name = Nom
|
||||
printers-no-devices = Aucun périphérique trouvé
|
||||
printers-no-matching-drivers = Aucun pilote ne correspond
|
||||
printers-no-printers = Aucune imprimante configurée
|
||||
printers-no-printers-desc = Les imprimantes connectées à cet ordinateur ou découvertes sur le réseau apparaîtront ici.
|
||||
printers-not-accepting = N'accepte pas les travaux
|
||||
printers-option-color = Mode de couleur
|
||||
printers-option-media = Format du papier
|
||||
printers-option-media-type = Type de papier
|
||||
printers-option-quality = Qualité d'impression
|
||||
printers-option-sides = Impression recto-verso
|
||||
printers-options = Options d'impression
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue