Skip to content

Commit

Permalink
Merge pull request #39 from sparshg/shortcuts
Browse files Browse the repository at this point in the history
fix shortcuts on MacOS
  • Loading branch information
Spydr06 authored Oct 4, 2023
2 parents 8559ea5 + 6e249db commit acf5269
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/application/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,23 @@ impl Application {

pub(self) fn setup_gactions(&self) {
gactions::ACTIONS.iter().for_each(|gaction| {
let mut accels = gaction.accels().to_vec();
let temp: Vec<String>;
if cfg!(target_os = "macos") {
temp = gaction
.accels()
.iter()
.map(|s| s.replace("<primary>", "<meta>"))
.collect::<Vec<String>>();
accels = temp.iter().map(|x| &**x).collect::<Vec<&str>>();
}
let callback = gaction.callback();
let action = gio::SimpleAction::from(gaction);
action.connect_activate(glib::clone!(
@weak self as app => move |action, parameter| callback(app, action, parameter)
));
self.add_action(&action);
self.set_accels_for_action(&format!("app.{}", gaction.name()), gaction.accels());
self.set_accels_for_action(&format!("app.{}", gaction.name()), &accels);
});
}
}

0 comments on commit acf5269

Please sign in to comment.