more work on the electron layer...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-10-04 18:17:01 +03:00
parent 70b65d034f
commit 3bc744e524

View File

@ -11,6 +11,12 @@ if(typeof(process) != 'undefined'){
var pathlib = requirejs('path') var pathlib = requirejs('path')
} }
var electron
try{
electron = requirejs('electron')
} catch(e){ }
var actions = require('lib/actions') var actions = require('lib/actions')
var features = require('lib/features') var features = require('lib/features')
var toggler = require('lib/toggler') var toggler = require('lib/toggler')
@ -109,28 +115,39 @@ module.NWHost = core.ImageGridFeatures.Feature({
var ElectronHostActions = actions.Actions({ var ElectronHostActions = actions.Actions({
get title(){ get title(){
}, return electron.remote.getCurrentWindow().getTitle() },
set title(value){ set title(value){
}, electron.remote.getCurrentWindow().setTitle(value) },
minimize: ['Window/Minimize', minimize: ['Window/Minimize',
function(){ function(){
// XXX electron.remote.getCurrentWindow().minimize() }],
}],
showDevTools: ['Interface|Development/Show Dev Tools', showDevTools: ['Interface|Development/Show Dev Tools',
function(){ function(){
// XXX electron.remote.getCurrentWindow().openDevTools() }],
}],
// XXX make this portable (osx, linux)...
showInFolder: ['File|Image/Show in $folder', showInFolder: ['File|Image/Show in $folder',
function(image){ function(image){
// XXX image = this.images[this.data.getImage(image)]
var base = image.base_path || this.location.path
var filename = image.path
var path = pathlib.normalize(base + '/' + filename)
requirejs('child_process')
// XXX make this portable (osx, linux)...
.exec('explorer.exe /select,'+JSON.stringify(path.replace(/\//g, '\\')))
//.exec('open -R '+JSON.stringify(path))
}], }],
// XXX this is almost generic, but it is not usable unless within // XXX this is almost generic, but it is not usable unless within
// a user event handler... // a user event handler...
// ...can we use this on electron??? // ...can we use this on electron???
// if this fails use:
// electron.remote.getCurrentWindow().isFullScreen(..)
// electron.remote.getCurrentWindow().setFullScreen(..)
toggleFullScreen: ['Window/Full screen mode', toggleFullScreen: ['Window/Full screen mode',
toggler.CSSClassToggler( toggler.CSSClassToggler(
function(){ return document.body }, function(){ return document.body },