System File Chooser: Linux: show file dialog in dark if current FlatLaf theme is dark (PR #988)

This commit is contained in:
Karl Tauber
2025-12-02 14:11:10 +01:00
parent 58e073a05b
commit 9e8b8697d1
6 changed files with 60 additions and 10 deletions

View File

@@ -37,7 +37,7 @@ import com.formdev.flatlaf.util.SystemInfo;
*/
public class FlatNativeLinuxLibrary
{
private static int API_VERSION_LINUX = 3002;
private static int API_VERSION_LINUX = 3003;
/**
* Checks whether native library is loaded/available.
@@ -178,6 +178,7 @@ public class FlatNativeLinuxLibrary
* to avoid blocking the AWT event dispatching thread.
*
* @param owner the owner of the file dialog; or {@code null}
* @param dark preferred appearance of the file dialog: {@code 1} = prefer dark, {@code 0} = prefer light, {@code -1} = default
* @param open if {@code true}, shows the open dialog; if {@code false}, shows the save dialog
* @param title text displayed in dialog title; or {@code null}
* @param okButtonLabel text displayed in default button; or {@code null}.
@@ -199,7 +200,7 @@ public class FlatNativeLinuxLibrary
*
* @since 3.7
*/
public native static String[] showFileChooser( Window owner, boolean open,
public native static String[] showFileChooser( Window owner, int dark, boolean open,
String title, String okButtonLabel, String currentName, String currentFolder,
int optionsSet, int optionsClear, FileChooserCallback callback,
int fileTypeIndex, String... fileTypes );

View File

@@ -1085,6 +1085,7 @@ public class SystemFileChooser
@Override
String[] showSystemDialog( Window owner, SystemFileChooser fc ) {
int dark = FlatLaf.isLafDark() ? 1 : 0;
boolean open = (fc.getDialogType() == OPEN_DIALOG);
String approveButtonText = fc.getApproveButtonText();
int approveButtonMnemonic = fc.getApproveButtonMnemonic();
@@ -1162,7 +1163,7 @@ public class SystemFileChooser
} : null;
// show system file dialog
return FlatNativeLinuxLibrary.showFileChooser( owner, open,
return FlatNativeLinuxLibrary.showFileChooser( owner, dark, open,
fc.getDialogTitle(), approveButtonText, currentName, currentFolder,
optionsSet, optionsClear, callback,
fileTypeIndex, fileTypes.toArray( new String[fileTypes.size()] ) );