PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Wayland: drop notice offers paste and the XWayland command for this install (#338, #386) (#1073)
BFlatad857f1c934f
diff --git a/README.md b/README.mdindex 709b00daa..21642ee61 100644--- a/README.md+++ b/README.md@@ -277,6 +277,8 @@ flatpak run ai.storyteller.photocraftThe AppImage needs no install: the first run registers its launcher icon and menu entry in `~/.local/share` so the dock shows PhotoCraft's icon on Wayland. Set `PHOTOCRAFT_NO_DESKTOP_INTEGRATION=1` to skip that, and see [`docs/releasing.md`](docs/releasing.md) › Linux to undo it.+On a Wayland session, files dropped on the window don't open yet: winit 0.30, the windowing library under egui, has no Wayland drag and drop (#386). Use File › Open, or copy the image in your file manager and paste it with Ctrl+V. To drag and drop, start PhotoCraft under XWayland: `WAYLAND_DISPLAY= photocraft`, `WAYLAND_DISPLAY= ./photocraft-<version>-linux-x86_64.AppImage`, or `flatpak run --nosocket=wayland --socket=x11 ai.storyteller.photocraft`. On Wayland, PhotoCraft shows the command for your install in a notice until you dismiss it.+On macOS, the command-line tool comes as `photocraft-cli-<version>-macos-universal.zip`. The binary is signed with the same Developer ID as the app and notarized by Apple. A bare binary can't carry a stapled notarization ticket the way the DMG does, so the first time you run it macOS checks the notarization online. You can confirm it yourself:```shdiff --git a/apps/photocraft/src/main.rs b/apps/photocraft/src/main.rsindex 7e83b6086..146fdaade 100644--- a/apps/photocraft/src/main.rs+++ b/apps/photocraft/src/main.rs@@ -323,6 +323,11 @@ fn main() -> eframe::Result {#[cfg(target_os = "linux")]{services.is_wayland = display == Some(tablet::DisplayKind::Wayland);+ if services.is_wayland {+ let var = |name| std::env::var(name).ok();+ services.xwayland_command =+ services::xwayland_command(var("FLATPAK_ID").as_deref(), var("APPIMAGE").as_deref(), std::env::var_os("DISPLAY").is_some());+ }}let mut app = PhotocraftApp::new(Session::new(), services);app.integrated_titlebar = cfg!(target_os = "macos");diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rsindex d4230f570..48bc1ad5b 100644--- a/apps/photocraft/src/services.rs+++ b/apps/photocraft/src/services.rs@@ -200,6 +200,25 @@ fn image_from_files(paths: &[PathBuf]) -> Option<(u32, u32, Vec<u8>)> {})}+/// The shell command that starts this install under XWayland, where winit delivers file drops+/// (winit 0.30 has none on Wayland, #386). A Flatpak gets the X11 socket only without the Wayland+/// one, an AppImage relaunches by its own path, and anything else is `photocraft` on the PATH.+/// `None` outside Flatpak when there is no X server (`DISPLAY` unset) to run on.+#[cfg(any(target_os = "linux", test))]+pub fn xwayland_command(flatpak_id: Option<&str>, appimage: Option<&str>, x_display: bool) -> Option<String> {+ if let Some(id) = flatpak_id.filter(|id| !id.is_empty()) {+ return Some(format!("flatpak run --nosocket=wayland --socket=x11 {}", shell_word(id)));+ }+ let exe = appimage.filter(|path| !path.is_empty()).map_or_else(|| "photocraft".to_string(), shell_word);+ x_display.then(|| format!("WAYLAND_DISPLAY= {exe}"))+}++/// `s` as one POSIX shell word: bare when every character is safe there, else single-quoted.+#[cfg(any(target_os = "linux", test))]+fn shell_word(s: &str) -> String {+ if s.bytes().all(|b| b.is_ascii_alphanumeric() || b"/._-+:,@".contains(&b)) { s.to_string() } else { format!("'{}'", s.replace('\'', r"'\''")) }+}+pub fn native(automation: Option<photocraft_automation::AuthorizedWorkspace>) -> Services {let clip: Rc<RefCell<Option<arboard::Clipboard>>> = Rc::default();let automation_read = automation.clone().map(|workspace| {@@ -362,6 +381,23 @@ mod tests {use photocraft_ui_egui::{PhotocraftApp, prefs_ui};use serde_json::{Value, json};+ #[test]+ fn xwayland_command_matches_how_photocraft_was_installed() {+ // Flatpak: WAYLAND_DISPLAY doesn't reach the sandbox's socket choice; flatpak's flags do.+ let flatpak = xwayland_command(Some("ai.storyteller.photocraft"), None, false);+ assert_eq!(flatpak.as_deref(), Some("flatpak run --nosocket=wayland --socket=x11 ai.storyteller.photocraft"));+ // AppImage: its own path, quoted for the shell (spaces, quotes).+ let appimage = xwayland_command(None, Some("/home/me/My Apps/it's.AppImage"), true);+ assert_eq!(appimage.as_deref(), Some(r"WAYLAND_DISPLAY= '/home/me/My Apps/it'\''s.AppImage'"));+ let bare = xwayland_command(None, Some("/opt/photocraft-0.3.0-linux-x86_64.AppImage"), true);+ assert_eq!(bare.as_deref(), Some("WAYLAND_DISPLAY= /opt/photocraft-0.3.0-linux-x86_64.AppImage"));+ // deb, rpm, AUR, tarball: the binary on the PATH.+ assert_eq!(xwayland_command(None, None, true).as_deref(), Some("WAYLAND_DISPLAY= photocraft"));+ assert_eq!(xwayland_command(Some(""), Some(""), true).as_deref(), Some("WAYLAND_DISPLAY= photocraft"));+ // No X server (XWayland disabled): nothing to suggest.+ assert_eq!(xwayland_command(None, Some("/opt/p.AppImage"), false), None);+ }+/// Tests every native save dialog and records the suggested file name. Each name's file type must come first/// in the save panel, or the panel appends the first type's extension (`photo.webp.psd`, `photo.gif.psd`).#[test]diff --git a/crates/ui-egui/examples/snapshot.rs b/crates/ui-egui/examples/snapshot.rsindex d135528db..52e5df76c 100644--- a/crates/ui-egui/examples/snapshot.rs+++ b/crates/ui-egui/examples/snapshot.rs@@ -66,6 +66,7 @@ fn main() {PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());let mut services = services;services.is_wayland = wayland_notice;+ services.xwayland_command = wayland_notice.then(|| "WAYLAND_DISPLAY= photocraft".into());let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), services);app.background_jobs = background_jobs;app.custom_titlebar = custom_titlebar;diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex de3aa0dc1..2acc49e64 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -1711,8 +1711,8 @@ fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {});ui.add_space(22.0);ui.horizontal(|ui| {- let msg = start_screen_drop_hint(app.services.is_wayland);- let g = ui.painter().layout_no_wrap(msg.into(), egui::FontId::proportional(12.5), t.text_faint);+ let msg = start_screen_drop_hint(app);+ let g = ui.painter().layout_no_wrap(msg.to_string(), egui::FontId::proportional(12.5), t.text_faint);ui.add_space(((card.width() - g.size().x - 24.0) / 2.0).max(0.0));let (r, _) = ui.allocate_exact_size(egui::vec2(18.0, 18.0), Sense::hover());crate::icons::paint(ui, r, "image", 15.0, t.text_faint);@@ -1730,8 +1730,13 @@ fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {});}-fn start_screen_drop_hint(is_wayland: bool) -> &'static str {- if is_wayland { tl!("Use File › Open to open an image.") } else { tl!("Drop an image or PSD anywhere to open it.") }+/// Wayland has no native file drops (winit 0.30, #386), so the hint offers File › Open and paste.+fn start_screen_drop_hint(app: &PhotocraftApp) -> std::borrow::Cow<'static, str> {+ if app.services.is_wayland {+ crate::i18n::fmt(tl!("Use File › Open, or paste a copied image with {paste}."), &[("paste", &crate::notices::paste_hint(app))]).into()+ } else {+ tl!("Drop an image or PSD anywhere to open it.").into()+ }}/// Recent files listed on the Home screen.@@ -3656,7 +3661,13 @@ mod tests {#[test]fn wayland_start_screen_hint_does_not_claim_file_drop_works() {- assert_ne!(start_screen_drop_hint(true), start_screen_drop_hint(false));+ let x11 = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());+ let wayland = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services { is_wayland: true, ..Default::default() });+ assert!(start_screen_drop_hint(&x11).starts_with("Drop"));+ // Pasting a copied image file works on Wayland (#338): the hint says how.+ let hint = start_screen_drop_hint(&wayland);+ assert!(!hint.contains("Drop"), "{hint}");+ assert!(hint.ends_with(&format!("paste a copied image with {}.", crate::notices::paste_hint(&wayland))), "{hint}");}#[test]diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex 44a95cd54..5a5bbb95c 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -990,11 +990,13 @@Draw with the Pen tool (P) or make a work path from a selection. Kreslete nástrojem pero (P) nebo vytvořte pracovní cestu z výběru.Drop an image or PSD anywhere to open it. Přetáhněte sem obrázek nebo PSD a otevře se.Native file drag-and-drop is unavailable Nativní přetahování souborů ve Waylandu není dostupné- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Nativní přetahování souborů ve Waylandu zatím není podporováno. Použijte Soubor › Otevřít nebo spusťte PhotoCraft v XWayland s `WAYLAND_DISPLAY= photocraft`.+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Nativní přetahování souborů ve Waylandu zatím není podporováno. Použijte Soubor › Otevřít, nebo obrázek zkopírujte ve správci souborů a vložte ho pomocí {paste}.+ To drop files, start PhotoCraft under XWayland: `{command}` Chcete-li soubory přetahovat, spusťte PhotoCraft v XWayland: `{command}`+ Edit › Paste Úpravy › VložitDuplicate Layers… Duplikovat vrstvy…Duplicate style Duplikovat stylEdit Toolbar… Upravit panel nástrojů…- Use File › Open to open an image. Obrázek otevřete přes Soubor › Otevřít.+ Use File › Open, or paste a copied image with {paste}. Použijte Soubor › Otevřít, nebo vložte zkopírovaný obrázek pomocí {paste}.Edit in Quick Mask Mode (Q) Upravit v režimu rychlé masky (Q)Edit in Standard Mode (Q) Upravit ve standardním režimu (Q)Effects Efektydiff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex eb6081ae3..b7d3c853f 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -974,11 +974,13 @@Draw with the Pen tool (P) or make a work path from a selection. Zeichne mit dem Stift-Werkzeug (P) oder erzeuge einen Arbeitspfad aus einer Auswahl.Drop an image or PSD anywhere to open it. Ziehe ein Bild oder PSD an eine beliebige Stelle, um es zu öffnen.Native file drag-and-drop is unavailable Natives Ziehen und Ablegen von Dateien ist nicht verfügbar- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Natives Ziehen und Ablegen von Dateien wird unter Wayland noch nicht unterstützt. Nutze Datei › Öffnen oder starte PhotoCraft unter XWayland mit `WAYLAND_DISPLAY= photocraft`.+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Natives Ziehen und Ablegen von Dateien wird unter Wayland noch nicht unterstützt. Nutze Datei › Öffnen oder kopiere das Bild im Dateimanager und füge es mit {paste} ein.+ To drop files, start PhotoCraft under XWayland: `{command}` Um Dateien abzulegen, starte PhotoCraft unter XWayland: `{command}`+ Edit › Paste Bearbeiten › EinfügenDuplicate Layers… Ebenen duplizieren…Duplicate style Stil duplizierenEdit Toolbar… Werkzeugleiste bearbeiten…- Use File › Open to open an image. Nutze Datei › Öffnen, um ein Bild zu öffnen.+ Use File › Open, or paste a copied image with {paste}. Nutze Datei › Öffnen oder füge ein kopiertes Bild mit {paste} ein.Edit in Quick Mask Mode (Q) Im Schnellmaskenmodus bearbeiten (Q)Edit in Standard Mode (Q) Im Standardmodus bearbeiten (Q)Effects Effektediff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex 380aaa765..e1f4c19b7 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -975,11 +975,13 @@Draw with the Pen tool (P) or make a work path from a selection. Dibuja con la herramienta Pluma (P) o crea un trazado de trabajo a partir de una selección.Drop an image or PSD anywhere to open it. Suelte una imagen o un PSD en cualquier lugar para abrirlo.Native file drag-and-drop is unavailable El arrastrar y soltar archivos de forma nativa no está disponible en Wayland- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. El arrastrar y soltar archivos de forma nativa aún no está disponible en Wayland. Usa Archivo › Abrir o ejecuta PhotoCraft bajo XWayland con `WAYLAND_DISPLAY= photocraft`.+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. El arrastrar y soltar archivos de forma nativa aún no está disponible en Wayland. Usa Archivo › Abrir, o copia la imagen en tu gestor de archivos y pégala con {paste}.+ To drop files, start PhotoCraft under XWayland: `{command}` Para soltar archivos, inicia PhotoCraft bajo XWayland: `{command}`+ Edit › Paste Edición › PegarDuplicate Layers… Duplicar capas…Duplicate style Duplicar estiloEdit Toolbar… Editar barra de herramientas…- Use File › Open to open an image. Usa Archivo › Abrir para abrir una imagen.+ Use File › Open, or paste a copied image with {paste}. Usa Archivo › Abrir, o pega una imagen copiada con {paste}.Edit in Quick Mask Mode (Q) Editar en modo de máscara rápida (Q)Edit in Standard Mode (Q) Editar en modo estándar (Q)Effects Efectosdiff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex 485e0f552..c0de419d3 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -2464,8 +2464,10 @@Floating point Virgule flottanteUse Global Light Utiliser la lumière globaleNative file drag-and-drop is unavailable Le glisser-déposer natif de fichiers n'est pas disponible- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Le glisser-déposer natif de fichiers n'est pas encore pris en charge sous Wayland. Utilisez Fichier › Ouvrir, ou lancez PhotoCraft sous XWayland avec `WAYLAND_DISPLAY= photocraft`.- Use File › Open to open an image. Utilisez Fichier › Ouvrir pour ouvrir une image.+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Le glisser-déposer natif de fichiers n'est pas encore pris en charge sous Wayland. Utilisez Fichier › Ouvrir, ou copiez l'image dans votre gestionnaire de fichiers et collez-la avec {paste}.+ To drop files, start PhotoCraft under XWayland: `{command}` Pour déposer des fichiers, lancez PhotoCraft sous XWayland : `{command}`+ Edit › Paste Édition › Coller+ Use File › Open, or paste a copied image with {paste}. Utilisez Fichier › Ouvrir, ou collez une image copiée avec {paste}.Mixer Brush Tool Outil Pinceau mélangeurInvalid {mode} profile Profil {mode} non valideUnnamed {mode} profile Profil {mode} sans nomdiff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsvindex 3796811ba..86a9d98e0 100644--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@ -2453,8 +2453,10 @@Floating point Titik mengambangUse Global Light Gunakan Cahaya GlobalNative file drag-and-drop is unavailable Seret dan lepas berkas native tidak tersedia- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Seret dan lepas berkas native belum didukung di Wayland. Gunakan Berkas › Buka, atau jalankan PhotoCraft di XWayland dengan `WAYLAND_DISPLAY= photocraft`.- Use File › Open to open an image. Gunakan Berkas › Buka untuk membuka gambar.+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Seret dan lepas berkas native belum didukung di Wayland. Gunakan Berkas › Buka, atau salin gambar di pengelola berkas lalu tempel dengan {paste}.+ To drop files, start PhotoCraft under XWayland: `{command}` Untuk menjatuhkan berkas, jalankan PhotoCraft di XWayland: `{command}`+ Edit › Paste Edit › Tempel+ Use File › Open, or paste a copied image with {paste}. Gunakan Berkas › Buka, atau tempel gambar yang disalin dengan {paste}.Mixer Brush Tool Alat Kuas PencampurInvalid {mode} profile Profil {mode} tidak validUnnamed {mode} profile Profil {mode} tanpa namadiff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex 18fe61bac..162b3fc10 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -974,11 +974,13 @@Draw with the Pen tool (P) or make a work path from a selection. Disegna con Penna (P) o crea un tracciato di lavoro da una selezione.Drop an image or PSD anywhere to open it. Trascina un'immagine o PSD ovunque per aprirlo.Native file drag-and-drop is unavailable Il drag-and-drop nativo file non è disponibile su Wayland- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Il drag-and-drop nativo non è ancora supportato su Wayland. Usa File › Apri, o avvia PhotoCraft sotto XWayland con `WAYLAND_DISPLAY= photocraft`.+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Il drag-and-drop nativo non è ancora supportato su Wayland. Usa File › Apri, oppure copia l'immagine nel file manager e incollala con {paste}.+ To drop files, start PhotoCraft under XWayland: `{command}` Per trascinare file, avvia PhotoCraft sotto XWayland: `{command}`+ Edit › Paste Modifica › IncollaDuplicate Layers… Duplica livelli…Duplicate style Duplica stileEdit Toolbar… Modifica barra strumenti…- Use File › Open to open an image. Usa File › Apri per aprire un'immagine.+ Use File › Open, or paste a copied image with {paste}. Usa File › Apri, oppure incolla un'immagine copiata con {paste}.Edit in Quick Mask Mode (Q) Modifica in maschera veloce (Q)Edit in Standard Mode (Q) Modifica in modalità standard (Q)Effects Effettidiff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex d8af1f816..b3f30cd47 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -980,11 +980,13 @@Draw with the Pen tool (P) or make a work path from a selection. ペンツール(P)で描くか、選択範囲から作業用パスを作成します。Drop an image or PSD anywhere to open it. 画像や PSD をここにドロップすると開きます。Native file drag-and-drop is unavailable Wayland ではネイティブのファイルドラッグ&ドロップを利用できません- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Wayland ではネイティブのファイルドラッグ&ドロップはまだ利用できません。[ファイル › 開く] を使うか、`WAYLAND_DISPLAY= photocraft` を指定して PhotoCraft を XWayland 上で起動してください。+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Wayland ではネイティブのファイルドラッグ&ドロップはまだ利用できません。[ファイル › 開く] を使うか、ファイルマネージャーで画像をコピーして {paste} で貼り付けてください。+ To drop files, start PhotoCraft under XWayland: `{command}` ファイルをドロップするには、XWayland 上で PhotoCraft を起動してください: `{command}`+ Edit › Paste [編集 › 貼り付け]Duplicate Layers… レイヤーを複製…Duplicate style スタイルを複製Edit Toolbar… ツールバーを編集…- Use File › Open to open an image. 画像を開くには [ファイル › 開く] を使ってください。+ Use File › Open, or paste a copied image with {paste}. [ファイル › 開く] を使うか、コピーした画像を {paste} で貼り付けてください。Edit in Quick Mask Mode (Q) クイックマスクモードで編集(Q)Edit in Standard Mode (Q) 標準モードで編集(Q)Effects 効果diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsvindex 194416762..e10cfeb8c 100644--- a/crates/ui-egui/src/i18n/ko.tsv+++ b/crates/ui-egui/src/i18n/ko.tsv@@ -1995,8 +1995,10 @@Floating point 부동 소수점Use Global Light 전체 조명 사용Native file drag-and-drop is unavailable 파일 드래그 앤 드롭을 사용할 수 없습니다- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Wayland에서는 아직 파일 드래그 앤 드롭을 지원하지 않습니다. 파일 › 열기를 사용하거나 `WAYLAND_DISPLAY= photocraft`로 XWayland에서 PhotoCraft를 실행하세요.- Use File › Open to open an image. 파일 › 열기에서 이미지를 여세요.+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Wayland에서는 아직 파일 드래그 앤 드롭을 지원하지 않습니다. 파일 › 열기를 사용하거나, 파일 관리자에서 이미지를 복사한 뒤 {paste}(으)로 붙여넣으세요.+ To drop files, start PhotoCraft under XWayland: `{command}` 파일을 끌어다 놓으려면 XWayland에서 PhotoCraft를 실행하세요: `{command}`+ Edit › Paste 편집 › 붙여넣기+ Use File › Open, or paste a copied image with {paste}. 파일 › 열기를 사용하거나, 복사한 이미지를 {paste}(으)로 붙여넣으세요.Invalid {mode} profile 유효하지 않은 {mode} 프로파일Unnamed {mode} profile 이름 없는 {mode} 프로파일Show bounding box when dragging layer 레이어를 드래그할 때 테두리 상자 표시diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsvindex 7f1942ac4..59ae547b4 100644--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@ -3194,6 +3194,10 @@ cameraRaw Roughness ChropowatośćMore documents Więcej dokumentówDeveloping {name} Wywoływanie {name}Camera Raw ({name}) Camera Raw ({name})+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Natywne przeciąganie i upuszczanie plików nie jest jeszcze obsługiwane w Wayland. Użyj Plik › Otwórz albo skopiuj obraz w menedżerze plików i wklej go za pomocą {paste}.+ To drop files, start PhotoCraft under XWayland: `{command}` Aby upuszczać pliki, uruchom PhotoCraft pod XWayland: `{command}`+ Edit › Paste Edycja › Wklej+ Use File › Open, or paste a copied image with {paste}. Użyj Plik › Otwórz albo wklej skopiowany obraz za pomocą {paste}.# Swatches panelCreate new swatch Utwórz nową próbkędiff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex 884156e9a..6d0b464a7 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -2460,8 +2460,10 @@Floating point Ponto flutuanteUse Global Light Usar luz globalNative file drag-and-drop is unavailable Arrastar e soltar arquivos nativo indisponível- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Arrastar e soltar arquivos nativo ainda não é compatível com Wayland. Use Arquivo › Abrir ou execute o PhotoCraft no XWayland com `WAYLAND_DISPLAY= photocraft`.- Use File › Open to open an image. Use Arquivo › Abrir para abrir uma imagem.+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Arrastar e soltar arquivos nativo ainda não é compatível com Wayland. Use Arquivo › Abrir ou copie a imagem no gerenciador de arquivos e cole-a com {paste}.+ To drop files, start PhotoCraft under XWayland: `{command}` Para soltar arquivos, execute o PhotoCraft no XWayland: `{command}`+ Edit › Paste Editar › Colar+ Use File › Open, or paste a copied image with {paste}. Use Arquivo › Abrir ou cole uma imagem copiada com {paste}.Mixer Brush Tool Ferramenta Pincel misturadorInvalid {mode} profile Perfil {mode} inválidoUnnamed {mode} profile Perfil {mode} sem nomediff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex e4fa04d3a..9626313ba 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -1387,9 +1387,11 @@BLANK DOCUMENT PRESETS ({n}) НАБОРЫ ПУСТЫХ ДОКУМЕНТОВ ({n})Create a new document or open an existing file. Создайте новый документ или откройте существующий файл.Drop an image or PSD anywhere to open it. Перетащите изображение или PSD в любое место окна, чтобы открыть.- Use File › Open to open an image. Чтобы открыть изображение, выберите Файл › Открыть.+ Use File › Open, or paste a copied image with {paste}. Выберите Файл › Открыть или вставьте скопированное изображение с помощью {paste}.Native file drag-and-drop is unavailable Нативное перетаскивание файлов в Wayland недоступно- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Нативное перетаскивание файлов в Wayland пока не поддерживается. Откройте файл через Файл › Открыть или запустите PhotoCraft в XWayland с `WAYLAND_DISPLAY= photocraft`.+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Нативное перетаскивание файлов в Wayland пока не поддерживается. Откройте файл через Файл › Открыть или скопируйте изображение в файловом менеджере и вставьте его с помощью {paste}.+ To drop files, start PhotoCraft under XWayland: `{command}` Чтобы перетаскивать файлы, запустите PhotoCraft в XWayland: `{command}`+ Edit › Paste Редактирование › ВставитьPhoto ФотоPrint ПечатьArt & Illustration Искусство и иллюстрацияdiff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsvindex 722d9b525..7df29203a 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -980,11 +980,13 @@Draw with the Pen tool (P) or make a work path from a selection. 使用钢笔工具(P)绘制,或从选区创建工作路径。Drop an image or PSD anywhere to open it. 将图像或 PSD 拖放到任意位置即可打开。Native file drag-and-drop is unavailable Wayland 上不支持原生文件拖放- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Wayland 尚不支持原生文件拖放。请使用“文件 › 打开”,或通过 `WAYLAND_DISPLAY= photocraft` 在 XWayland 下运行 PhotoCraft。+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Wayland 尚不支持原生文件拖放。请使用“文件 › 打开”,或在文件管理器中复制图像后使用 {paste} 粘贴。+ To drop files, start PhotoCraft under XWayland: `{command}` 要拖放文件,请在 XWayland 下启动 PhotoCraft:`{command}`+ Edit › Paste “编辑 › 粘贴”Duplicate Layers… 复制图层…Duplicate style 复制样式Edit Toolbar… 编辑工具栏…- Use File › Open to open an image. 使用“文件 › 打开”打开图像。+ Use File › Open, or paste a copied image with {paste}. 请使用“文件 › 打开”,或使用 {paste} 粘贴复制的图像。Edit in Quick Mask Mode (Q) 在快速蒙版模式下编辑 (Q)Edit in Standard Mode (Q) 在标准模式下编辑 (Q)Effects 效果diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex 9649e3c1a..877862127 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -981,11 +981,13 @@Draw with the Pen tool (P) or make a work path from a selection. 使用筆型工具 (P) 繪製,或從選取範圍建立工作路徑。Drop an image or PSD anywhere to open it. 將影像或 PSD 拖放到任何位置即可開啟。Native file drag-and-drop is unavailable Wayland 不支援原生檔案拖放- Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Wayland 尚未支援原生檔案拖放。請使用「檔案 › 開啟」,或透過 `WAYLAND_DISPLAY= photocraft` 在 XWayland 下執行 PhotoCraft。+ Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Wayland 尚未支援原生檔案拖放。請使用「檔案 › 開啟」,或在檔案管理員中複製影像後使用 {paste} 貼上。+ To drop files, start PhotoCraft under XWayland: `{command}` 若要拖放檔案,請在 XWayland 下啟動 PhotoCraft:`{command}`+ Edit › Paste 「編輯 › 貼上」Duplicate Layers… 複製圖層…Duplicate style 複製樣式Edit Toolbar… 編輯工具列…- Use File › Open to open an image. 使用「檔案 › 開啟」開啟影像。+ Use File › Open, or paste a copied image with {paste}. 請使用「檔案 › 開啟」,或使用 {paste} 貼上複製的影像。Edit in Quick Mask Mode (Q) 在快速遮色片模式下編輯 (Q)Edit in Standard Mode (Q) 在標準模式下編輯 (Q)Effects 效果diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 8978f95d4..106b061ce 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -267,6 +267,9 @@ pub struct Services {pub save_prefs: Option<SaveTextFn>,/// The native window is connected directly to a Wayland compositor.pub is_wayland: bool,+ /// On Wayland, the shell command that starts this install under XWayland, where native file+ /// drops work (#386); `None` when there is no X server to run it on.+ pub xwayland_command: Option<String>,/// Crash-recovery autosave (Preferences › File Handling) and recovery at launch.pub autosave: Option<AutosaveFn>,pub discard_autosave: Option<DiscardAutosaveFn>,diff --git a/crates/ui-egui/src/notices.rs b/crates/ui-egui/src/notices.rsindex 8c47b760c..b79512c03 100644--- a/crates/ui-egui/src/notices.rs+++ b/crates/ui-egui/src/notices.rs@@ -27,12 +27,23 @@ pub struct Notice {/// Preference key to set when this notice is dismissed.#[serde(default)]pub dismiss_pref: Option<String>,+ /// `{name}` values filled into the title and lines after they are translated.+ #[serde(default, skip_serializing_if = "Vec::is_empty")]+ pub args: Vec<(String, String)>,+}++impl Notice {+ /// `s` (the title or a line) in the current language, with [`Notice::args`] filled in.+ pub fn text(&self, s: &str) -> String {+ let args: Vec<(&str, &str)> = self.args.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();+ crate::i18n::fmt(crate::i18n::t(s), &args)+ }}/// Show a notice (newest last); returns its id.pub fn post(app: &mut PhotocraftApp, title: impl Into<String>, lines: Vec<String>, error: bool, dismiss_pref: Option<&str>) -> u64 {let id = app.ui.alloc_id();- app.ui.notices.push(Notice { id, title: title.into(), lines, error, dismiss_pref: dismiss_pref.map(str::to_owned) });+ app.ui.notices.push(Notice { id, title: title.into(), lines, error, dismiss_pref: dismiss_pref.map(str::to_owned), args: Vec::new() });cap_notices(app);id}@@ -44,7 +55,14 @@ fn cap_notices(app: &mut PhotocraftApp) {}}-/// Show the Wayland-specific fallback guidance unless the user dismissed it in preferences.+/// How to paste in hints: Edit › Paste's effective shortcut (`Ctrl+V`), else the menu path.+pub(crate) fn paste_hint(app: &PhotocraftApp) -> String {+ crate::shortcuts::shortcut_label(app, "edit.paste").unwrap_or_else(|| tl!("Edit › Paste").to_string())+}++/// Show the Wayland-specific fallback guidance unless the user dismissed it in preferences: winit+/// 0.30 delivers no file drops on Wayland, so point at File › Open, pasting a copied file, and the+/// command that starts this install under XWayland (where drops work), when there is one.pub fn wayland_file_drop_guidance(app: &mut PhotocraftApp) {if !app.services.is_wayland|| app.session.prefs().dialogs.get(WAYLAND_FILE_DROP_DISMISSED).and_then(serde_json::Value::as_bool) == Some(true)@@ -52,16 +70,20 @@ pub fn wayland_file_drop_guidance(app: &mut PhotocraftApp) {{return;}- post(- app,- "Native file drag-and-drop is unavailable",- vec![- "Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`."- .into(),- ],- false,- Some(WAYLAND_FILE_DROP_DISMISSED),- );+ // English templates, translated and filled in when drawn, so the notice follows a language change.+ let mut lines = vec![+ "Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}."+ .to_owned(),+ ];+ let mut args = vec![("paste".to_owned(), paste_hint(app))];+ if let Some(command) = &app.services.xwayland_command {+ lines.push("To drop files, start PhotoCraft under XWayland: `{command}`".to_owned());+ args.push(("command".to_owned(), command.clone()));+ }+ let id = post(app, "Native file drag-and-drop is unavailable", lines, false, Some(WAYLAND_FILE_DROP_DISMISSED));+ if let Some(notice) = app.ui.notices.iter_mut().find(|notice| notice.id == id) {+ notice.args = args;+ }}/// A full refresh of document `doc` fell back to the CPU compositor (`reason`, the GPU's) and took@@ -140,7 +162,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {.show(ui, |ui| {ui.set_width(340.0);ui.horizontal(|ui| {- let title = egui::RichText::new(crate::i18n::t(&n.title)).strong().color(if n.error { t.warning } else { t.text });+ let title = egui::RichText::new(n.text(&n.title)).strong().color(if n.error { t.warning } else { t.text });ui.add(egui::Label::new(title).wrap());ui.with_layout(egui::Layout::right_to_left(egui::Align::Min), |ui| {if ui.add(egui::Button::new(egui::RichText::new("×").color(t.text_dim)).frame(false)).on_hover_text(tl!("Dismiss")).clicked() {@@ -149,7 +171,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {});});for line in n.lines.iter().take(MAX_LINES) {- let line = crate::i18n::t(line);+ let line = n.text(line);ui.add(egui::Label::new(egui::RichText::new(format!("• {line}")).color(t.text_dim)).wrap());}if n.lines.len() > MAX_LINES {@@ -174,8 +196,10 @@ mod tests {#[test]fn wayland_guidance_follows_language_changes_after_startup() {- let app = PhotocraftApp::new(Session::new(), Services { is_wayland: true, ..Default::default() });+ let command = Some("WAYLAND_DISPLAY= photocraft".to_string());+ let app = PhotocraftApp::new(Session::new(), Services { is_wayland: true, xwayland_command: command, ..Default::default() });let notice = &app.ui.notices[0];+ assert!(notice.lines.iter().all(|line| crate::i18n::tr(crate::i18n::Lang::from_code("es").unwrap(), line) != line), "every line is a catalog template");// the notice keeps its English source text and is translated when drawn (`i18n::t` with// the current language); `tr` with an explicit language leaves the process-wide language,// which other tests running in parallel draw with, untouched@@ -185,17 +209,26 @@ mod tests {assert_eq!(crate::i18n::tr(crate::i18n::Lang::EN, ¬ice.title), "Native file drag-and-drop is unavailable");}+ /// A notice's lines in English with their arguments filled in.+ fn english(notice: &Notice) -> String {+ let args: Vec<(&str, &str)> = notice.args.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();+ notice.lines.iter().map(|line| crate::i18n::fmt(line, &args)).collect::<Vec<_>>().join(" ")+ }+#[test]fn wayland_guidance_is_only_shown_in_wayland_sessions() {- let mut app = PhotocraftApp::new(Session::new(), Services { is_wayland: true, ..Default::default() });+ let command = Some("WAYLAND_DISPLAY= '/apps/Photo Craft.AppImage'".to_string());+ let mut app = PhotocraftApp::new(Session::new(), Services { is_wayland: true, xwayland_command: command, ..Default::default() });assert_eq!(app.ui.notices.len(), 1);assert_eq!(app.ui.notices[0].title, "Native file drag-and-drop is unavailable");- let guidance = app.ui.notices[0].lines.join(" ");+ let guidance = english(&app.ui.notices[0]);assert!(guidance.contains("not supported on Wayland yet"));assert!(guidance.contains("File › Open"));- assert!(!guidance.contains("Ctrl+V"));- assert!(guidance.contains("XWayland"));- assert!(guidance.contains("WAYLAND_DISPLAY= photocraft"));+ // Pasting a copied file works on Wayland (#338), so the notice offers it.+ let paste = paste_hint(&app);+ assert!(guidance.contains(&format!("paste it with {paste}")), "{guidance}");+ // The relaunch command is the one for this install (an AppImage here), not a guess.+ assert!(guidance.contains("under XWayland: `WAYLAND_DISPLAY= '/apps/Photo Craft.AppImage'`"), "{guidance}");assert_eq!(app.ui.notices[0].dismiss_pref.as_deref(), Some(WAYLAND_FILE_DROP_DISMISSED));for i in 0..MAX_NOTICES {post(&mut app, format!("Transient {i}"), Vec::new(), false, None);@@ -207,6 +240,24 @@ mod tests {assert!(app.ui.notices.is_empty());}+ #[test]+ fn wayland_guidance_without_an_x_server_does_not_suggest_xwayland() {+ let app = PhotocraftApp::new(Session::new(), Services { is_wayland: true, ..Default::default() });+ let guidance = english(&app.ui.notices[0]);+ assert!(guidance.contains("File › Open"));+ assert!(!guidance.contains("XWayland"), "{guidance}");+ }++ #[test]+ fn paste_hint_follows_the_shortcut_and_falls_back_to_the_menu() {+ let mut app = PhotocraftApp::new(Session::new(), Services::default());+ assert_eq!(paste_hint(&app), crate::shortcuts::shortcut_label(&app, "edit.paste").unwrap());+ app.session.prefs.edit(|prefs| {+ prefs.shortcuts.insert("edit.paste".into(), String::new());+ });+ assert_eq!(paste_hint(&app), "Edit › Paste");+ }+#[test]fn dismissing_wayland_guidance_persists_across_launches() {let saved = Arc::new(Mutex::new(None::<String>));