2020-03-20 20:28:31 +00:00
|
|
|
import { EventEmitter } from 'events';
|
2020-07-13 16:58:49 +00:00
|
|
|
import { deprecate } from 'electron/main';
|
2020-06-23 03:32:45 +00:00
|
|
|
const { systemPreferences, SystemPreferences } = process._linkedBinding('electron_browser_system_preferences');
|
2019-08-14 20:42:55 +00:00
|
|
|
|
|
|
|
// SystemPreferences is an EventEmitter.
|
2020-03-20 20:28:31 +00:00
|
|
|
Object.setPrototypeOf(SystemPreferences.prototype, EventEmitter.prototype);
|
|
|
|
EventEmitter.call(systemPreferences);
|
2019-08-14 20:42:55 +00:00
|
|
|
|
2020-03-18 01:06:52 +00:00
|
|
|
if ('getAppLevelAppearance' in systemPreferences) {
|
2020-03-20 20:28:31 +00:00
|
|
|
const nativeALAGetter = systemPreferences.getAppLevelAppearance;
|
|
|
|
const nativeALASetter = systemPreferences.setAppLevelAppearance;
|
2020-03-18 01:06:52 +00:00
|
|
|
Object.defineProperty(SystemPreferences.prototype, 'appLevelAppearance', {
|
|
|
|
get: () => nativeALAGetter.call(systemPreferences),
|
|
|
|
set: (appearance) => nativeALASetter.call(systemPreferences, appearance)
|
2020-03-20 20:28:31 +00:00
|
|
|
});
|
2019-08-14 20:42:55 +00:00
|
|
|
}
|
|
|
|
|
2020-03-18 01:06:52 +00:00
|
|
|
if ('getEffectiveAppearance' in systemPreferences) {
|
2020-03-20 20:28:31 +00:00
|
|
|
const nativeEAGetter = systemPreferences.getAppLevelAppearance;
|
2020-03-18 01:06:52 +00:00
|
|
|
Object.defineProperty(SystemPreferences.prototype, 'effectiveAppearance', {
|
|
|
|
get: () => nativeEAGetter.call(systemPreferences)
|
2020-03-20 20:28:31 +00:00
|
|
|
});
|
2019-08-14 20:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SystemPreferences.prototype.isDarkMode = deprecate.moveAPI(
|
|
|
|
SystemPreferences.prototype.isDarkMode,
|
|
|
|
'systemPreferences.isDarkMode()',
|
|
|
|
'nativeTheme.shouldUseDarkColors'
|
2020-03-20 20:28:31 +00:00
|
|
|
);
|
2019-08-14 20:42:55 +00:00
|
|
|
SystemPreferences.prototype.isInvertedColorScheme = deprecate.moveAPI(
|
|
|
|
SystemPreferences.prototype.isInvertedColorScheme,
|
|
|
|
'systemPreferences.isInvertedColorScheme()',
|
|
|
|
'nativeTheme.shouldUseInvertedColorScheme'
|
2020-03-20 20:28:31 +00:00
|
|
|
);
|
2019-08-14 20:42:55 +00:00
|
|
|
SystemPreferences.prototype.isHighContrastColorScheme = deprecate.moveAPI(
|
|
|
|
SystemPreferences.prototype.isHighContrastColorScheme,
|
|
|
|
'systemPreferences.isHighContrastColorScheme()',
|
|
|
|
'nativeTheme.shouldUseHighContrastColors'
|
2020-03-20 20:28:31 +00:00
|
|
|
);
|
2019-08-14 20:42:55 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
module.exports = systemPreferences;
|