Skip to content
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

Fix menu bar gone on macOS #10967

Merged
merged 2 commits into from
Mar 4, 2024
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
5 changes: 2 additions & 3 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.jabref.gui.Globals;
import org.jabref.gui.autocompleter.AutoCompleteFirstNameMode;
import org.jabref.gui.autocompleter.AutoCompletePreferences;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.gui.duplicationFinder.DuplicateResolverDialog;
import org.jabref.gui.entryeditor.EntryEditorPreferences;
import org.jabref.gui.externalfiletype.ExternalFileType;
Expand Down Expand Up @@ -710,7 +709,6 @@ private JabRefPreferences() {
defaults.put(WARN_BEFORE_OVERWRITING_KEY, Boolean.TRUE);
defaults.put(CONFIRM_DELETE, Boolean.TRUE);
defaults.put(CONFIRM_LINKED_FILE_DELETE, Boolean.TRUE);
defaults.put(TRASH_INSTEAD_OF_DELETE, JabRefDesktop.moveToTrashSupported());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there a true be put?

OK, what if the OS does not support move to trash?

This were my thoughts. Therefore, I made the default rely on the current OS's capabilities.

Copy link
Member Author

@Siedlerchr Siedlerchr Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly this line broke the menu bar! That's why I moved the check. I guess it has something to do with the initalization order of javafx <-> awt because we are here in a static context early at startup. That's why I moved the check down where the value is first read

defaults.put(DEFAULT_CITATION_KEY_PATTERN, "[auth][year]");
defaults.put(UNWANTED_CITATION_KEY_CHARACTERS, "-`ʹ:!;?^+");
defaults.put(RESOLVE_STRINGS_FOR_FIELDS, "author;booktitle;editor;editora;editorb;editorc;institution;issuetitle;journal;journalsubtitle;journaltitle;mainsubtitle;month;publisher;shortauthor;shorteditor;subtitle;titleaddon");
Expand Down Expand Up @@ -2204,7 +2202,8 @@ public FilePreferences getFilePreferences() {
// We choose the data directory, because a ".bak" file should survive cache cleanups
getPath(BACKUP_DIRECTORY, OS.getNativeDesktop().getBackupDirectory()),
getBoolean(CONFIRM_LINKED_FILE_DELETE),
getBoolean(TRASH_INSTEAD_OF_DELETE));
// We make use of the fallback, because we need AWT being initialized, which is not the case at the constructor JabRefPreferences()
getBoolean(TRASH_INSTEAD_OF_DELETE, OS.getNativeDesktop().moveToTrashSupported()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. Can this be enabled in the preferences even though it is not supported?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was already wrong before the chris change. 😉 isSupported is logic, not a preferences option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grafik

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moveToTrash.setDisable(!OS.getNativeDesktop().moveToTrashSupported());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevertheless, the preference should not be true if it is not supported system-wide. I thought, in #10591 I implemented it as: "default = supported by OS" and then "disabled/enabled = supported by OS".

Maybe an additional line:

if (!OS.getNativeDesktop().moveToTrashSupported()) {
  moveToTrash.setValue(false)
}

to ensure that it is both disabled and false if trash is not supported.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was in defaults. but this broke the system menu bar in macOS. This is why i removed it in defaults and just added it as fallback value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part exactly broke the menu bar? The issue did not show any exception, so I cannot understand the root cause.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion would be just to make true the default, but it's greyed out in the preferences and where moveToTrash is used, there is an additional check, if this is supported. Check could go to JabRefDesktop#moveToTrash or sthg and then delete instead.


EasyBind.listen(getInternalPreferences().getUserAndHostProperty(), (obs, oldValue, newValue) -> filePreferences.getUserAndHostProperty().setValue(newValue));
EasyBind.listen(filePreferences.mainFileDirectoryProperty(), (obs, oldValue, newValue) -> put(MAIN_FILE_DIRECTORY, newValue));
Expand Down
Loading