Add drag-and-drop import for .pixstrip-preset files
- Workflow page accepts .pixstrip-preset file drops - Dropped preset files are imported and applied to current config - Saved to user presets automatically on successful import
This commit is contained in:
@@ -251,6 +251,26 @@ pub fn build_workflow_page(state: &AppState) -> adw::NavigationPage {
|
|||||||
.child(&scrolled)
|
.child(&scrolled)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
// Drop target for .pixstrip-preset files
|
||||||
|
let drop_target = gtk::DropTarget::new(gtk::gio::File::static_type(), gtk::gdk::DragAction::COPY);
|
||||||
|
let jc_drop = state.job_config.clone();
|
||||||
|
drop_target.connect_drop(move |_target, value, _x, _y| {
|
||||||
|
if let Ok(file) = value.get::<gtk::gio::File>() {
|
||||||
|
if let Some(path) = file.path() {
|
||||||
|
if path.extension().and_then(|e| e.to_str()) == Some("pixstrip-preset") {
|
||||||
|
let store = pixstrip_core::storage::PresetStore::new();
|
||||||
|
if let Ok(preset) = store.import_from_file(&path) {
|
||||||
|
apply_preset_to_config(&mut jc_drop.borrow_mut(), &preset);
|
||||||
|
let _ = store.save(&preset);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
});
|
||||||
|
clamp.add_controller(drop_target);
|
||||||
|
|
||||||
adw::NavigationPage::builder()
|
adw::NavigationPage::builder()
|
||||||
.title("Choose a Workflow")
|
.title("Choose a Workflow")
|
||||||
.tag("step-workflow")
|
.tag("step-workflow")
|
||||||
|
|||||||
Reference in New Issue
Block a user