[beast: 55/70] EBEAST: pick BrowserWindow defaults from a BrowserWindowDefaults CSS rule
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 55/70] EBEAST: pick BrowserWindow defaults from a BrowserWindowDefaults CSS rule
- Date: Tue, 28 Mar 2017 23:26:20 +0000 (UTC)
commit f47481e91565d134aa2cf2f9bc19eb7940799e09
Author: Tim Janik <timj gnu org>
Date: Tue Mar 7 17:53:37 2017 +0100
EBEAST: pick BrowserWindow defaults from a BrowserWindowDefaults CSS rule
Signed-off-by: Tim Janik <timj gnu org>
ebeast/main.js | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/ebeast/main.js b/ebeast/main.js
index 83a064a..a676544 100644
--- a/ebeast/main.js
+++ b/ebeast/main.js
@@ -5,17 +5,32 @@ const Electron = require ('electron');
var win;
function create_window ()
{
+ const FS = require ('fs');
// avoid menu flicker, leave menu construction to the window
Electron.Menu.setApplicationMenu (null);
+ // find some CSS presets needed as BrowserWindow defaults
+ let appcss = FS.readFileSync ('objects/app.css', 'UTF-8');
+ let rex = /\bBrowserWindowDefaults\s*{([^}]*)}/m;
+ appcss = rex.exec (appcss)[1]; // extract BrowserWindowDefaults section
+ rex = /\/\*([^*]|\*[^\/])*\*\//;
+ appcss = appcss.replace (rex, ' '); // remove comments
+ rex = /\bbackgroundColor\s*:\s*([^;}]*)\s*[;}]/mi;
+ const backgroundColor = rex.exec (appcss)[1];
+ rex = /\bdefaultFontSize\s*:\s*([^;}]*)\s*[;}]/mi;
+ const defaultFontSize = rex.exec (appcss)[1];
+ rex = /\bdefaultMonospaceFontSize\s*:\s*([^;}]*)\s*[;}]/mi;
+ const defaultMonospaceFontSize = rex.exec (appcss)[1];
// window configuraiton
const options = {
- width: 1820, height: 1024, // calling win.maximize() flickers, using a big size not
+ width: 1820, // calling win.maximize() causes flicker
+ height: 1365, // using a big initial size avoids flickering
+ backgroundColor: backgroundColor,
webPreferences: {
- defaultEncoding: 'UTF-8',
- defaultFontSize: 15,
- defaultMonospaceFontSize: 14,
+ defaultEncoding: 'UTF-8',
+ defaultFontSize: parseInt (defaultFontSize),
+ defaultMonospaceFontSize: parseInt (defaultMonospaceFontSize),
defaultFontFamily: {
- standard: 'Candara', // 'Times New Roman',
+ standard: 'sans', // 'Times New Roman',
serif: 'Constantia', // 'Times New Roman',
sansSerif: 'Candara', // 'Arial',
monospace: 'Consolas', // 'Courier New',
@@ -25,7 +40,6 @@ function create_window ()
},
show: false, // avoid incremental load effect, see 'ready-to-show'
darkTheme: true,
- backgroundColor: '#333333',
};
win = new Electron.BrowserWindow (options);
win.once ('ready-to-show', () => { win.show(); });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]