make custom titlebar user-configurable and prompt for relaunch on change

This commit is contained in:
Philipp Brumm
2016-06-28 14:02:57 +02:00
parent a357228876
commit faa1f935f8
6 changed files with 26 additions and 22 deletions

View File

@@ -196,7 +196,6 @@ class AtomEnvironment extends Model
notificationManager: @notifications, @applicationDelegate, @clipboard, viewRegistry: @views, assert: @assert.bind(this)
})
@titleBar = new TitleBar() if process.platform is 'darwin'
@themes.workspace = @workspace
@textEditors = new TextEditorRegistry
@@ -204,6 +203,9 @@ class AtomEnvironment extends Model
@config.load()
# This needs to happen after config.load()
@titleBar = new TitleBar() if process.platform is 'darwin' and @config.get('core.useCustomTitleBar')
@themes.loadBaseStylesheets()
@initialStyleElements = @styles.getSnapshot()
@themes.initialLoadComplete = true if onlyLoadBaseStyleSheets

View File

@@ -266,3 +266,9 @@ if process.platform in ['win32', 'linux']
type: 'boolean'
default: false
description: 'Automatically hide the menu bar and toggle it by pressing Alt. This is only supported on Windows & Linux.'
if process.platform is 'darwin'
module.exports.core.properties.useCustomTitleBar =
type: 'boolean'
default: false
description: 'Use custom, theme-aware title-bar.<br />Note: This currently does not include a file icon or title context menu.<br />This setting will require a relaunch of Atom to take effect.'

View File

@@ -76,6 +76,8 @@ class AtomApplication
@config.setSchema null, {type: 'object', properties: _.clone(require('../config-schema'))}
@config.load()
@config.onDidChange 'core.useCustomTitleBar', @promptForRelaunch
@autoUpdateManager = new AutoUpdateManager(@version, options.test, @resourcePath, @config)
@applicationMenu = new ApplicationMenu(@version, @autoUpdateManager)
@atomProtocolHandler = new AtomProtocolHandler(@resourcePath, @safeMode)
@@ -87,6 +89,7 @@ class AtomApplication
@setupDockMenu()
@storageFolder = new StorageFolder(process.env.ATOM_HOME)
if options.pathsToOpen?.length > 0 or options.urlsToOpen?.length > 0 or options.test
@openWithOptions(options)
else
@@ -706,3 +709,16 @@ class AtomApplication
openOptions.defaultPath = path
dialog.showOpenDialog(parentWindow, openOptions, callback)
promptForRelaunch: ->
chosen = dialog.showMessageBox BrowserWindow.getFocusedWindow(),
type: 'warning'
title: 'Relaunch required'
message: "To apply this setting, you'll need to relaunch Atom."
detail: ''
buttons: ['Relaunch Atom', 'Cancel']
if chosen is 0
# once we're using electron v.1.2.2
# app.relaunch()
app.quit()

View File

@@ -40,7 +40,7 @@ class AtomWindow
if process.platform is 'linux'
options.icon = @constructor.iconPath
if process.platform is 'darwin'
if process.platform is 'darwin' and global.atomApplication.config.get('core.useCustomTitleBar')
options.titleBarStyle = 'hidden'
@browserWindow = new BrowserWindow options