Add keep-in-place option for drag-and-drop imports
This commit is contained in:
@@ -64,11 +64,12 @@ pub fn show_drop_dialog(
|
||||
.build();
|
||||
|
||||
dialog.add_response("cancel", &i18n("Cancel"));
|
||||
dialog.add_response("add-only", &i18n("Just add"));
|
||||
dialog.add_response("add-and-integrate", &i18n("Add to app menu"));
|
||||
dialog.add_response("keep-in-place", &i18n("Keep in place"));
|
||||
dialog.add_response("copy-only", &i18n("Copy to Applications"));
|
||||
dialog.add_response("copy-and-integrate", &i18n("Copy & add to menu"));
|
||||
|
||||
dialog.set_response_appearance("add-and-integrate", adw::ResponseAppearance::Suggested);
|
||||
dialog.set_default_response(Some("add-and-integrate"));
|
||||
dialog.set_response_appearance("copy-and-integrate", adw::ResponseAppearance::Suggested);
|
||||
dialog.set_default_response(Some("copy-and-integrate"));
|
||||
dialog.set_close_response("cancel");
|
||||
|
||||
let toast_ref = toast_overlay.clone();
|
||||
@@ -78,7 +79,8 @@ pub fn show_drop_dialog(
|
||||
return;
|
||||
}
|
||||
|
||||
let integrate = response == "add-and-integrate";
|
||||
let copy = response != "keep-in-place";
|
||||
let integrate = response == "copy-and-integrate";
|
||||
let files = files.clone();
|
||||
let toast_ref = toast_ref.clone();
|
||||
let on_complete_ref = on_complete.clone();
|
||||
@@ -86,7 +88,7 @@ pub fn show_drop_dialog(
|
||||
glib::spawn_future_local(async move {
|
||||
// Phase 1: Fast registration (copy + DB upsert only)
|
||||
let result = gio::spawn_blocking(move || {
|
||||
register_dropped_files(&files)
|
||||
register_dropped_files(&files, copy)
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -149,6 +151,7 @@ pub fn show_drop_dialog(
|
||||
/// Returns a list of registered files for background analysis.
|
||||
fn register_dropped_files(
|
||||
files: &[PathBuf],
|
||||
copy_to_target: bool,
|
||||
) -> Result<Vec<RegisteredFile>, String> {
|
||||
let db = Database::open().map_err(|e| format!("Failed to open database: {}", e))?;
|
||||
|
||||
@@ -192,8 +195,8 @@ fn register_dropped_files(
|
||||
.unwrap_or(false)
|
||||
});
|
||||
|
||||
let final_path = if in_scan_dir {
|
||||
// Ensure executable even if already in scan dir
|
||||
let final_path = if in_scan_dir || !copy_to_target {
|
||||
// Keep the file where it is; just ensure it's executable
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
Reference in New Issue
Block a user