Skip to content

Commit

Permalink
Python shell window: prevent more than one window from launching
Browse files Browse the repository at this point in the history
  • Loading branch information
epilys committed Mar 21, 2023
1 parent 9f7c4aa commit 5044779
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,21 @@ impl ApplicationInner {
}));
#[cfg(feature = "python")]
{
use std::sync::atomic::{AtomicBool, Ordering};

let state = Rc::new(AtomicBool::new(false));
let shell = gtk::gio::SimpleAction::new("shell", None);
shell.connect_activate(glib::clone!(@weak obj => move |_, _| {
// [ref:FIXME]: prevent more than one window from launching.
crate::api::shell::new_shell_window(obj).present();
if state.load(Ordering::SeqCst) {
return;
}
state.store(true, Ordering::SeqCst);
let window = crate::api::shell::new_shell_window(obj);
let state_destroy = state.clone();
window.connect_destroy(move |_| {
state_destroy.store(false, Ordering::SeqCst);
});
window.present();
}));
application.add_action(&shell);
}
Expand Down

0 comments on commit 5044779

Please sign in to comment.