Skip to content

Commit

Permalink
Refactored function to get status of menus in MacOSX
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Sep 28, 2017
1 parent 59a57a9 commit 369b23a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ public boolean handleQuit() {
// Save out the current prefs state
PreferencesData.save();

if (!OSUtils.isMacOS() || System.getProperty("apple.laf.useScreenMenuBar") == "false") {
if (!OSUtils.hasMacOSStyleMenus()) {
// If this was fired from the menu or an AppleEvent (the Finder),
// then Mac OS X will send the terminate signal itself.
System.exit(0);
Expand Down
6 changes: 3 additions & 3 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ public void actionPerformed(ActionEvent e) {
fileMenu.add(item);

// macosx already has its own preferences and quit menu
if (!OSUtils.isMacOS() || System.getProperty("apple.laf.useScreenMenuBar") == "false") {
if (!OSUtils.hasMacOSStyleMenus()) {
fileMenu.addSeparator();

item = newJMenuItem(tr("Preferences"), ',');
Expand Down Expand Up @@ -1252,7 +1252,7 @@ public void actionPerformed(ActionEvent e) {
menu.add(item);

// macosx already has its own about menu
if (!OSUtils.isMacOS() || System.getProperty("apple.laf.useScreenMenuBar") == "false") {
if (!OSUtils.hasMacOSStyleMenus()) {
menu.addSeparator();
item = new JMenuItem(tr("About Arduino"));
item.addActionListener(new ActionListener() {
Expand Down Expand Up @@ -1812,7 +1812,7 @@ protected boolean checkModified() {
String prompt = I18n.format(tr("Save changes to \"{0}\"? "),
sketch.getName());

if (!OSUtils.isMacOS() || System.getProperty("apple.laf.useScreenMenuBar") == "false") {
if (!OSUtils.hasMacOSStyleMenus()) {
int result =
JOptionPane.showConfirmDialog(this, prompt, tr("Close"),
JOptionPane.YES_NO_CANCEL_OPTION,
Expand Down
3 changes: 3 additions & 0 deletions arduino-core/src/processing/app/helpers/OSUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ static public boolean isMacOS() {
return System.getProperty("os.name").contains("Mac");
}

static public boolean hasMacOSStyleMenus() {
return OSUtils.isMacOS() && System.getProperty("apple.laf.useScreenMenuBar").equals("true");
}
}

0 comments on commit 369b23a

Please sign in to comment.