electron/lib/browser/api/system-preferences.ts

37 lines
1.4 KiB
TypeScript
Raw Normal View History

import { deprecate } from 'electron/main';
const { systemPreferences } = process._linkedBinding('electron_browser_system_preferences');
if ('getAppLevelAppearance' in systemPreferences) {
2020-03-20 20:28:31 +00:00
const nativeALAGetter = systemPreferences.getAppLevelAppearance;
const nativeALASetter = systemPreferences.setAppLevelAppearance;
Object.defineProperty(systemPreferences, 'appLevelAppearance', {
get: () => nativeALAGetter.call(systemPreferences),
set: (appearance) => nativeALASetter.call(systemPreferences, appearance)
2020-03-20 20:28:31 +00:00
});
}
if ('getEffectiveAppearance' in systemPreferences) {
const nativeEAGetter = systemPreferences.getEffectiveAppearance;
Object.defineProperty(systemPreferences, 'effectiveAppearance', {
get: () => nativeEAGetter.call(systemPreferences)
2020-03-20 20:28:31 +00:00
});
}
systemPreferences.isDarkMode = deprecate.moveAPI(
systemPreferences.isDarkMode,
'systemPreferences.isDarkMode()',
'nativeTheme.shouldUseDarkColors'
2020-03-20 20:28:31 +00:00
);
systemPreferences.isInvertedColorScheme = deprecate.moveAPI(
systemPreferences.isInvertedColorScheme,
'systemPreferences.isInvertedColorScheme()',
'nativeTheme.shouldUseInvertedColorScheme'
2020-03-20 20:28:31 +00:00
);
systemPreferences.isHighContrastColorScheme = deprecate.moveAPI(
systemPreferences.isHighContrastColorScheme,
'systemPreferences.isHighContrastColorScheme()',
'nativeTheme.shouldUseHighContrastColors'
2020-03-20 20:28:31 +00:00
);
export default systemPreferences;