Move isAeroGlassEnabled and isDarkMode to systemPreferences
This commit is contained in:
parent
d72a0e452f
commit
ddd8eae661
8 changed files with 46 additions and 35 deletions
|
@ -41,7 +41,6 @@
|
|||
|
||||
#if defined(OS_WIN)
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "ui/base/win/shell.h"
|
||||
#endif
|
||||
|
||||
using atom::Browser;
|
||||
|
@ -382,12 +381,6 @@ std::string App::GetLocale() {
|
|||
return l10n_util::GetApplicationLocale("");
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool App::IsAeroGlassEnabled() {
|
||||
return ui::win::IsAeroGlassEnabled();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool App::MakeSingleInstance(
|
||||
const ProcessSingleton::NotificationCallback& callback) {
|
||||
if (process_singleton_.get())
|
||||
|
@ -471,13 +464,10 @@ void App::BuildPrototype(
|
|||
#if defined(OS_MACOSX)
|
||||
.SetMethod("hide", base::Bind(&Browser::Hide, browser))
|
||||
.SetMethod("show", base::Bind(&Browser::Show, browser))
|
||||
.SetMethod("isDarkMode",
|
||||
base::Bind(&Browser::IsDarkMode, browser))
|
||||
#endif
|
||||
#if defined(OS_WIN)
|
||||
.SetMethod("setUserTasks",
|
||||
base::Bind(&Browser::SetUserTasks, browser))
|
||||
.SetMethod("isAeroGlassEnabled", &App::IsAeroGlassEnabled)
|
||||
#endif
|
||||
.SetMethod("setPath", &App::SetPath)
|
||||
.SetMethod("getPath", &App::GetPath)
|
||||
|
|
|
@ -114,10 +114,6 @@ class App : public AtomBrowserClient::Delegate,
|
|||
const net::CompletionCallback& callback);
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool IsAeroGlassEnabled();
|
||||
#endif
|
||||
|
||||
scoped_ptr<ProcessSingleton> process_singleton_;
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
#include "atom/common/node_includes.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "ui/base/win/shell.h"
|
||||
#endif
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
@ -18,6 +22,18 @@ SystemPreferences::SystemPreferences(v8::Isolate* isolate) {
|
|||
SystemPreferences::~SystemPreferences() {
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool SystemPreferences::IsAeroGlassEnabled() {
|
||||
return ui::win::IsAeroGlassEnabled();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
bool SystemPreferences::IsDarkMode() {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// static
|
||||
mate::Handle<SystemPreferences> SystemPreferences::Create(
|
||||
v8::Isolate* isolate) {
|
||||
|
@ -27,7 +43,11 @@ mate::Handle<SystemPreferences> SystemPreferences::Create(
|
|||
// static
|
||||
void SystemPreferences::BuildPrototype(
|
||||
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
|
||||
mate::ObjectTemplateBuilder(isolate, prototype);
|
||||
mate::ObjectTemplateBuilder(isolate, prototype)
|
||||
#if defined(OS_WIN)
|
||||
.SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled)
|
||||
#endif
|
||||
.SetMethod("isDarkMode", &SystemPreferences::IsDarkMode);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
|
|
@ -19,6 +19,11 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences> {
|
|||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::ObjectTemplate> prototype);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool IsAeroGlassEnabled();
|
||||
#endif
|
||||
bool IsDarkMode();
|
||||
|
||||
protected:
|
||||
explicit SystemPreferences(v8::Isolate* isolate);
|
||||
~SystemPreferences() override;
|
||||
|
|
|
@ -4,11 +4,19 @@
|
|||
|
||||
#include "atom/browser/api/atom_api_system_preferences.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
bool SystemPreferences::IsDarkMode() {
|
||||
NSString* mode = [[NSUserDefaults standardUserDefaults]
|
||||
stringForKey:@"AppleInterfaceStyle"];
|
||||
return [mode isEqualToString:@"Dark"];
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace api
|
||||
|
||||
|
|
|
@ -89,9 +89,6 @@ class Browser : public WindowListObserver {
|
|||
// Show the application.
|
||||
void Show();
|
||||
|
||||
// Check if the system is in Dark Mode.
|
||||
bool IsDarkMode();
|
||||
|
||||
// Bounce the dock icon.
|
||||
enum BounceType {
|
||||
BOUNCE_CRITICAL = 0,
|
||||
|
|
|
@ -27,11 +27,6 @@ void Browser::Show() {
|
|||
[[AtomApplication sharedApplication] unhide:nil];
|
||||
}
|
||||
|
||||
bool Browser::IsDarkMode() {
|
||||
NSString *mode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
|
||||
return [mode isEqualToString: @"Dark"];
|
||||
}
|
||||
|
||||
void Browser::AddRecentDocument(const base::FilePath& path) {
|
||||
NSString* path_string = base::mac::FilePathToNSString(path);
|
||||
if (!path_string)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const deprecate = require('electron').deprecate
|
||||
const session = require('electron').session
|
||||
const Menu = require('electron').Menu
|
||||
const electron = require('electron')
|
||||
const {deprecate, session, Menu} = electron
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
|
||||
const bindings = process.atomBinding('app')
|
||||
|
@ -65,39 +64,40 @@ for (i = 0, len = ref1.length; i < len; i++) {
|
|||
}
|
||||
|
||||
// Deprecated.
|
||||
|
||||
app.getHomeDir = deprecate('app.getHomeDir', 'app.getPath', function () {
|
||||
return this.getPath('home')
|
||||
})
|
||||
|
||||
app.getDataPath = deprecate('app.getDataPath', 'app.getPath', function () {
|
||||
return this.getPath('userData')
|
||||
})
|
||||
|
||||
app.setDataPath = deprecate('app.setDataPath', 'app.setPath', function (path) {
|
||||
return this.setPath('userData', path)
|
||||
})
|
||||
|
||||
app.resolveProxy = deprecate('app.resolveProxy', 'session.defaultSession.resolveProxy', function (url, callback) {
|
||||
return session.defaultSession.resolveProxy(url, callback)
|
||||
})
|
||||
|
||||
deprecate.rename(app, 'terminate', 'quit')
|
||||
|
||||
deprecate.event(app, 'finish-launching', 'ready', function () {
|
||||
// give default app a chance to setup default menu.
|
||||
setImmediate(() => {
|
||||
this.emit('finish-launching')
|
||||
})
|
||||
})
|
||||
|
||||
deprecate.event(app, 'activate-with-no-open-windows', 'activate', function (event, hasVisibleWindows) {
|
||||
if (!hasVisibleWindows) {
|
||||
return this.emit('activate-with-no-open-windows', event)
|
||||
}
|
||||
})
|
||||
|
||||
deprecate.event(app, 'select-certificate', 'select-client-certificate')
|
||||
if (process.platform === 'win32') {
|
||||
app.isAeroGlassEnabled = deprecate('app.isAeroGlassEnabled', 'systemPreferences.isAeroGlassEnabled', function () {
|
||||
return electron.systemPreferences.isAeroGlassEnabled();
|
||||
})
|
||||
} else if (process.platform === 'darwin') {
|
||||
app.isDarkMode = deprecate('app.isDarkMode', 'systemPreferences.isDarkMode', function () {
|
||||
return electron.systemPreferences.isDarkMode();
|
||||
})
|
||||
}
|
||||
|
||||
// Wrappers for native classes.
|
||||
var wrapDownloadItem = function (downloadItem) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue