Skip to content

Fix cancel not sent for import dialogs #1420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 16 additions & 34 deletions crates/rnote-ui/src/dialogs/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use adw::prelude::*;
use futures::StreamExt;
use gettextrs::gettext;
use gtk4::{
Builder, Button, CallbackAction, FileDialog, FileFilter, Label, Shortcut, ShortcutController,
ShortcutTrigger, ToggleButton, gio, glib, glib::clone, graphene, gsk,
Builder, Button, FileDialog, FileFilter, Label, ToggleButton, gio, glib, glib::clone, graphene,
gsk,
};
use num_traits::ToPrimitive;
use rnote_engine::engine::import::{PdfImportPageSpacing, PdfImportPagesType};
Expand Down Expand Up @@ -475,23 +475,14 @@ pub(crate) async fn dialog_import_pdf_w_prefs(
}));
}));

// Overwrite builtin close shortcut
let controller = ShortcutController::new();
controller.add_shortcut(Shortcut::new(
Some(ShortcutTrigger::parse_string("Escape").unwrap()),
Some(CallbackAction::new(clone!(
#[weak]
import_pdf_button_cancel,
#[upgrade_or]
glib::Propagation::Stop,
move |_, _| {
import_pdf_button_cancel.emit_clicked();

glib::Propagation::Stop
}
))),
// Send a cancel response when the dialog is closed
dialog.connect_closed(clone!(
#[weak]
import_pdf_button_cancel,
move |_| {
import_pdf_button_cancel.emit_clicked();
}
));
dialog.add_controller(controller);

// Present than wait for a response from the dialog
dialog.present(appwindow.root().as_ref());
Expand Down Expand Up @@ -581,23 +572,14 @@ pub(crate) async fn dialog_import_xopp_w_prefs(
}));
}));

// Overwrite builtin close shortcut
let controller = ShortcutController::new();
controller.add_shortcut(Shortcut::new(
Some(ShortcutTrigger::parse_string("Escape").unwrap()),
Some(CallbackAction::new(clone!(
#[weak]
import_xopp_button_cancel,
#[upgrade_or]
glib::Propagation::Stop,
move |_, _| {
import_xopp_button_cancel.emit_clicked();

glib::Propagation::Stop
}
))),
// Send a cancel response when the dialog is closed
dialog.connect_closed(clone!(
#[weak]
import_xopp_button_cancel,
move |_| {
import_xopp_button_cancel.emit_clicked();
}
));
dialog.add_controller(controller);

// Present than wait for a response from the dialog
dialog.present(appwindow.root().as_ref());
Expand Down