DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
File › Package: InDesign's Package dialog and Printing Instructions
paaspaas00d21459ff3ea1
diff --git a/ROADMAP.md b/ROADMAP.mdindex a7b5105d3..b0e33a381 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -348,6 +348,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.mNewest first.+- **2026-10-21** · File › Package… opens InDesign's Package dialog: Summary counts the fonts, links and images and inks the package carries, with a warning where some are missing or modified, and Fonts, Links and Images and Colors and Inks list them (Show Problems Only). Create Printing Instructions asks for the contact details and instructions that go into the package's Instructions.txt, and Include IDML / Include PDF (Print) choose the copies it carries. Package… went straight to the folder picker with fixed options. Found in the Learn Skills Daily course, chapter 27. No readiness percentage change.- **2026-10-16** · Type › Reload Fonts (`font.reload`): fonts installed, edited or removed while DesignCraft runs are read again without a restart, and the open documents recompose with them (#328, #547). An edited font file is noticed by its length and modification time; bundled, added and document fonts stay as they are. InDesign does this by itself, so noticing changes automatically is still open (gap 6). No readiness percentage change.- **2026-10-16** · Parents can be deleted from their Pages-panel context menu or `layout.parents.delete {id}`. Applied-page and based-on references are cleared, local override copies survive, and Undo restores the parent. Addresses the deletion portion of #956; no readiness percentage change.- **2026-10-17** · File › Package writes the document's and the IDML's links relative to the package (`Links/logo.png`, `file:Links/logo.png`), so a package holds no path from the machine that made it; opening a document resolves them to the files beside it. Links › Copy Link(s) To still links by full path. (#340). No readiness percentage change.diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rsindex 8b4043787..9182f5843 100644--- a/crates/ui-egui/src/dialogs.rs+++ b/crates/ui-egui/src/dialogs.rs@@ -2087,6 +2087,8 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {"colorGroupOptions" => crate::i18n::tr(&app.ui.language, "Color Group Options"),"layerSettings" => crate::i18n::tr(&app.ui.language, "Layer Options"),crate::effects_dialog::ID => crate::i18n::tr(&app.ui.language, "Effects"),+ crate::package_dialog::ID => crate::i18n::tr(&app.ui.language, "Package"),+ crate::package_dialog::INSTRUCTIONS => crate::i18n::tr(&app.ui.language, "Printing Instructions"),id => match id.strip_prefix("cmd:").and_then(designcraft_engine::find_command) {Some(c) => crate::i18n::tr(&app.ui.language, c.label.trim_end_matches('…')),None => crate::i18n::tr(&app.ui.language, "Dialog"),@@ -2104,6 +2106,8 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {"newDocument" => 960.0,"numberingSection" => 560.0,crate::effects_dialog::ID => 720.0,+ crate::package_dialog::ID => 720.0,+ crate::package_dialog::INSTRUCTIONS => 520.0,_ => 640.0,};let width = preferred_width.min(available.x);@@ -2361,6 +2365,8 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {"colorGroupOptions" => options::color_group_options(app, ui, &mut d),"layerSettings" => options::layer_options(app, ui, &mut d),crate::effects_dialog::ID => crate::effects_dialog::show(app, ui, &mut d),+ crate::package_dialog::ID => crate::package_dialog::show(app, ui, &mut d),+ crate::package_dialog::INSTRUCTIONS => crate::package_dialog::show_instructions(app, ui, &mut d),"preferences" => preferences(app, ui, &mut d, body_height),"print" => print_dialog(app, ui, &mut d),"pdfImport" => {@@ -2819,6 +2825,8 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {"updateLink" => crate::i18n::tr(&app.ui.language, " Update ").to_string(),"findFont" => crate::i18n::tr(&app.ui.language, "Replace All").to_string(),"newDocument" => format!(" {} ", crate::i18n::tr(&app.ui.language, "Create")),+ crate::package_dialog::ID => crate::i18n::tr(&app.ui.language, "Package…").to_string(),+ crate::package_dialog::INSTRUCTIONS => crate::i18n::tr(&app.ui.language, "Continue").to_string(),_ => crate::i18n::tr(&app.ui.language, " OK ").to_string(),};let cancel_label = match d.id.as_str() {@@ -3573,6 +3581,8 @@ pub fn confirm(app: &mut DesignApp) -> Result<Value, String> {}"alert" => Ok(Value::Null),crate::effects_dialog::ID => crate::effects_dialog::confirm(app, &d),+ crate::package_dialog::ID => crate::package_dialog::confirm(app, &d),+ crate::package_dialog::INSTRUCTIONS => crate::package_dialog::confirm_instructions(app, &d),"findChange" => {let result = if d.b("objectMode") { Ok(Value::Null) } else { app.run("find.change", find_change_params(&d)) };// Confirmation consumes retained bounds before closing, even on an error.diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rsindex efe089ef9..eccf6ca89 100644--- a/crates/ui-egui/src/i18n.rs+++ b/crates/ui-egui/src/i18n.rs@@ -83,6 +83,91 @@ const TABLE: &[(&str, [&str; 5])] = &[("Print…", ["Drucken …", "Imprimer…", "Imprimir…", "プリント…", "打印…"]),("Document Setup…", ["Dokument einrichten …", "Format de document…", "Ajustar documento…", "ドキュメント設定…", "文档设置…"]),("Package…", ["Verpacken …", "Assemblage…", "Empaquetar…", "パッケージ…", "打包…"]),+ ("Summary", ["Übersicht", "Résumé", "Resumen", "概要", "摘要"]),+ ("Fonts", ["Schriften", "Polices", "Fuentes", "フォント", "字体"]),+ ("Links and Images", ["Verknüpfungen und Bilder", "Liens et images", "Vínculos e imágenes", "リンクと画像", "链接和图像"]),+ ("Colors and Inks", ["Farben und Druckfarben", "Couleurs et encres", "Colores y tintas", "カラーとインキ", "颜色和油墨"]),+ ("Process Cyan", ["Prozess-Cyan", "Cyan quadri", "Cian de cuatricromía", "プロセスシアン", "印刷青色"]),+ ("Process Magenta", ["Prozess-Magenta", "Magenta quadri", "Magenta de cuatricromía", "プロセスマゼンタ", "印刷洋红色"]),+ ("Process Yellow", ["Prozess-Gelb", "Jaune quadri", "Amarillo de cuatricromía", "プロセスイエロー", "印刷黄色"]),+ ("Process Black", ["Prozess-Schwarz", "Noir quadri", "Negro de cuatricromía", "プロセスブラック", "印刷黑色"]),+ ("Contact:", ["Kontakt:", "Contact :", "Contacto:", "連絡先:", "联系人:"]),+ ("Company:", ["Firma:", "Société :", "Empresa:", "会社名:", "公司:"]),+ ("Address:", ["Adresse:", "Adresse :", "Dirección:", "住所:", "地址:"]),+ ("Phone:", ["Telefon:", "Téléphone :", "Teléfono:", "電話:", "电话:"]),+ ("Fax:", ["Fax:", "Fax :", "Fax:", "FAX:", "传真:"]),+ ("Email:", ["E-Mail:", "E-mail :", "Correo electrónico:", "メール:", "电子邮件:"]),+ ("Instructions:", ["Anweisungen:", "Instructions :", "Instrucciones:", "指示:", "说明:"]),+ (+ "Fonts: {used} Fonts Used, {missing} Missing",+ [+ "Schriften: {used} verwendet, {missing} fehlen",+ "Polices : {used} utilisées, {missing} manquantes",+ "Fuentes: {used} utilizadas, {missing} ausentes",+ "フォント : {used} 個使用、{missing} 個見つかりません",+ "字体:使用 {used} 种,缺失 {missing} 种",+ ],+ ),+ (+ "Links and Images: {found} Links Found; {modified} Modified, {missing} Missing",+ [+ "Verknüpfungen und Bilder: {found} gefunden; {modified} geändert, {missing} fehlen",+ "Liens et images : {found} liens trouvés ; {modified} modifiés, {missing} manquants",+ "Vínculos e imágenes: {found} vínculos encontrados; {modified} modificados, {missing} ausentes",+ "リンクと画像 : {found} 個のリンク、{modified} 個変更、{missing} 個見つかりません",+ "链接和图像:找到 {found} 个链接;{modified} 个已修改,{missing} 个缺失",+ ],+ ),+ (+ "Images: {embedded} Embedded",+ [+ "Bilder: {embedded} eingebettet",+ "Images : {embedded} incorporées",+ "Imágenes: {embedded} incrustadas",+ "画像 : {embedded} 個埋め込み",+ "图像:嵌入 {embedded} 个",+ ],+ ),+ (+ "Colors and Inks: {process} Process Inks; {spot} Spot Inks",+ [+ "Farben und Druckfarben: {process} Prozessfarben; {spot} Volltonfarben",+ "Couleurs et encres : {process} encres quadri ; {spot} encres d’accompagnement",+ "Colores y tintas: {process} tintas de cuatricromía; {spot} tintas planas",+ "カラーとインキ : プロセスインキ {process} 個、スポットインキ {spot} 個",+ "颜色和油墨:{process} 种印刷色油墨;{spot} 种专色油墨",+ ],+ ),+ ("Missing", ["Fehlt", "Manquant", "Ausente", "見つかりません", "缺失"]),+ ("Modified", ["Geändert", "Modifié", "Modificado", "変更", "已修改"]),+ ("Substituted", ["Ersetzt", "Remplacée", "Sustituida", "代替", "已替换"]),+ ("Bundled", ["Mitgeliefert", "Fournie", "Incluida", "同梱", "内置"]),+ ("Installed", ["Installiert", "Installée", "Instalada", "インストール済み", "已安装"]),+ ("Source", ["Quelle", "Source", "Origen", "ソース", "来源"]),+ ("Scope:", ["Bereich:", "Étendue :", "Ámbito:", "範囲:", "范围:"]),+ ("Entire Publication", ["Gesamte Publikation", "Publication entière", "Toda la publicación", "出版物全体", "整个出版物"]),+ (+ "Create Printing Instructions",+ ["Druckanweisungen erstellen", "Créer des instructions d’impression", "Crear instrucciones de impresión", "印刷指示を作成", "创建打印说明"],+ ),+ ("Include IDML", ["IDML einschließen", "Inclure l’IDML", "Incluir IDML", "IDML を含める", "包括 IDML"]),+ (+ "Include PDF (Print)",+ ["PDF einschließen (Druck)", "Inclure le PDF (impression)", "Incluir PDF (impresión)", "PDF を含める(印刷)", "包括 PDF(打印)"],+ ),+ ("Show Problems Only", ["Nur Probleme anzeigen", "Afficher uniquement les problèmes", "Mostrar solo problemas", "問題のみ表示", "仅显示问题"]),+ ("Printing Instructions", ["Druckanweisungen", "Instructions d’impression", "Instrucciones de impresión", "印刷指示", "打印说明"]),+ ("Continue", ["Weiter", "Continuer", "Continuar", "続行", "继续"]),+ (+ "Packaged {count} files into {dir}",+ [+ "{count} Dateien in {dir} verpackt",+ "{count} fichiers assemblés dans {dir}",+ "{count} archivos empaquetados en {dir}",+ "{count} 個のファイルを {dir} にパッケージしました",+ "已将 {count} 个文件打包到 {dir}",+ ],+ ),// Edit.("Undo", ["Rückgängig", "Annuler", "Deshacer", "取り消し", "还原"]),("Redo", ["Wiederholen", "Rétablir", "Rehacer", "やり直し", "重做"]),diff --git a/crates/ui-egui/src/i18n/ar.rs b/crates/ui-egui/src/i18n/ar.rsindex b050de38b..268b799d1 100644--- a/crates/ui-egui/src/i18n/ar.rs+++ b/crates/ui-egui/src/i18n/ar.rs@@ -30,6 +30,43 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "قص"),("Copy", "نسخ"),("Paste", "لصق"),+ ("Packaged {count} files into {dir}", "تم حزم {count} ملفات في {dir}"),+ ("Continue", "متابعة"),+ ("Printing Instructions", "تعليمات الطباعة"),+ ("Show Problems Only", "إظهار المشكلات فقط"),+ ("Include PDF (Print)", "تضمين PDF (للطباعة)"),+ ("Include IDML", "تضمين IDML"),+ ("Create Printing Instructions", "إنشاء تعليمات الطباعة"),+ ("Entire Publication", "المنشور بالكامل"),+ ("Scope:", "النطاق:"),+ ("Source", "المصدر"),+ ("Installed", "مثبت"),+ ("Bundled", "مضمن مع التطبيق"),+ ("Substituted", "مستبدل"),+ ("Modified", "معدل"),+ ("Missing", "مفقود"),+ ("Colors and Inks: {process} Process Inks; {spot} Spot Inks", "الألوان والأحبار: {process} أحبار معالجة؛ {spot} أحبار مخصصة"),+ ("Images: {embedded} Embedded", "الصور: {embedded} مضمنة"),+ (+ "Links and Images: {found} Links Found; {modified} Modified, {missing} Missing",+ "الروابط والصور: {found} روابط؛ {modified} معدلة، {missing} مفقودة",+ ),+ ("Fonts: {used} Fonts Used, {missing} Missing", "الخطوط: {used} مستخدمة، {missing} مفقودة"),+ ("Instructions:", "التعليمات:"),+ ("Email:", "البريد الإلكتروني:"),+ ("Fax:", "الفاكس:"),+ ("Phone:", "الهاتف:"),+ ("Address:", "العنوان:"),+ ("Company:", "الشركة:"),+ ("Contact:", "جهة الاتصال:"),+ ("Process Black", "أسود معالجة"),+ ("Process Yellow", "أصفر معالجة"),+ ("Process Magenta", "أرجواني معالجة"),+ ("Process Cyan", "سماوي معالجة"),+ ("Colors and Inks", "الألوان والأحبار"),+ ("Links and Images", "الروابط والصور"),+ ("Fonts", "الخطوط"),+ ("Summary", "الملخص"),("Paste Vector Art", "لصق رسم متجه"),("Baseline Options", "خيارات خط الأساس"),("Fixed Number", "عدد ثابت"),diff --git a/crates/ui-egui/src/i18n/cs.rs b/crates/ui-egui/src/i18n/cs.rsindex e77e72a1c..a51121541 100644--- a/crates/ui-egui/src/i18n/cs.rs+++ b/crates/ui-egui/src/i18n/cs.rs@@ -31,6 +31,42 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Vyjmout"),("Copy", "Kopírovat"),("Paste", "Vložit"),+ ("Continue", "Pokračovat"),+ ("Printing Instructions", "Pokyny k tisku"),+ ("Show Problems Only", "Zobrazit jen problémy"),+ ("Include PDF (Print)", "Zahrnout PDF (tisk)"),+ ("Include IDML", "Zahrnout IDML"),+ ("Create Printing Instructions", "Vytvořit pokyny k tisku"),+ ("Entire Publication", "Celá publikace"),+ ("Scope:", "Rozsah:"),+ ("Spot", "Přímá"),+ ("Process", "Procesní"),+ ("Source", "Zdroj"),+ ("Installed", "Nainstalováno"),+ ("Bundled", "Přibaleno"),+ ("Substituted", "Nahrazeno"),+ ("Modified", "Změněno"),+ ("Missing", "Chybí"),+ ("Colors and Inks: {process} Process Inks; {spot} Spot Inks", "Barvy a inkousty: procesní {process}; přímé {spot}"),+ ("Images: {embedded} Embedded", "Obrazy: vloženo {embedded}"),+ (+ "Links and Images: {found} Links Found; {modified} Modified, {missing} Missing",+ "Odkazy a obrazy: nalezeno {found}; změněno {modified}, chybí {missing}",+ ),+ ("Fonts: {used} Fonts Used, {missing} Missing", "Písma: použito {used}, chybí {missing}"),+ ("Instructions:", "Pokyny:"),+ ("Fax:", "Fax:"),+ ("Address:", "Adresa:"),+ ("Company:", "Společnost:"),+ ("Contact:", "Kontakt:"),+ ("Process Black", "Procesní černá"),+ ("Process Yellow", "Procesní žlutá"),+ ("Process Magenta", "Procesní purpurová"),+ ("Process Cyan", "Procesní azurová"),+ ("Colors and Inks", "Barvy a inkousty"),+ ("Links and Images", "Odkazy a obrazy"),+ ("Fonts", "Písma"),+ ("Summary", "Souhrn"),("Reverse Path", "Obrátit cestu"),("Set Anchor", "Nastavit kotvu"),("Clear", "Vymazat"),diff --git a/crates/ui-egui/src/i18n/it.rs b/crates/ui-egui/src/i18n/it.rsindex a918a9829..0d0d49112 100644--- a/crates/ui-egui/src/i18n/it.rs+++ b/crates/ui-egui/src/i18n/it.rs@@ -28,6 +28,44 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Taglia"),("Copy", "Copia"),("Paste", "Incolla"),+ ("Packaged {count} files into {dir}", "{count} file raccolti in {dir}"),+ ("Continue", "Continua"),+ ("Printing Instructions", "Istruzioni di stampa"),+ ("Package", "Pacchetto"),+ ("Show Problems Only", "Mostra solo problemi"),+ ("Include PDF (Print)", "Includi PDF (stampa)"),+ ("Include IDML", "Includi IDML"),+ ("Create Printing Instructions", "Crea istruzioni di stampa"),+ ("Entire Publication", "Intera pubblicazione"),+ ("Scope:", "Ambito:"),+ ("Source", "Origine"),+ ("Installed", "Installato"),+ ("Bundled", "Incluso"),+ ("Substituted", "Sostituito"),+ ("Modified", "Modificato"),+ ("Missing", "Mancante"),+ ("Colors and Inks: {process} Process Inks; {spot} Spot Inks", "Colori e inchiostri: {process} quadricromia; {spot} tinte piatte"),+ ("Images: {embedded} Embedded", "Immagini: {embedded} incorporate"),+ (+ "Links and Images: {found} Links Found; {modified} Modified, {missing} Missing",+ "Collegamenti e immagini: {found} trovati; {modified} modificati, {missing} mancanti",+ ),+ ("Fonts: {used} Fonts Used, {missing} Missing", "Font: {used} utilizzati, {missing} mancanti"),+ ("Instructions:", "Istruzioni:"),+ ("Email:", "E-mail:"),+ ("Fax:", "Fax:"),+ ("Phone:", "Telefono:"),+ ("Address:", "Indirizzo:"),+ ("Company:", "Società:"),+ ("Contact:", "Contatto:"),+ ("Process Black", "Nero quadricromia"),+ ("Process Yellow", "Giallo quadricromia"),+ ("Process Magenta", "Magenta quadricromia"),+ ("Process Cyan", "Cyan quadricromia"),+ ("Colors and Inks", "Colori e inchiostri"),+ ("Links and Images", "Collegamenti e immagini"),+ ("Fonts", "Font"),+ ("Summary", "Riepilogo"),("Paste Vector Art", "Incolla grafica vettoriale"),("Baseline Options", "Opzioni linea di base"),("Fixed Number", "Numero fisso"),diff --git a/crates/ui-egui/src/i18n/ka.rs b/crates/ui-egui/src/i18n/ka.rsindex d938c2dc7..142f806ac 100644--- a/crates/ui-egui/src/i18n/ka.rs+++ b/crates/ui-egui/src/i18n/ka.rs@@ -31,6 +31,45 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "ამოჭრა"),("Copy", "კოპირება"),("Paste", "ჩასმა"),+ ("Packaged {count} files into {dir}", "{count} ფაილი შეიფუთა {dir}-ში"),+ ("Continue", "გაგრძელება"),+ ("Printing Instructions", "ბეჭდვის ინსტრუქციები"),+ ("Show Problems Only", "მხოლოდ პრობლემების ჩვენება"),+ ("Include PDF (Print)", "PDF-ის ჩართვა (ბეჭდვა)"),+ ("Include IDML", "IDML-ის ჩართვა"),+ ("Create Printing Instructions", "ბეჭდვის ინსტრუქციების შექმნა"),+ ("Entire Publication", "მთელი პუბლიკაცია"),+ ("Scope:", "არეალი:"),+ ("Spot", "ლაქა"),+ ("Process", "პროცესი"),+ ("Source", "წყარო"),+ ("Installed", "დაყენებული"),+ ("Bundled", "ჩაშენებული"),+ ("Substituted", "ჩანაცვლებული"),+ ("Modified", "შეცვლილი"),+ ("Missing", "აკლია"),+ ("Colors and Inks: {process} Process Inks; {spot} Spot Inks", "ფერები და მელნები: {process} პროცესის; {spot} ლაქის"),+ ("Images: {embedded} Embedded", "გამოსახულებები: ჩაშენებულია {embedded}"),+ (+ "Links and Images: {found} Links Found; {modified} Modified, {missing} Missing",+ "ბმულები და გამოსახულებები: ნაპოვნია {found}; შეცვლილია {modified}, აკლია {missing}",+ ),+ ("Fonts: {used} Fonts Used, {missing} Missing", "შრიფტები: გამოყენებულია {used}, აკლია {missing}"),+ ("Instructions:", "ინსტრუქციები:"),+ ("Email:", "ელფოსტა:"),+ ("Fax:", "ფაქსი:"),+ ("Phone:", "ტელეფონი:"),+ ("Address:", "მისამართი:"),+ ("Company:", "კომპანია:"),+ ("Contact:", "საკონტაქტო პირი:"),+ ("Process Black", "პროცესის შავი"),+ ("Process Yellow", "პროცესის ყვითელი"),+ ("Process Magenta", "პროცესის მეწამული"),+ ("Process Cyan", "პროცესის ცისფერი"),+ ("Colors and Inks", "ფერები და მელნები"),+ ("Links and Images", "ბმულები და გამოსახულებები"),+ ("Fonts", "შრიფტები"),+ ("Summary", "შეჯამება"),("Inches Decimal", "ინჩები (ათობითი)"),("Back", "უკან"),("Warning", "გაფრთხილება"),diff --git a/crates/ui-egui/src/i18n/pl.rs b/crates/ui-egui/src/i18n/pl.rsindex 68d685d99..ca8c99e33 100644--- a/crates/ui-egui/src/i18n/pl.rs+++ b/crates/ui-egui/src/i18n/pl.rs@@ -29,6 +29,45 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Wytnij"),("Copy", "Kopiuj"),("Paste", "Wklej"),+ ("Packaged {count} files into {dir}", "Spakowano {count} plików do {dir}"),+ ("Continue", "Kontynuuj"),+ ("Printing Instructions", "Instrukcje drukowania"),+ ("Show Problems Only", "Pokaż tylko problemy"),+ ("Include PDF (Print)", "Dołącz PDF (druk)"),+ ("Include IDML", "Dołącz IDML"),+ ("Create Printing Instructions", "Utwórz instrukcje drukowania"),+ ("Entire Publication", "Cała publikacja"),+ ("Scope:", "Zakres:"),+ ("Spot", "Dodatkowy"),+ ("Process", "Procesowy"),+ ("Source", "Źródło"),+ ("Installed", "Zainstalowana"),+ ("Bundled", "Dołączona"),+ ("Substituted", "Zastąpiona"),+ ("Modified", "Zmieniony"),+ ("Missing", "Brak"),+ ("Colors and Inks: {process} Process Inks; {spot} Spot Inks", "Kolory i farby: procesowe {process}; dodatkowe {spot}"),+ ("Images: {embedded} Embedded", "Obrazy: osadzone {embedded}"),+ (+ "Links and Images: {found} Links Found; {modified} Modified, {missing} Missing",+ "Łącza i obrazy: znaleziono {found}; zmienione {modified}, brakujące {missing}",+ ),+ ("Fonts: {used} Fonts Used, {missing} Missing", "Czcionki: użyte {used}, brakujące {missing}"),+ ("Instructions:", "Instrukcje:"),+ ("Email:", "E-mail:"),+ ("Fax:", "Faks:"),+ ("Phone:", "Telefon:"),+ ("Address:", "Adres:"),+ ("Company:", "Firma:"),+ ("Contact:", "Kontakt:"),+ ("Process Black", "Czarny procesowy"),+ ("Process Yellow", "Żółty procesowy"),+ ("Process Magenta", "Magenta procesowa"),+ ("Process Cyan", "Cyjan procesowy"),+ ("Colors and Inks", "Kolory i farby"),+ ("Links and Images", "Łącza i obrazy"),+ ("Fonts", "Czcionki"),+ ("Summary", "Podsumowanie"),("Clear", "Wyczyść"),("Duplicate", "Powiel"),("Select All", "Zaznacz wszystko"),diff --git a/crates/ui-egui/src/i18n/pt_br.rs b/crates/ui-egui/src/i18n/pt_br.rsindex 8521de594..9c4317506 100644--- a/crates/ui-egui/src/i18n/pt_br.rs+++ b/crates/ui-egui/src/i18n/pt_br.rs@@ -31,6 +31,44 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Recortar"),("Copy", "Copiar"),("Paste", "Colar"),+ ("Packaged {count} files into {dir}", "{count} arquivos empacotados em {dir}"),+ ("Continue", "Continuar"),+ ("Printing Instructions", "Instruções de impressão"),+ ("Package", "Empacotar"),+ ("Show Problems Only", "Mostrar apenas problemas"),+ ("Include PDF (Print)", "Incluir PDF (impressão)"),+ ("Include IDML", "Incluir IDML"),+ ("Create Printing Instructions", "Criar instruções de impressão"),+ ("Entire Publication", "Publicação inteira"),+ ("Scope:", "Escopo:"),+ ("Source", "Origem"),+ ("Installed", "Instalada"),+ ("Bundled", "Incluída"),+ ("Substituted", "Substituída"),+ ("Modified", "Modificado"),+ ("Missing", "Ausente"),+ ("Colors and Inks: {process} Process Inks; {spot} Spot Inks", "Cores e tintas: {process} de escala; {spot} especiais"),+ ("Images: {embedded} Embedded", "Imagens: {embedded} incorporadas"),+ (+ "Links and Images: {found} Links Found; {modified} Modified, {missing} Missing",+ "Vínculos e imagens: {found} encontrados; {modified} modificados, {missing} ausentes",+ ),+ ("Fonts: {used} Fonts Used, {missing} Missing", "Fontes: {used} usadas, {missing} ausentes"),+ ("Instructions:", "Instruções:"),+ ("Email:", "E-mail:"),+ ("Fax:", "Fax:"),+ ("Phone:", "Telefone:"),+ ("Address:", "Endereço:"),+ ("Company:", "Empresa:"),+ ("Contact:", "Contato:"),+ ("Process Black", "Preto de escala"),+ ("Process Yellow", "Amarelo de escala"),+ ("Process Magenta", "Magenta de escala"),+ ("Process Cyan", "Ciano de escala"),+ ("Colors and Inks", "Cores e tintas"),+ ("Links and Images", "Vínculos e imagens"),+ ("Fonts", "Fontes"),+ ("Summary", "Resumo"),("Paste Vector Art", "Colar arte vetorial"),("Baseline Options", "Opções de linha de base"),("Fixed Number", "Número fixo"),diff --git a/crates/ui-egui/src/i18n/ru.rs b/crates/ui-egui/src/i18n/ru.rsindex 251555ca5..4888924ee 100644--- a/crates/ui-egui/src/i18n/ru.rs+++ b/crates/ui-egui/src/i18n/ru.rs@@ -33,6 +33,45 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Вырезать"),("Copy", "Копировать"),("Paste", "Вставить"),+ ("Packaged {count} files into {dir}", "Упаковано файлов: {count} в {dir}"),+ ("Continue", "Продолжить"),+ ("Printing Instructions", "Инструкции для печати"),+ ("Show Problems Only", "Показывать только проблемы"),+ ("Include PDF (Print)", "Включить PDF (печать)"),+ ("Include IDML", "Включить IDML"),+ ("Create Printing Instructions", "Создать инструкции для печати"),+ ("Entire Publication", "Вся публикация"),+ ("Scope:", "Область:"),+ ("Spot", "Плашечный"),+ ("Process", "Триадный"),+ ("Source", "Источник"),+ ("Installed", "Установлен"),+ ("Bundled", "Встроенный"),+ ("Substituted", "Заменен"),+ ("Modified", "Изменено"),+ ("Missing", "Отсутствует"),+ ("Colors and Inks: {process} Process Inks; {spot} Spot Inks", "Цвета и краски: триадных {process}; плашечных {spot}"),+ ("Images: {embedded} Embedded", "Изображения: внедрено {embedded}"),+ (+ "Links and Images: {found} Links Found; {modified} Modified, {missing} Missing",+ "Связи и изображения: найдено {found}; изменено {modified}, отсутствует {missing}",+ ),+ ("Fonts: {used} Fonts Used, {missing} Missing", "Шрифты: используется {used}, отсутствует {missing}"),+ ("Instructions:", "Инструкции:"),+ ("Email:", "Эл. почта:"),+ ("Fax:", "Факс:"),+ ("Phone:", "Телефон:"),+ ("Address:", "Адрес:"),+ ("Company:", "Компания:"),+ ("Contact:", "Контакт:"),+ ("Process Black", "Триадный черный"),+ ("Process Yellow", "Триадный желтый"),+ ("Process Magenta", "Триадный пурпурный"),+ ("Process Cyan", "Триадный голубой"),+ ("Colors and Inks", "Цвета и краски"),+ ("Links and Images", "Связи и изображения"),+ ("Fonts", "Шрифты"),+ ("Summary", "Сводка"),("Clear", "Очистить"),("Duplicate", "Дублировать"),("Select All", "Выделить все"),diff --git a/crates/ui-egui/src/i18n/uk.rs b/crates/ui-egui/src/i18n/uk.rsindex dd4a1434d..88d72cb57 100644--- a/crates/ui-egui/src/i18n/uk.rs+++ b/crates/ui-egui/src/i18n/uk.rs@@ -29,6 +29,44 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Вирізати"),("Copy", "Копіювати"),("Paste", "Вставити"),+ ("Packaged {count} files into {dir}", "Запаковано файлів: {count} у {dir}"),+ ("Continue", "Продовжити"),+ ("Printing Instructions", "Інструкції для друку"),+ ("Package", "Пакування"),+ ("Show Problems Only", "Показувати лише проблеми"),+ ("Include PDF (Print)", "Включити PDF (друк)"),+ ("Include IDML", "Включити IDML"),+ ("Create Printing Instructions", "Створити інструкції для друку"),+ ("Entire Publication", "Уся публікація"),+ ("Scope:", "Область:"),+ ("Source", "Джерело"),+ ("Installed", "Встановлений"),+ ("Bundled", "Вбудований"),+ ("Substituted", "Замінено"),+ ("Modified", "Змінено"),+ ("Missing", "Бракує"),+ ("Colors and Inks: {process} Process Inks; {spot} Spot Inks", "Кольори й фарби: тріадних {process}; плашкових {spot}"),+ ("Images: {embedded} Embedded", "Зображення: вбудовано {embedded}"),+ (+ "Links and Images: {found} Links Found; {modified} Modified, {missing} Missing",+ "Зв’язки й зображення: знайдено {found}; змінено {modified}, бракує {missing}",+ ),+ ("Fonts: {used} Fonts Used, {missing} Missing", "Шрифти: використано {used}, бракує {missing}"),+ ("Instructions:", "Інструкції:"),+ ("Email:", "Ел. пошта:"),+ ("Fax:", "Факс:"),+ ("Phone:", "Телефон:"),+ ("Address:", "Адреса:"),+ ("Company:", "Компанія:"),+ ("Contact:", "Контакт:"),+ ("Process Black", "Тріадний чорний"),+ ("Process Yellow", "Тріадний жовтий"),+ ("Process Magenta", "Тріадний пурпуровий"),+ ("Process Cyan", "Тріадний блакитний"),+ ("Colors and Inks", "Кольори й фарби"),+ ("Links and Images", "Зв’язки й зображення"),+ ("Fonts", "Шрифти"),+ ("Summary", "Зведення"),("Paste Vector Art", "Вставити векторну графіку"),("Baseline Options", "Параметри базової лінії"),("Fixed Number", "Фіксована кількість"),diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex cb98cac7f..758ec7988 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -21,6 +21,7 @@ pub mod menus;mod modal_drag;mod new_document;mod object_control;+pub mod package_dialog;mod panel_docking;pub mod panels;mod prefs;diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex 79b8b2c4e..794e58f2d 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -39,7 +39,12 @@ pub const UI_COMMANDS: &[(&str, &str, Option<&str>, &str)] = &[None,"{page?: transparency|dropShadow|innerShadow|outerGlow|innerGlow|bevel|satin|feather|directionalFeather|gradientFeather} — the Effects dialog for the selected objects",),- ("app.packageDialog", "Package…", Some("Cmd+Alt+Shift+P"), "{} — choose the package folder to create (file.package)"),+ (+ "app.packageDialog",+ "Package…",+ Some("Cmd+Alt+Shift+P"),+ "{} — the Package dialog (what the package carries, printing instructions), then the folder to create (file.package)",+ ),("app.saveSwatches", "Save Swatches for Exchange…", None, "{path?} — write the colour swatches as .ase"),("app.exportPng", "Export Page as PNG…", Some("Cmd+E"), "{}"),("app.exportIdml", "Export IDML…", None, "{path?} — InDesign Markup (IDML) package"),@@ -1145,21 +1150,8 @@ fn run_ui_inner(app: &mut DesignApp, id: &str, p: &Value) -> Option<Result<Value}"app.exportText" => export_bytes(app, p, "rtf", "file.exportText"),"app.packageDialog" => {- let name = app.session.active().map(|d| format!("{} Folder", d.doc.title)).unwrap_or_default();- match app.services.pick_save.as_mut().and_then(|f| f(&name)) {- Some(dir) => {- let r = app.run("file.package", json!({"dir": dir}));- if let Ok(v) = &r {- app.status(- crate::i18n::tr(&app.ui.language, "Packaged {count} files into {dir}")- .replace("{count}", &v["files"].as_array().map_or(0, |f| f.len()).to_string())- .replace("{dir}", v["dir"].as_str().unwrap_or("")),- );- }- r- }- None => Ok(Value::Null),- }+ crate::package_dialog::open(app);+ Ok(Value::Null)}"app.language" => {let Some(v) = p.get("lang").and_then(Value::as_str) else { return Some(app.run("app.preferences", json!({}))) };diff --git a/crates/ui-egui/src/package_dialog.rs b/crates/ui-egui/src/package_dialog.rsnew file mode 100644index 000000000..6c00ca060--- /dev/null+++ b/crates/ui-egui/src/package_dialog.rs@@ -0,0 +1,457 @@+//! File › Package…: InDesign's Package dialog. Summary counts what the package carries (fonts,+//! links and images, inks), with a warning where something is missing or modified; Fonts, Links+//! and Images and Colors and Inks list them (Show Problems Only). Package… asks for the folder to+//! create and writes the package (`file.package`), after the Printing Instructions when Create+//! Printing Instructions is on.++use serde_json::{Value, json};++use crate::DesignApp;+use crate::dialogs::Dialog;+use crate::theme::semibold;++/// The Package dialog's id.+pub const ID: &str = "package";+/// The Printing Instructions dialog's id.+pub const INSTRUCTIONS: &str = "printingInstructions";++/// The dialog's pages: (key, label).+const PAGES: [(&str, &str); 4] = [("summary", "Summary"), ("fonts", "Fonts"), ("links", "Links and Images"), ("inks", "Colors and Inks")];++/// The process inks every package prints with.+const PROCESS_INKS: [&str; 4] = ["Process Cyan", "Process Magenta", "Process Yellow", "Process Black"];++/// The Printing Instructions' fields: (key, label, lines).+const INSTRUCTION_FIELDS: [(&str, &str, usize); 7] = [+ ("contact", "Contact:", 1),+ ("company", "Company:", 1),+ ("address", "Address:", 3),+ ("phone", "Phone:", 1),+ ("fax", "Fax:", 1),+ ("email", "Email:", 1),+ ("instructions", "Instructions:", 4),+];++/// Open the Package dialog on its Summary, with the document's fonts, links and spot inks.+pub fn open(app: &mut DesignApp) {+ if app.session.active().is_none() {+ return;+ }+ let fonts: Vec<Value> = app+ .session+ .execute("font.list", &json!({}))+ .ok()+ .and_then(|v| v.as_array().cloned())+ .unwrap_or_default()+ .iter()+ .map(|f| {+ let status = if f["missing"].as_bool().unwrap_or(false) {+ "missing"+ } else if f["styleMissing"].as_bool().unwrap_or(false) || f["matchStatus"] == "styleSubstitute" {+ "substituted"+ } else {+ "ok"+ };+ let name = format!("{} {}", f["family"].as_str().unwrap_or(""), f["style"].as_str().unwrap_or("")).trim().to_string();+ json!({"name": name, "source": f["source"].as_str().unwrap_or(""), "status": status})+ })+ .collect();+ let links: Vec<Value> = app+ .session+ .execute("links.list", &json!({}))+ .ok()+ .and_then(|v| v.as_array().cloned())+ .unwrap_or_default()+ .iter()+ .map(|l| {+ let page = l["uses"].as_array().and_then(|u| u.iter().find_map(|u| u["page"].as_str())).unwrap_or("");+ json!({"name": l["name"].as_str().unwrap_or(""), "page": page, "status": l["status"].as_str().unwrap_or("ok")})+ })+ .collect();+ // Spot inks print on their own plates unless the Ink Manager makes them process.+ let inks = app.session.execute("ink.list", &json!({})).unwrap_or_default();+ let all_process = inks["allToProcess"].as_bool().unwrap_or(false);+ let spot: Vec<Value> = inks["inks"]+ .as_array()+ .map(|a| {+ a.iter()+ .filter(|i| !all_process && !i["process"].as_bool().unwrap_or(false))+ .filter_map(|i| i["name"].as_str())+ .map(|n| json!(n))+ .collect()+ })+ .unwrap_or_default();+ app.ui.dialog = Some(Dialog::new(+ ID,+ json!({"page": "summary", "fonts": fonts, "links": links, "spot": spot, "instructions": false, "idml": true, "pdf": false, "problemsOnly": false}),+ ));+}++fn rows(d: &Dialog, key: &str) -> Vec<Value> {+ d.fields.get(key).and_then(Value::as_array).cloned().unwrap_or_default()+}++/// How many of `rows` have one of `statuses`.+fn count(rows: &[Value], statuses: &[&str]) -> usize {+ rows.iter().filter(|r| r["status"].as_str().is_some_and(|s| statuses.contains(&s))).count()+}++/// The Summary's lines: (text, whether it warns).+fn summary_lines(lang: &str, d: &Dialog) -> Vec<(String, bool)> {+ let tr = |s: &str| crate::i18n::tr(lang, s).to_string();+ let (fonts, links) = (rows(d, "fonts"), rows(d, "links"));+ let missing_fonts = count(&fonts, &["missing"]);+ let (modified, missing) = (count(&links, &["modified"]), count(&links, &["missing"]));+ vec![+ (+ tr("Fonts: {used} Fonts Used, {missing} Missing")+ .replace("{used}", &fonts.len().to_string())+ .replace("{missing}", &missing_fonts.to_string()),+ missing_fonts > 0,+ ),+ (+ tr("Links and Images: {found} Links Found; {modified} Modified, {missing} Missing")+ .replace("{found}", &links.len().to_string())+ .replace("{modified}", &modified.to_string())+ .replace("{missing}", &missing.to_string()),+ modified + missing > 0,+ ),+ (tr("Images: {embedded} Embedded").replace("{embedded}", &count(&links, &["embedded"]).to_string()), false),+ (+ tr("Colors and Inks: {process} Process Inks; {spot} Spot Inks")+ .replace("{process}", &PROCESS_INKS.len().to_string())+ .replace("{spot}", &rows(d, "spot").len().to_string()),+ false,+ ),+ ]+}++/// The warning sign InDesign shows beside a line with problems, and the colours of statuses.+const WARN: egui::Color32 = egui::Color32::from_rgb(0xe8, 0xb3, 0x2c);+const BAD: egui::Color32 = egui::Color32::from_rgb(0xe5, 0x4b, 0x4b);++fn status_text(lang: &str, status: &str) -> (String, Option<egui::Color32>) {+ let tr = |s: &str| crate::i18n::tr(lang, s).to_string();+ match status {+ "missing" => (format!("\u{26A0} {}", tr("Missing")), Some(BAD)),+ "modified" => (format!("\u{25B2} {}", tr("Modified")), Some(WARN)),+ "substituted" => (tr("Substituted"), Some(WARN)),+ "embedded" => (tr("Embedded"), None),+ _ => (tr("OK"), None),+ }+}++/// A table: a header row and `cells` rows (each with an optional colour for its last cell).+fn table(ui: &mut egui::Ui, id: &str, header: &[String], cells: &[(Vec<String>, Option<egui::Color32>)]) {+ let t = crate::theme::Tokens::get(ui.ctx());+ egui::Frame::NONE.stroke(egui::Stroke::new(1.0, t.field_border)).inner_margin(6.0).show(ui, |ui| {+ egui::ScrollArea::vertical().id_salt(id).max_height(220.0).auto_shrink([false, true]).show(ui, |ui| {+ egui::Grid::new(id).num_columns(header.len()).spacing([18.0, 4.0]).striped(true).show(ui, |ui| {+ for h in header {+ crate::rtl::label(ui, egui::RichText::new(h).font(semibold(11.5)));+ }+ ui.end_row();+ for (row, color) in cells {+ for (i, c) in row.iter().enumerate() {+ let mut text = egui::RichText::new(c);+ if i + 1 == row.len()+ && let Some(color) = color+ {+ text = text.color(*color);+ }+ crate::rtl::label(ui, text);+ }+ ui.end_row();+ }+ });+ });+ });+}++/// The Package dialog: the pages on the left, the page on the right.+pub fn show(app: &DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {+ let lang = app.ui.language.clone();+ let tr = |s: &str| crate::i18n::tr(&lang, s).to_string();+ let page = d.fields.get("page").and_then(Value::as_str).unwrap_or("summary").to_string();+ ui.horizontal_top(|ui| {+ // A fixed height, as Preferences': the divider between the pages and the page fills it,+ // and the dialog keeps its size from page to page.+ ui.set_min_height(320.0);+ ui.set_max_height(320.0);+ ui.vertical(|ui| {+ ui.set_width(150.0);+ for (key, label) in PAGES {+ if ui.selectable_label(page == key, crate::rtl::widget(ui, tr(label))).clicked() {+ d.fields.insert("page".into(), json!(key));+ }+ }+ });+ ui.separator();+ ui.vertical(|ui| {+ ui.set_min_width(460.0);+ let title = PAGES.iter().find(|p| p.0 == page).map_or("Summary", |p| p.1);+ crate::rtl::label(ui, egui::RichText::new(tr(title)).font(semibold(13.0)));+ ui.add_space(6.0);+ let problems_only = d.b("problemsOnly");+ match page.as_str() {+ "fonts" => {+ let fonts = rows(d, "fonts");+ let cells: Vec<_> = fonts+ .iter()+ .filter(|f| !problems_only || f["status"] != "ok")+ .map(|f| {+ let (status, color) = status_text(&lang, f["status"].as_str().unwrap_or("ok"));+ let source = match f["source"].as_str().unwrap_or("") {+ "bundled" => tr("Bundled"),+ "installed" => tr("Installed"),+ "document" => tr("Document"),+ "added" => tr("Added"),+ _ => String::new(),+ };+ (vec![f["name"].as_str().unwrap_or("").to_string(), source, status], color)+ })+ .collect();+ table(ui, "package_fonts", &[tr("Name"), tr("Source"), tr("Status")], &cells);+ }+ "links" => {+ let links = rows(d, "links");+ let cells: Vec<_> = links+ .iter()+ .filter(|l| !problems_only || matches!(l["status"].as_str(), Some("missing" | "modified")))+ .map(|l| {+ let (status, color) = status_text(&lang, l["status"].as_str().unwrap_or("ok"));+ (vec![l["name"].as_str().unwrap_or("").to_string(), l["page"].as_str().unwrap_or("").to_string(), status], color)+ })+ .collect();+ table(ui, "package_links", &[tr("Name"), tr("Page"), tr("Status")], &cells);+ }+ "inks" => {+ let mut cells: Vec<_> = PROCESS_INKS.iter().map(|n| (vec![tr(n), tr("Process")], None)).collect();+ cells.extend(rows(d, "spot").iter().filter_map(Value::as_str).map(|n| (vec![n.to_string(), tr("Spot")], None)));+ table(ui, "package_inks", &[tr("Name"), tr("Type")], &cells);+ }+ _ => {+ ui.horizontal(|ui| {+ crate::rtl::label(ui, tr("Scope:"));+ crate::rtl::label(ui, tr("Entire Publication"));+ });+ ui.add_space(6.0);+ for (line, warn) in summary_lines(&lang, d) {+ ui.horizontal(|ui| {+ let sign = egui::RichText::new(if warn { "\u{26A0}" } else { " " }).color(WARN);+ ui.add_sized([14.0, 16.0], egui::Label::new(sign));+ crate::rtl::label(ui, line);+ });+ }+ ui.add_space(10.0);+ for (key, label) in [("instructions", "Create Printing Instructions"), ("idml", "Include IDML"), ("pdf", "Include PDF (Print)")] {+ let mut on = d.b(key);+ if ui.checkbox(&mut on, crate::rtl::widget(ui, tr(label))).changed() {+ d.fields.insert(key.into(), json!(on));+ }+ }+ }+ }+ if matches!(page.as_str(), "fonts" | "links") {+ ui.add_space(4.0);+ let mut on = problems_only;+ if ui.checkbox(&mut on, crate::rtl::widget(ui, tr("Show Problems Only"))).changed() {+ d.fields.insert("problemsOnly".into(), json!(on));+ }+ }+ });+ });+}++/// Package…: the Printing Instructions first when asked for, else the folder.+pub fn confirm(app: &mut DesignApp, d: &Dialog) -> Result<Value, String> {+ let (idml, pdf) = (d.b("idml"), d.b("pdf"));+ if d.b("instructions") {+ app.ui.dialog = Some(Dialog::new(INSTRUCTIONS, json!({"idml": idml, "pdf": pdf})));+ return Ok(Value::Null);+ }+ package_to_folder(app, idml, pdf, None)+}++/// The Printing Instructions dialog, as InDesign's: who to contact and what to do.+pub fn show_instructions(app: &DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {+ let lang = app.ui.language.clone();+ egui::Grid::new("printing_instructions").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {+ for (key, label, lines) in INSTRUCTION_FIELDS {+ crate::rtl::label(ui, crate::i18n::tr(&lang, label));+ let mut text = d.s(key);+ let edit = if lines > 1 { egui::TextEdit::multiline(&mut text).desired_rows(lines) } else { egui::TextEdit::singleline(&mut text) };+ if ui.add(edit.desired_width(320.0)).changed() {+ d.fields.insert(key.into(), json!(text));+ }+ ui.end_row();+ }+ });+}++/// The instructions as they go into the package's Instructions.txt: the contact lines, then the+/// instructions. Empty fields are left out.+fn instructions_text(d: &Dialog) -> String {+ let mut out = String::new();+ for (key, label) in+ [("contact", "Contact"), ("company", "Company"), ("address", "Address"), ("phone", "Phone"), ("fax", "Fax"), ("email", "Email")]+ {+ let v = d.s(key);+ let v = v.trim();+ if !v.is_empty() {+ out += &format!("{label}: {}\n", v.replace('\n', "\n "));+ }+ }+ let ins = d.s("instructions");+ if !ins.trim().is_empty() {+ if !out.is_empty() {+ out.push('\n');+ }+ out += ins.trim();+ out.push('\n');+ }+ out+}++/// Continue: the folder, with the instructions.+pub fn confirm_instructions(app: &mut DesignApp, d: &Dialog) -> Result<Value, String> {+ let text = instructions_text(d);+ package_to_folder(app, d.b("idml"), d.b("pdf"), Some(text).filter(|t| !t.is_empty()))+}++/// Ask for the folder to create ("<title> Folder") and package the document into it.+pub fn package_to_folder(app: &mut DesignApp, idml: bool, pdf: bool, instructions: Option<String>) -> Result<Value, String> {+ let name = app.session.active().map(|d| format!("{} Folder", d.doc.title)).unwrap_or_default();+ let Some(dir) = app.services.pick_save.as_mut().and_then(|f| f(&name)) else { return Ok(Value::Null) };+ let mut p = json!({"dir": dir, "idml": idml, "pdf": pdf});+ if let Some(t) = instructions {+ p["instructions"] = json!(t);+ }+ let r = app.run("file.package", p);+ if let Ok(v) = &r {+ app.status(+ crate::i18n::tr(&app.ui.language, "Packaged {count} files into {dir}")+ .replace("{count}", &v["files"].as_array().map_or(0, |f| f.len()).to_string())+ .replace("{dir}", v["dir"].as_str().unwrap_or("")),+ );+ }+ r+}++#[cfg(test)]+mod tests {+ use egui_kittest::{Harness, kittest::Queryable};++ use super::*;++ /// A document with a text frame and an image whose file has gone, in a temporary folder.+ fn app_with_missing_link(dir: &std::path::Path) -> DesignApp {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({"title": "Packed"})).unwrap();+ app.run("frame.create", json!({"rect": [36, 36, 300, 200], "content": "text", "text": "Hello"})).unwrap();+ let png = designcraft_render::Rendered { width: 4, height: 3, pixels: [30, 90, 180, 255].repeat(12) }.to_png();+ let img = dir.join("gone.png");+ std::fs::write(&img, &png).unwrap();+ app.run("file.place", json!({"path": img.to_string_lossy(), "x": 40, "y": 260, "width": 40})).unwrap();+ std::fs::remove_file(&img).unwrap();+ app+ }++ fn harness(app: DesignApp) -> Harness<'static, DesignApp> {+ Harness::builder().with_size(egui::vec2(1100.0, 760.0)).build_ui_state(+ |ui, app: &mut DesignApp| {+ let key = egui::Id::new("package_test_fonts");+ if ui.data(|d| d.get_temp::<bool>(key)).is_none() {+ crate::theme::install_fonts(ui.ctx(), "");+ ui.data_mut(|d| d.insert_temp(key, true));+ return;+ }+ crate::dialogs::show(app, ui.ctx());+ },+ app,+ )+ }++ fn temp_dir(tag: &str) -> std::path::PathBuf {+ let nonce = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos();+ let dir = std::env::temp_dir().join(format!("dc-package-dialog-{tag}-{}-{nonce}", std::process::id()));+ std::fs::create_dir_all(&dir).unwrap();+ dir+ }++ /// The course's chapter 27: File › Package opens InDesign's Package dialog. Summary counts the+ /// fonts, links (one missing, with a warning) and inks; Links and Images lists the link, and+ /// Show Problems Only keeps it; Create Printing Instructions leads to Printing Instructions,+ /// whose Continue asks for the folder and writes the package with the instructions.+ #[test]+ fn package_shows_a_summary_then_the_printing_instructions() {+ let dir = temp_dir("summary");+ let mut app = app_with_missing_link(&dir);+ let out = dir.join("Packed Folder");+ let picked = out.to_string_lossy().to_string();+ app.services.pick_save = Some(Box::new(move |_| Some(picked.clone())));+ crate::menus::activate(&mut app, "app.packageDialog", &Value::Null);+ assert_eq!(app.ui.dialog.as_ref().map(|d| d.id.as_str()), Some(ID));+ let mut h = harness(app);+ h.run_steps(3);+ assert!(h.query_by_label("Scope:").is_some());+ assert!(h.query_by_label("Links and Images: 1 Links Found; 0 Modified, 1 Missing").is_some());+ assert!(h.query_by_label("Colors and Inks: 4 Process Inks; 0 Spot Inks").is_some());+ let fonts = h.state().ui.dialog.as_ref().unwrap().fields["fonts"].as_array().unwrap().len();+ assert!(h.query_by_label(&format!("Fonts: {fonts} Fonts Used, 0 Missing")).is_some());+ // Links and Images: the link, missing; Show Problems Only keeps it.+ h.get_by_label("Links and Images").click();+ h.run_steps(2);+ assert!(h.query_by_label("gone.png").is_some());+ assert!(h.query_by_label("\u{26A0} Missing").is_some());+ h.get_by_label("Show Problems Only").click();+ h.run_steps(2);+ assert!(h.query_by_label("gone.png").is_some());+ // Back on Summary: Create Printing Instructions, then Package….+ h.get_by_label("Summary").click();+ h.run_steps(2);+ h.get_by_label("Create Printing Instructions").click();+ h.run_steps(2);+ h.get_by_label("Package…").click();+ h.run_steps(3);+ assert_eq!(h.state().ui.dialog.as_ref().map(|d| d.id.as_str()), Some(INSTRUCTIONS));+ for (key, value) in [("contact", "Dave"), ("email", "[email protected]"), ("instructions", "Call me if anything is wrong.")] {+ h.state_mut().ui.dialog.as_mut().unwrap().fields.insert(key.into(), json!(value));+ }+ h.run_steps(2);+ h.get_by_label("Continue").click();+ h.run_steps(3);+ assert!(h.state().ui.dialog.is_none());+ let report = std::fs::read_to_string(out.join("Instructions.txt")).unwrap();+ assert!(+ report.contains("Contact: Dave") && report.contains("Email: [email protected]") && report.contains("Call me if anything is wrong."),+ "{report}"+ );+ assert!(out.join("Packed.idml").exists(), "Include IDML is on by default");+ assert!(!out.join("Packed.pdf").exists(), "Include PDF is off by default");+ std::fs::remove_dir_all(dir).unwrap();+ }++ /// Without instructions, Package… goes straight to the folder; Include PDF adds the PDF and+ /// Include IDML off leaves the IDML out.+ #[test]+ fn package_options_choose_the_idml_and_pdf() {+ let dir = temp_dir("options");+ let mut app = app_with_missing_link(&dir);+ let out = dir.join("Packed Folder");+ let picked = out.to_string_lossy().to_string();+ app.services.pick_save = Some(Box::new(move |_| Some(picked.clone())));+ open(&mut app);+ let mut h = harness(app);+ h.run_steps(3);+ h.get_by_label("Include IDML").click();+ h.run_steps(2);+ h.get_by_label("Include PDF (Print)").click();+ h.run_steps(2);+ h.get_by_label("Package…").click();+ h.run_steps(3);+ assert!(h.state().ui.dialog.is_none());+ assert!(out.join("Packed.pdf").exists() && !out.join("Packed.idml").exists());+ std::fs::remove_dir_all(dir).unwrap();+ }+}