Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Fancy start tile on Windows (10 + possibly 8.1, would be nice to check).
Browse files Browse the repository at this point in the history
Changes only affect Windows build / install / update.
Fixes #2372
  • Loading branch information
bsclifton committed Jul 10, 2016
1 parent 1605fbc commit 88d2ec0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public/built

# Temp files
.DS_Store
temp.VisualElementsManifest.xml

# electron-packager output dirs
*-darwin-x64
Expand Down
23 changes: 20 additions & 3 deletions app/windowsInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,38 @@ const path = require('path')
const childProcess = require('child_process')
const spawn = childProcess.spawn
const spawnSync = childProcess.spawnSync
const execSync = childProcess.execSync
const app = electron.app
const appUserModelId = 'com.squirrel.brave.Brave'

const getBraveDefaultsBinPath = () => {
const getBraveBinPath = () => {
const appPath = app.getPath('exe')
const appDir = path.dirname(appPath)
return path.dirname(appPath)
}

const getBraveDefaultsBinPath = () => {
const appDir = getBraveBinPath()
return path.join(appDir, 'resources', 'braveDefaults.exe')
}

function CopyManifestFile () {
const versionedRoot = getBraveBinPath()
let updateRoot = versionedRoot.split('\\')
updateRoot.pop()
updateRoot = updateRoot.join('\\')
const cmd = 'copy "' + path.join(versionedRoot, 'Update.VisualElementsManifest.xml') + '" "' + updateRoot + '"'
execSync(cmd)
}

// windows installation events etc...
if (process.platform === 'win32') {
const shouldQuit = require('electron-squirrel-startup')

const cmd = process.argv[1]
if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
// The manifest file is used to customize the look of the Start menu tile.
// This function copies it from the versioned folder to the parent folder
// (where the auto-update executable lives)
CopyManifestFile()
// Launch defaults helper to add defaults on install
spawn(getBraveDefaultsBinPath(), [], { detached: true })
} else if (cmd === '--squirrel-uninstall') {
Expand Down
8 changes: 8 additions & 0 deletions res/Update.VisualElementsManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VisualElements
BackgroundColor="#404040"
ShowNameOnSquare150x150Logo="on"
ForegroundText="light"
Square70x70Logo="{{braveVersion}}\resources\start-tile-70.png"
Square150x150Logo="{{braveVersion}}\resources\start-tile-150.png" />
</Application>
Binary file added res/start-tile-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/start-tile-70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions tools/buildPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,23 @@ cmds = cmds.concat([
' --version-string.FileDescription="Brave"'
])

function BuildManifestFile () {
const fs = require('fs')
const fileContents = fs.readFileSync('./res/Update.VisualElementsManifest.xml', 'utf8')
const versionedFileContents = fileContents.replace(/{{braveVersion}}/g, 'app-' + VersionInfo.braveVersion)
fs.writeFileSync('temp.VisualElementsManifest.xml', versionedFileContents, 'utf8')
}

if (isLinux) {
cmds.push('mv Brave-linux-x64/Brave Brave-linux-x64/brave')
cmds.push('ncp ./app/extensions ' + path.join(buildDir, 'resources', 'extensions'))
} else if (isDarwin) {
cmds.push('ncp ./app/extensions ' + path.join(buildDir, 'Brave.app', 'Contents', 'Resources', 'extensions'))
} else if (isWindows) {
BuildManifestFile()
cmds.push('move .\\temp.VisualElementsManifest.xml "' + path.join(buildDir, 'Update.VisualElementsManifest.xml') + '"')
cmds.push('copy .\\res\\start-tile-70.png "' + path.join(buildDir, 'resources', 'start-tile-70.png') + '"')
cmds.push('copy .\\res\\start-tile-150.png "' + path.join(buildDir, 'resources', 'start-tile-150.png') + '"')
cmds.push('makensis.exe -DARCH=' + arch + ' res/braveDefaults.nsi')
cmds.push('ncp ./app/extensions ' + path.join(buildDir, 'resources', 'extensions'))
}
Expand Down

0 comments on commit 88d2ec0

Please sign in to comment.