From 5d888fa9ece5008dda835d3e012a51ff70cb7bc4 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 9 Dec 2018 13:09:22 +1200 Subject: Added theme open --- desktop/sources/index.html | 3 ++- desktop/sources/scripts/lib/theme.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/desktop/sources/index.html b/desktop/sources/index.html index 34cdac2..ce82658 100644 --- a/desktop/sources/index.html +++ b/desktop/sources/index.html @@ -63,7 +63,8 @@ terminal.controller.add("default","Theme","Default Theme",() => { terminal.theme.noir(); },"CmdOrCtrl+Shift+1") terminal.controller.add("default","Theme","Light Theme",() => { terminal.theme.pale(); },"CmdOrCtrl+Shift+2") - terminal.controller.add("default","Theme","Get More..",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Themes'); }) + terminal.controller.add("default","Theme","Open Theme",() => { terminal.theme.open(); },"CmdOrCtrl+Shift+o") + terminal.controller.add("default","Theme","Download Themes..",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Themes'); }) terminal.controller.commit() terminal.start() diff --git a/desktop/sources/scripts/lib/theme.js b/desktop/sources/scripts/lib/theme.js index 9b8ac21..4b9e3b1 100644 --- a/desktop/sources/scripts/lib/theme.js +++ b/desktop/sources/scripts/lib/theme.js @@ -2,6 +2,8 @@ function Theme (noir, pale) { const themer = this + const fs = require('fs') + const { dialog, app } = require('electron').remote this.collection = { noir: noir, pale: pale } this.active = this.collection.noir @@ -80,6 +82,16 @@ function Theme (noir, pale) { reader.readAsText(file) } + this.open = function () { + console.log('Open') + let paths = dialog.showOpenDialog(app.win, { properties: ['openFile'] }) + if (!paths) { console.log('Nothing to load') } + fs.readFile(paths[0], 'utf8', function (err, data) { + if (err) throw err + themer.load(data) + }) + } + window.addEventListener('dragover', this.drag) window.addEventListener('drop', this.drop) -- cgit v1.2.3